--- trunk/magellan-initscripts/etc/rc.d/init.d/checkfs 2011/03/11 17:19:32 1252 +++ trunk/magellan-initscripts/etc/rc.d/init.d/checkfs 2011/03/11 17:20:16 1253 @@ -13,97 +13,106 @@ source /etc/conf.d/rc source ${rc_functions} -# stops annoying kernel messages -echo "0" > /proc/sys/kernel/printk - -if [ -f /fastboot ] -then - echo "Fast boot requested, will not perform file system checks ..." - exit 0 -fi - -echo -e ${COLOREDSTAR}"Mounting root file system in read-only mode ..." -mount -n -o remount,ro / -evaluate_retval - -if [ $? != 0 ] -then - $FAILURE - echo - echo "Cannot check root file system because it could not" - echo "be mounted in read-only mode." - echo - echo -n "When you press enter, this system will be halted." - $NORMAL - echo - echo "Press enter to continue ..." - read - echo "gonna run: $rc_base/init.d/halt" - $rc_base/init.d/halt -fi - -if [ -f /forcefsck ] -then - echo "/forcefsck exists, forcing file system check" - options="-f" -else - options="" -fi - -echo -e ${COLOREDSTAR}"Checking file systems ..." -#Note: -a option used to be -p; but this fails e.g. on fsck.minix -fsck $options -a -A -C -T -error_value=$? - -if [ "$error_value" = 1 ] -then - $WARNING - echo "File system errors were found and have been corrected." - echo "You may want to double-check that everything was fixed" - echo -n "properly" - $NORMAL - print_status warning -fi - -if [ "$error_value" = 0 ] -then - print_status success -fi - -if [ "$error_value" = 2 ] -then - $WARNING - echo "File system errors were found and have been corrected, but" - echo "the nature of the errors require this system to be rebooted." - echo - echo -n "When you press enter, this system will be rebooted." - $NORMAL - print_status warning - echo - echo "Please press enter to continue ..." - read - $rc_base/init.d/reboot -fi - -if [ "$error_value" -gt 2 -a "$error_value" -lt 16 ] -then - $FAILURE - echo "File system errors were encountered that couldn't be" - echo "fixed automatically. This system cannot continue to boot" - echo "and will therefore be halted until those errors fixed manually" - echo "by a System Administrator." - echo - echo -n "When you press enter, this system will be halted." - $NORMAL - print_status failure - echo - echo "Press enter to continue ..." - read - $rc_base/init.d/halt -fi - -#sets default level for kernel messages -echo "3" > /proc/sys/kernel/printk - -update_svcstatus $1 -splash svc_started "$(basename $0)" 0 +case "$1" in + start) + # stops annoying kernel messages + echo "0" > /proc/sys/kernel/printk + + if [ -f /fastboot ] + then + rc_echo "Fast boot requested, will not perform file system checks ..." + exit 0 + fi + + rc_print "Mounting root file system in read-only mode ..." + mount -n -o remount,ro / + evaluate_retval + + if [ $? != 0 ] + then + $FAILURE + rc_echo + rc_echo "Cannot check root file system because it could not" + rc_echo "be mounted in read-only mode." + rc_echo + rc_echo -n "When you press enter, this system will be halted." + $NORMAL + rc_echo + rc_echo "Press enter to continue ..." + read + rc_echo "gonna run: $rc_base/init.d/halt" + $rc_base/init.d/halt + fi + + if [ -f /forcefsck ] + then + rc_echo "/forcefsck exists, forcing file system check" + options="-f" + else + options="" + fi + + rc_print "Checking file systems ..." + #Note: -a option used to be -p; but this fails e.g. on fsck.minix + fsck $options -a -A -C -T + error_value=$? + + if [ "$error_value" = 1 ] + then + $WARNING + rc_echo "File system errors were found and have been corrected." + rc_echo "You may want to double-check that everything was fixed" + rc_echo -n "properly" + $NORMAL + print_status warning + fi + + if [ "$error_value" = 0 ] + then + print_status success + fi + + if [ "$error_value" = 2 ] + then + $WARNING + rc_echo "File system errors were found and have been corrected, but" + rc_echo "the nature of the errors require this system to be rebooted." + rc_echo + rc_echo -n "When you press enter, this system will be rebooted." + $NORMAL + print_status warning + rc_echo + rc_echo "Please press enter to continue ..." + read + $rc_base/init.d/reboot + fi + + if [ "$error_value" -gt 2 -a "$error_value" -lt 16 ] + then + $FAILURE + rc_echo "File system errors were encountered that couldn't be" + rc_echo "fixed automatically. This system cannot continue to boot" + rc_echo "and will therefore be halted until those errors fixed manually" + rc_echo "by a System Administrator." + rc_echo + rc_echo -n "When you press enter, this system will be halted." + $NORMAL + print_status failure + rc_echo + rc_echo "Press enter to continue ..." + rc_echo + $rc_base/init.d/halt + fi + + #sets default level for kernel messages + echo "3" > /proc/sys/kernel/printk + + update_svcstatus $1 + splash svc_started "$(basename $0)" 0 + ;; + + *) + rc_echo "Usage: $0 {start}" + exit 1 + ;; +esac