#!/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. stty status '^T' stty susp '^-' intr '^-' quit '^-' trap : 2 trap : 3 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin export HOME PATH version=`cat /etc/version` /sbin/conscontrol mute off echo echo "Welcome to pfSense ${version} ..." echo /sbin/mount -a || fsck -y && mount -a SWAPDEVICE=`cat /etc/fstab | grep swap | cut -f1` /sbin/dumpon -v $SWAPDEVICE 2>/dev/null /sbin/swapon -a 2>/dev/null /bin/mkdir -p /usr/savecore 2>/dev/null /sbin/savecore /usr/savecore $SWAPDEVICE /usr/local/bin/php -f /etc/rc.conf_mount_rw # 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 if [ ! -L /etc/dhclient.conf ]; then rm -rf /etc/dhclient.conf ln -s /var/etc/dhclient.conf /etc/dhclient.conf fi if [ ! -d /cf/conf/backup/ ]; then mkdir -p /cf/conf/backup/ 2>/dev/null fi /etc/rc.d/initrandom start >/dev/null /etc/rc.d/random start >/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 /var/run /var/log /var/etc /var/db/ipf 2>/dev/null chmod 0755 /var/db/ipf rm -rf /var/log/* rm -rf /var/run/* rm -rf /tmp/* # generate circular logfiles 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 chmod 0600 /var/log/system.log /var/log/filter.log /var/log/dhcpd.log /var/log/vpn.log /var/log/portalauth.log /sbin/adjkerntz -i DEVFS=`mount | grep devfs | wc -l | cut -d" " -f8` if [ "$DEVFS" = "0" ]; then mount_devfs devfs /dev fi echo -n "Syncing master.passwd... " /usr/sbin/pwd_mkdb -d /etc/ /etc/master.passwd echo "done." # Create an initial utmp file cd /var/run && cp /dev/null utmp && chmod 644 utmp # Build devices database #dev_mkdb # Run ldconfig /sbin/ldconfig -elf /usr/lib /usr/local/lib /lib /usr/local/bin/php -f /etc/rc.conf_mount_rw # let the PHP-based configuration subsystem set up the system now /etc/rc.bootup echo -n Starting Secure Shell Services... /etc/sshd echo -n "Starting USB... " /usr/sbin/usbd 2>>/tmp/bootup_messages echo "done." /usr/sbin/cron 2>>/tmp/bootup_messages /etc/rc.packages echo "Executing rc.d items... " for FILE in /usr/local/etc/rc.d/*.sh; do echo -n " Starting ${FILE}..." sh $FILE >>/tmp/bootup_messages 2>&1 echo "done." done if [ -f /tmp/filter_boot_dirty ]; then # one more pass to give package plugins a chance to adjust echo -n "Final firewall setup in progress..." /etc/rc.filter_configure echo "Done." fi /usr/local/bin/php -f /etc/rc.conf_mount_ro echo "Bootup complete" exit 0