FreeNAS Code
This project has moved to github - see https://github.com/freenas
Brought to you by:
cochard,
mattolander
#!/bin/sh # # /etc/rc #part of FreeNAS (http://www.freenas.org) #Copyright (C) 2005-2006 Olivier Cochard <cochard@gmail.com>. #All rights reserved. # #Based on m0n0wall (http://m0n0.ch/wall) #Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. #All rights reserved. stty status '^T' # Set shell to ignore SIGINT (2), but not children; # shell catches SIGQUIT (3) and returns to single user. # trap : 2 trap "echo 'Boot interrupted'; exit 1" 3 HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin export HOME PATH # Get operating platform PLATFORM=`cat /etc/platform` case ${PLATFORM} in i386-full) # If running from full, mount the root (/) in read-write. mount -u -o rw /; ;; *) # If running from liveCD or embedded, mount the root (ramdisk) in read-write. mount -u -o rw /dev/md0 /; ;; esac # Create directories in /var for dir in /var/run /var/log /var/log/samba /var/etc /var/etc/ssh /var/etc/private /var/etc/iscsi /var/db /var/mount /var/empty /var/cron /var/cron/tabs; do [ ! -d "${dir}" ] && mkdir -p ${dir} done # If the file /etc/cfdevice exist (this mean 'full' release), and symlink /var/etc/cfdevice doesn't exist.. create it. if [ -f "/etc/cfdevice" ] && [ ! -h /var/etc/cfdevice ] ; then ln -s /etc/cfdevice /var/etc/cfdevice fi # If the firmware.lock file, delete it (if not, all WebGUI pages will be redirected to upgrade page) if [ -f "/etc/cfdevice" ] ; then rm -f /var/run/firmware.lock fi # Make spool directorie (for afpd) if doesn't exist if [ ! -d "/var/spool" ]; then mkdir -p /var/spool mkdir -p /var/spool/lock fi # generate circular logfiles clog -i -s 262144 /var/log/system.log clog -i -s 32768 /var/log/ftp.log clog -i -s 32768 /var/log/rsyncd.log clog -i -s 32768 /var/log/sshd.log clog -i -s 32768 /var/log/lastlog clog -i -s 32768 /var/log/smartd.log clog -i -s 32768 /var/log/daemon.log chmod 0600 /var/log/*.log adjkerntz -i # Create an initial utmp file cd /var/run && cp /dev/null utmp && chmod 0644 utmp # Create symlink for lighttpd file upload if doesn't exist if [ ! -h "/var/tmp" ]; then ln -s /ftmp /var/tmp fi # Configure the shared library cache. /sbin/ldconfig -elf /usr/lib /usr/local/lib /lib # Let the other functions know we're booting. touch /var/etc/booting if [ "$1" = autoboot ]; then autoboot=yes _boot="faststart" rc_fast=yes # run_rc_command(): do fast booting else autoboot=no _boot="start" fi . /etc/rc.subr echo "Loading configuration files." load_rc_config 'XXX' skip="-s nostart" if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then skip="$skip -s nojail" if [ "$early_late_divider" = "mountcritlocal" ]; then early_late_divider=NETWORKING fi fi # Do a first pass to get everything up to $early_late_divider so that # we can do a second pass that includes $local_startup directories # files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null` for _rc_elem in ${files}; do run_rc_script ${_rc_elem} ${_boot} case "$_rc_elem" in */${early_late_divider}) break ;; esac done unset files local_rc # Now that disks are mounted, for each dir in $local_startup # search for init scripts that use the new rc.d semantics. # case ${local_startup} in [Nn][Oo] | '') ;; *) find_local_scripts_new ;; esac files=`rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null` _skip_early=1 for _rc_elem in ${files}; do case "$_skip_early" in 1) case "$_rc_elem" in */${early_late_divider}) _skip_early=0 ;; esac continue ;; esac run_rc_script ${_rc_elem} ${_boot} done # Let the other functions know we've finished booting. rm -f /var/etc/booting > /dev/null 2>&1 echo '' date exit 0