]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/checkfs
httpscert: Increase size of the RSA key to 4096.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / checkfs
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/checkfs
4 #
5 # Description : File System Check
6 #
7 # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
8 # A. Luebke - luebke@users.sourceforge.net
9 #
10 # Version : 00.00
11 #
12 # Notes :
13 #
14 # Based on checkfs script from LFS-3.1 and earlier.
15 #
16 # From man fsck
17 # 0 - No errors
18 # 1 - File system errors corrected
19 # 2 - System should be rebooted
20 # 4 - File system errors left uncorrected
21 # 8 - Operational error
22 # 16 - Usage or syntax error
23 # 32 - Fsck canceled by user request
24 # 128 - Shared library error
25 #
26 #########################################################################
27
28 . /etc/sysconfig/rc
29 . ${rc_functions}
30
31 case "${1}" in
32 start)
33 if [ -f /fastboot ]; then
34 boot_mesg -n "/fastboot found, will not perform" ${INFO}
35 boot_mesg " file system checks as requested."
36 echo_ok
37 exit 0
38 fi
39
40 boot_mesg "Mounting root file system in read-only mode..."
41 mount -n -o remount,ro / >/dev/null
42 evaluate_retval
43
44 if [ ${?} != 0 ]; then
45 echo_failure
46 boot_mesg -n "FAILURE:\n\nCannot check root" ${FAILURE}
47 boot_mesg -n " filesystem because it could not be mounted"
48 boot_mesg -n " in read-only mode.\n\nAfter you"
49 boot_mesg -n " press Enter, this system will be"
50 boot_mesg -n " halted and powered off."
51 boot_mesg -n "\n\nPress enter to continue or wait a minute..." ${INFO}
52 boot_mesg "" ${NORMAL}
53 read -t 60 ENTER
54 ${rc_base}/init.d/halt stop
55 fi
56
57 if [ -f /forcefsck ]; then
58 boot_mesg -n "/forcefsck found, forcing file" ${INFO}
59 boot_mesg " system checks as requested."
60 echo_ok
61 options="-f"
62 else
63 options=""
64 fi
65
66 boot_mesg "Checking file systems..."
67 # Note: -a option used to be -p; but this fails e.g.
68 # on fsck.minix
69 fsck ${options} -a -A -C -T 2>/dev/null
70 error_value=${?}
71
72 if [ "${error_value}" = 0 ]; then
73 echo_ok
74 fi
75
76 if [ "${error_value}" = 1 ]; then
77 echo_warning
78 boot_mesg -n "WARNING:\n\nFile system errors" ${WARNING}
79 boot_mesg -n " were found and have been corrected."
80 boot_mesg -n " You may want to double-check that"
81 boot_mesg -n " everything was fixed properly."
82 boot_mesg "" ${NORMAL}
83 fi
84
85 if [ "${error_value}" = 2 -o "${error_value}" = 3 ]; then
86 echo_warning
87 boot_mesg -n "WARNING:\n\nFile system errors" ${WARNING}
88 boot_mesg -n " were found and have been been"
89 boot_mesg -n " corrected, but the nature of the"
90 boot_mesg -n " errors require this system to be"
91 boot_mesg -n " rebooted.\n\nAfter you press enter,"
92 boot_mesg -n " this system will be rebooted"
93 boot_mesg -n "\n\nPress Enter to continue or wait a minute..." ${INFO}
94 boot_mesg "" ${NORMAL}
95 read -t 60 ENTER
96 reboot -f
97 fi
98
99 if [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then
100 echo_failure
101 sleep 2
102 boot_mesg -n "FAILURE:\n\nFile system errors" ${FAILURE}
103 boot_mesg -n " were encountered that could not be"
104 boot_mesg -n " fixed automatically. This system"
105 boot_mesg -n " cannot continue to boot and will"
106 boot_mesg -n " therefore be halted until those"
107 boot_mesg -n " errors are fixed manually by a"
108 boot_mesg -n " System Administrator.\n\n"
109 boot_mesg "" ${NORMAL}
110 sulogin
111 reboot -f
112 fi
113
114 if [ "${error_value}" -ge 16 ]; then
115 echo_failure
116 boot_mesg -n "FAILURE:\n\nUnexpected Failure" ${FAILURE}
117 boot_mesg -n " running fsck. Exited with error"
118 boot_mesg -n " code: ${error_value}."
119 boot_mesg "" ${NORMAL}
120 exit ${error_value}
121 fi
122 ;;
123 *)
124 echo "Usage: ${0} {start}"
125 exit 1
126 ;;
127 esac
128
129 # End $rc_base/init.d/checkfs