#!/bin/sh #---------------------------------------------------------------------------- # /etc/init.d/checkfs - initial boot script # # Creation : 2015-06-13 hbfl # Last Update: $Id$ # # Copyright (c) 2015-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- lsb=false if ${lsb} then # read init-functions . /lib/lsb/init-functions else # read functions . /etc/init.d/functions fi # --------------------------------------------------------------------------- # usage # --------------------------------------------------------------------------- usage() { cat </dev/null if [ ${?} -eq 0 ] then # -C display output with progressbar FSCK_PROGRESS='' if [ "`tty`" = "/dev/console" ] then FSCK_PROGRESS="-C" fi # force fsck, if /forcefsck exist # (e.g. from shutdown -rF now) # note that this reboots after fsck # and fsck again, afterwards continue booting FSCK_FORCE='' if [ -f /forcefsck ] then FSCK_FORCE="-f" fi if ${lsb} then log_info_msg "Checking file systems...\n" else boot_mesg " * Checking file systems..." fi /sbin/fsck ${FSCK_PROGRESS} -A -p ${FSCK_FORCE} 2>/dev/null fsck_ret=${?} case ${fsck_ret} in 0|1) # nothing to do ;; 2|3) /bin/sync /sbin/reboot -f ;; *) echo echo "fsck failed. Please repair manually and reboot. The root" echo "file system is currently mounted read-only. To remount it" echo "read-write do:" echo echo " bash# mount -n -o remount,rw /" echo echo "Attention: Only CONTROL-D will reboot the system in this" echo "maintanance mode. shutdown or reboot will not work." echo PS1="(repair filesystem) # " export PS1 /bin/sh /dev/console 2>&1 # if the user has mounted something rw, this should be umounted echo "Unmounting file systems (ignore error messages)" /bin/umount -avn # on umsdos fs this would lead to an error message. so direct # errors to /dev/null /bin/mount -no remount,ro / 2> /dev/null /bin/sync /sbin/reboot -f ;; esac fi evaluate_retval } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { while [ ${#} -gt 0 ] do case "${1}" in -q|--quiet) _quiet=true shift ;; *) _action=${1} shift ;; esac done case "${_action}" in start) start ;; *) usage exit 1 ;; esac exit 0 } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------