| 1 |
root |
1.1 |
#!/ vim, this is /bash syntax !/ |
| 2 |
|
|
|
| 3 |
|
|
_check_fs() { |
| 4 |
|
|
local msg="$1" |
| 5 |
|
|
local cmd="$2" |
| 6 |
|
|
local msg2="$3" |
| 7 |
|
|
local prompt="$4" |
| 8 |
|
|
|
| 9 |
|
|
echo "$msg" |
| 10 |
|
|
|
| 11 |
|
|
$cmd |
| 12 |
|
|
if (($?>1)); then |
| 13 |
|
|
echo "$cmd returned with exit code $?" |
| 14 |
|
|
fatal "$msg2" |
| 15 |
|
|
fi |
| 16 |
|
|
} |
| 17 |
|
|
|
| 18 |
|
|
def checkfs_root |
| 19 |
|
|
desc "Checking root filesystem" |
| 20 |
|
|
start() { |
| 21 |
|
|
local C; ((SLOW_TERMINAL)) || C=C |
| 22 |
|
|
_check_fs "checking root-fs..." "/sbin/fsck -${C}Ta /" "*** |
| 23 |
|
|
*** error while checking root-fs |
| 24 |
|
|
*** root-fs still read-only!" "(root-fsck error) # " |
| 25 |
|
|
} |
| 26 |
|
|
end |
| 27 |
|
|
|
| 28 |
|
|
def "check_fs" "Checking filesystems" |
| 29 |
|
|
start() { |
| 30 |
|
|
local C; ((SLOW_TERMINAL)) || C=C |
| 31 |
|
|
_check_fs "checking filesystems..." "/sbin/fsck -${C}TARa /" "*** |
| 32 |
|
|
*** error while checking file-systems |
| 33 |
|
|
*** root-fs mounted read-write" "(fsck error) # " |
| 34 |
|
|
} |
| 35 |
|
|
end |
| 36 |
|
|
|
| 37 |
|
|
def "autoboot_check" "Open shell when not autobooting" |
| 38 |
|
|
start() { |
| 39 |
|
|
local TTY=${1:-/dev/tty3} |
| 40 |
|
|
if [ "$AUTOBOOT" != "YES" ]; then |
| 41 |
|
|
echo "Starting shell on $TTY" |
| 42 |
|
|
$SULOGIN $TTY & |
| 43 |
|
|
fi |
| 44 |
|
|
} |
| 45 |
|
|
end |
| 46 |
|
|
|
| 47 |
|
|
def cmos_clock |
| 48 |
|
|
desc System clock |
| 49 |
|
|
start() { |
| 50 |
|
|
echo "fetching system clock value..." |
| 51 |
|
|
/sbin/hwclock --hctosys --utc & |
| 52 |
|
|
} |
| 53 |
|
|
end |
| 54 |
|
|
|
| 55 |
|
|
def init_swap "Initializing swapspace..." |
| 56 |
|
|
start() { |
| 57 |
|
|
echo enabling swapping... |
| 58 |
|
|
safe_eval /sbin/swapon -av |
| 59 |
|
|
} |
| 60 |
|
|
end |
| 61 |
|
|
|
| 62 |
|
|
def mount_root Mounting root-fs |
| 63 |
|
|
start() { |
| 64 |
|
|
safe_eval /bin/mount -noremount,rw / || |
| 65 |
|
|
echo "WARNING: unable to mount root-fs read-write!" |
| 66 |
|
|
} |
| 67 |
|
|
stop() { |
| 68 |
|
|
safe_eval /bin/umount -noremount,ro / || |
| 69 |
|
|
echo "WARNING: unable to mount root-fs read-only!" |
| 70 |
|
|
} |
| 71 |
|
|
end |
| 72 |
|
|
|
| 73 |
|
|
def mount_devpts Mounting devpts-filesystem |
| 74 |
|
|
start() { |
| 75 |
|
|
safe_eval /bin/mount -ntdevpts -ogid=5,mode=620 none /dev/pts |
| 76 |
|
|
} |
| 77 |
|
|
end |
| 78 |
|
|
|
| 79 |
|
|
def mount_proc "Mounting proc-filesystem" |
| 80 |
|
|
start() { |
| 81 |
|
|
safe_eval /bin/mount -ntproc none /proc |
| 82 |
|
|
} |
| 83 |
|
|
end |
| 84 |
|
|
|
| 85 |
|
|
def check_modules "Checking/creating module dependencies" |
| 86 |
|
|
start() { |
| 87 |
|
|
local release=$(uname -r) |
| 88 |
|
|
echo "Linux release $release" |
| 89 |
|
|
rm -f /lib/modules/current |
| 90 |
|
|
if [ -d /lib/modules/$release ]; then |
| 91 |
|
|
ln -s $release /lib/modules/current |
| 92 |
|
|
if ! [ -f /lib/modules/current/modules.dep ]; then |
| 93 |
|
|
echo "Creating module dependencies" |
| 94 |
|
|
safe_eval /sbin/depmod -a |
| 95 |
|
|
fi |
| 96 |
|
|
else |
| 97 |
|
|
echo "NO MODULES FOUND!" |
| 98 |
|
|
fi |
| 99 |
|
|
} |
| 100 |
|
|
end |
| 101 |
|
|
|
| 102 |
|
|
def init_mtab "Initializing /etc/mtab" |
| 103 |
|
|
start() { |
| 104 |
|
|
rm -f /etc/mtab.tmp /etc/mtab~ /etc/nologin |
| 105 |
|
|
if [ -s /etc/mtab ]; then |
| 106 |
|
|
: >/etc/mtab |
| 107 |
|
|
fi |
| 108 |
|
|
safe_eval /bin/mount -f / |
| 109 |
|
|
} |
| 110 |
|
|
end |
| 111 |
|
|
|
| 112 |
|
|
def "kmesg" "Saving kernel messages" |
| 113 |
|
|
start() { |
| 114 |
|
|
{ |
| 115 |
|
|
echo "-- `date` --" |
| 116 |
root |
1.2 |
dmesg -c -s131072 |
| 117 |
root |
1.1 |
klogd -o -f /dev/null |
| 118 |
|
|
} >/var/log/lastboot |
| 119 |
|
|
} |
| 120 |
|
|
end |
| 121 |
|
|
|
| 122 |
|
|
def "update" "Update daemon" |
| 123 |
|
|
start() { |
| 124 |
|
|
/sbin/update -s 20 -f 20 |
| 125 |
|
|
} |
| 126 |
|
|
end |
| 127 |
|
|
|
| 128 |
|
|
def "mount_ext2" "Mounting ext2 & reiserfs filesystems" |
| 129 |
|
|
start() { |
| 130 |
|
|
echo "mounting ext2 & reiserfs filesystems..." |
| 131 |
|
|
safe_eval /bin/mount -avtext2,reiserfs |
| 132 |
|
|
} |
| 133 |
|
|
end |
| 134 |
|
|
|
| 135 |
|
|
def "clear_misc" "Clearing volatile files" |
| 136 |
|
|
start() { |
| 137 |
|
|
rm -rf /var/lock/* /var/spool/locks/* /var/spool/uucp/LCK..* /tmp/.X0-lock |
| 138 |
|
|
rm -f /var/{run,pid}/{*/,}* |
| 139 |
|
|
} |
| 140 |
|
|
end |
| 141 |
|
|
|
| 142 |
|
|
def "check_logs" "Checking system log files" |
| 143 |
|
|
start() { |
| 144 |
|
|
$rcpath/checklogs |
| 145 |
|
|
} |
| 146 |
|
|
end |
| 147 |
|
|
|
| 148 |
|
|
def "clean_temp" "Deleting various /tmp dirs" |
| 149 |
|
|
start() { |
| 150 |
|
|
rm -rf /tmp/{.X*-lock,.X11-unix,.iroha_unix,.ki2-unix,jd_sockV4,mysql.sock} |
| 151 |
|
|
} |
| 152 |
|
|
end |
| 153 |
|
|
|
| 154 |
|
|
def "init_utmp" "Creating utmp" |
| 155 |
|
|
start() { |
| 156 |
|
|
: >/var/run/utmp |
| 157 |
|
|
} |
| 158 |
|
|
end |
| 159 |
|
|
|
| 160 |
|
|
def "mount_noext2" "Mounting non-ext2 filesystems" |
| 161 |
|
|
start() { |
| 162 |
|
|
echo "Mounting non-ext2 filesystems..." |
| 163 |
|
|
safe_eval /bin/mount -avtnoext2,noproc,noreiserfs,nodevpts |
| 164 |
|
|
} |
| 165 |
|
|
end |
| 166 |
|
|
|