#!/bin/sh # /etc/rc - master bootup script, invokes php setup # part of pfSense by Scott Ullrich # Copyright (C) 2004 Scott Ullrich, All rights reserved. # originally based on m0n0wall (http://neon1.net/m0n0wall) # Copyright (C) 2003-2004 Manuel Kasper . # All rights reserved. # # mount /usr.uzip if it exists [ -x /usr.uzip ] && [ -d /usr ] && [ ! -d /usr/local ] \ && /sbin/mount_cd9660 /dev/`/sbin/mdconfig -af /usr.uzip`.uzip /usr HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin export HOME PATH # Set our current version version=`cat /etc/version` # Set our operating platform PLATFORM=`cat /etc/platform` echo cat /etc/ascii-art/pfsense-logo-small.txt echo echo echo "Welcome to pfSense ${version} on the '${PLATFORM}' platform..." echo if [ "$PLATFORM" = "cdrom" ]; then echo "Running CDROM routines..." /etc/rc.cdrom fi # Enable console output if its muted. /sbin/conscontrol mute off >/dev/null # Mount /. If it fails run a fsck. if [ ! "$PLATFORM" = "cdrom" ] ; then /sbin/mount -w / || /sbin/fsck -y fi # Check to see if a compact flash mountpoint exists # If it fails to mount then run a fsck -y if grep cf /etc/fstab; then /sbin/mount -w /cf || /sbin/fsck -y fi # Mount memory file system if it exists /sbin/mount -a if [ "$PLATFORM" = "cdrom" ] ; then echo "No swap on ${PLATFORM}" elif [ "$PLATFORM" = "embedded" ] ; then echo "No swap on ${PLATFORM}" /usr/local/bin/php -f /etc/rc.conf_mount_rw else /sbin/swapon -a 2>/dev/null /usr/local/bin/php -f /etc/rc.conf_mount_rw fi # Repair symlinks if they are broken if [ ! -L /etc/syslog.conf ]; then rm -rf /etc/syslog.conf ln -s /var/etc/syslog.conf /etc/syslog.conf fi # Repair symlinks if they are broken if [ ! -L /etc/hosts ]; then rm -rf /etc/hosts ln -s /var/etc/hosts /etc/hosts fi if [ ! -L /etc/resolv.conf ]; then rm -rf /etc/resolv.conf ln -s /var/etc/resolv.conf /etc/resolv.conf fi # Malloc debugging check if [ ! -L /etc/malloc.conf ]; then ln -s aj /etc/malloc.conf fi if [ ! -L /etc/dhclient.conf ]; then rm -rf /etc/dhclient.conf ln -s /var/etc/dhclient.conf /etc/dhclient.conf fi if [ ! -L /etc/sasyncd.conf ]; then mkdir -p /var/etc/ touch /var/etc/sasyncd.conf rm -rf /etc/sasyncd.conf ln -s /var/etc/sasyncd.conf /etc/sasyncd.conf chown root:wheel /var/etc/sasyncd.conf chmod 0600 /var/etc/sasyncd.conf fi [ ! -d /var/tmp ] || mkdir -p /var/tmp 2>/dev/null [ ! -d /cf/conf/backup/ ] || mkdir -p /cf/conf/backup/ 2>/dev/null [ ! -f /var/db/ez-ipupdate.cache ] || touch /var/db/ez-ipupdate.cache 2>/dev/null set -T trap "echo 'Reboot interrupted'; exit 1" 3 # Create uploadbar tmp directory mkdir -p /tmp/uploadbar chmod 777 /tmp/uploadbar # make some directories in /var mkdir -p /var/run /var/log /var/etc /var/db/entropy /var/at/jobs/ /var/empty 2>/dev/null rm -rf /var/log/* rm -rf /var/run/* rm -rf /tmp/* # generate circular logfiles if [ ! "$PLATFORM" = "cdrom" ]; then clog -i -s 10000 /var/log/system.log clog -i -s 10000 /var/log/filter.log clog -i -s 10000 /var/log/dhcpd.log clog -i -s 10000 /var/log/vpn.log clog -i -s 10000 /var/log/portalauth.log clog -i -s 10000 /var/log/ipsec.log clog -i -s 10000 /var/log/slbd.log else clog -i -s 262144 /var/log/system.log clog -i -s 262144 /var/log/filter.log clog -i -s 32768 /var/log/dhcpd.log clog -i -s 32768 /var/log/vpn.log clog -i -s 32768 /var/log/portalauth.log clog -i -s 10000 /var/log/ipsec.log clog -i -s 262144 /var/log/slbd.log fi # change permissions on newly created clog files. chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log /var/log/slbd.log /sbin/adjkerntz -i DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8` if [ "$DEVFS" = "0" ]; then mount_devfs devfs /dev fi # Create an initial utmp file cd /var/run && cp /dev/null utmp && chmod 644 utmp /sbin/ldconfig -elf /usr/lib /usr/local/lib /lib /usr/local/bin/php -f /etc/rc.conf_mount_rw # Make sure /etc/rc.conf doesn't exist. if [ -f /etc/rc.conf ]; then echo "Removing /etc/rc.conf..." rm -rf /etc/rc.conf fi echo -n "Starting USB... " /usr/sbin/usbd 2>>/tmp/bootup_messages /usr/local/sbin/kbdcheck echo "done." # let the PHP-based configuration subsystem set up the system now /etc/rc.bootup echo -n "Starting CRON... " /usr/sbin/cron 2>>/tmp/bootup_messages echo "done." if [ ! "$PLATFORM" = "cdrom" ]; then echo "Syncing packages..." /etc/rc.packages 2>/dev/null echo "Executing rc.d items... " for FILE in /usr/local/etc/rc.d/*.sh; do echo -n " Starting ${FILE}..." sh $FILE start >>/tmp/bootup_messages 2>&1 echo "done." done fi rm -rf /usr/local/pkg/pf/CVS /usr/local/bin/php -f /etc/rc.conf_mount_ro /usr/local/sbin/check_reload_status >/dev/null & echo "Bootup complete" if [ -e /dev/ttyv1 ]; then if [ ! -e /var/etc/console_lockdown ]; then # Allow VTY switching /usr/sbin/vidcontrol -S on 2>/dev/null # Turn off bloody mouse pointer. /usr/sbin/vidcontrol -m off 2>/dev/null env TERM=cons25 sh -c /etc/rc.initial 2>/dev/ttyv1 /dev/ttyv1 & sleep 1 /usr/sbin/vidcontrol -s 2 2>/dev/null fi else while [ 1 ]; do env TERM=cons25 sh -c "/etc/rc.initial" done exit fi /usr/local/bin/beep.sh start exit 0