#!/ vim, this is /bash syntax !/ _check_fs() { local msg="$1" local cmd="$2" local msg2="$3" local prompt="$4" echo "$msg" $cmd if (($?>1)); then echo "$cmd returned with exit code $?" fatal "$msg2" fi } def checkfs_root desc "Checking root filesystem" start() { local C; ((SLOW_TERMINAL)) || C=C _check_fs "checking root-fs..." "/sbin/fsck -${C}Ta /" "*** *** error while checking root-fs *** root-fs still read-only!" "(root-fsck error) # " } end def "check_fs" "Checking filesystems" start() { local C; ((SLOW_TERMINAL)) || C=C _check_fs "checking filesystems..." "/sbin/fsck -${C}TARa /" "*** *** error while checking file-systems *** root-fs mounted read-write" "(fsck error) # " } end def "autoboot_check" "Open shell when not autobooting" start() { local TTY=${1:-/dev/tty3} if [ "$AUTOBOOT" != "YES" ]; then echo "Starting shell on $TTY" $SULOGIN $TTY & fi } end def cmos_clock desc System clock start() { echo "fetching system clock value..." /sbin/hwclock --hctosys --utc & } end def init_swap "Initializing swapspace..." start() { echo enabling swapping... safe_eval /sbin/swapon -av } end def mount_root Mounting root-fs start() { safe_eval /bin/mount -noremount,rw / || echo "WARNING: unable to mount root-fs read-write!" } stop() { safe_eval /bin/umount -noremount,ro / || echo "WARNING: unable to mount root-fs read-only!" } end def mount_devpts Mounting devpts-filesystem start() { safe_eval /bin/mount -ntdevpts -ogid=5,mode=620 none /dev/pts } end def mount_proc "Mounting proc-filesystem" start() { safe_eval /bin/mount -ntproc none /proc } end def check_modules "Checking/creating module dependencies" start() { local release=$(uname -r) echo "Linux release $release" rm -f /lib/modules/current if [ -d /lib/modules/$release ]; then ln -s $release /lib/modules/current if ! [ -f /lib/modules/current/modules.dep ]; then echo "Creating module dependencies" safe_eval /sbin/depmod -a fi else echo "NO MODULES FOUND!" fi } end def init_mtab "Initializing /etc/mtab" start() { rm -f /etc/mtab.tmp /etc/mtab~ /etc/nologin if [ -s /etc/mtab ]; then : >/etc/mtab fi safe_eval /bin/mount -f / } end def "kmesg" "Saving kernel messages" start() { { echo "-- `date` --" dmesg -c -s131072 klogd -o -f /dev/null } >/var/log/lastboot } end def "update" "Update daemon" start() { /sbin/update -s 20 -f 20 } end def "mount_ext2" "Mounting ext2 & reiserfs filesystems" start() { echo "mounting ext2 & reiserfs filesystems..." safe_eval /bin/mount -avtext2,reiserfs } end def "clear_misc" "Clearing volatile files" start() { rm -rf /var/lock/* /var/spool/locks/* /var/spool/uucp/LCK..* /tmp/.X0-lock rm -f /var/{run,pid}/{*/,}* } end def "check_logs" "Checking system log files" start() { $rcpath/checklogs } end def "clean_temp" "Deleting various /tmp dirs" start() { rm -rf /tmp/{.X*-lock,.X11-unix,.iroha_unix,.ki2-unix,jd_sockV4,mysql.sock} } end def "init_utmp" "Creating utmp" start() { : >/var/run/utmp } end def "mount_noext2" "Mounting non-ext2 filesystems" start() { echo "Mounting non-ext2 filesystems..." safe_eval /bin/mount -avtnoext2,noproc,noreiserfs,nodevpts } end