]> git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blame - src/initscripts/system/checkfs
Merge branch 'master' of ssh://git.ipfire.org/pub/git/ipfire-2.x
[people/mfischer/ipfire-2.x.git] / src / initscripts / system / checkfs
CommitLineData
73d9a908 1#!/bin/sh
66c36198
PM
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
73d9a908
MT
21
22. /etc/sysconfig/rc
23. ${rc_functions}
24
25case "${1}" in
26 start)
dd46a3c5
MT
27 if [ -f /fastboot ]; then
28 boot_mesg -n "/fastboot found, will not perform" ${INFO}
73d9a908
MT
29 boot_mesg " file system checks as requested."
30 echo_ok
31 exit 0
32 fi
33
34 boot_mesg "Mounting root file system in read-only mode..."
35 mount -n -o remount,ro / >/dev/null
36 evaluate_retval
37
38 if [ ${?} != 0 ]; then
39 echo_failure
40 boot_mesg -n "FAILURE:\n\nCannot check root" ${FAILURE}
41 boot_mesg -n " filesystem because it could not be mounted"
42 boot_mesg -n " in read-only mode.\n\nAfter you"
43 boot_mesg -n " press Enter, this system will be"
44 boot_mesg -n " halted and powered off."
e147d1e6 45 boot_mesg -n "\n\nPress enter to continue or wait a minute..." ${INFO}
73d9a908 46 boot_mesg "" ${NORMAL}
e147d1e6 47 read -t 60 ENTER
73d9a908
MT
48 ${rc_base}/init.d/halt stop
49 fi
50
51 if [ -f /forcefsck ]; then
52 boot_mesg -n "/forcefsck found, forcing file" ${INFO}
53 boot_mesg " system checks as requested."
54 echo_ok
55 options="-f"
56 else
57 options=""
58 fi
59
60 boot_mesg "Checking file systems..."
61 # Note: -a option used to be -p; but this fails e.g.
62 # on fsck.minix
63 fsck ${options} -a -A -C -T 2>/dev/null
64 error_value=${?}
65
66 if [ "${error_value}" = 0 ]; then
67 echo_ok
68 fi
69
70 if [ "${error_value}" = 1 ]; then
71 echo_warning
72 boot_mesg -n "WARNING:\n\nFile system errors" ${WARNING}
73 boot_mesg -n " were found and have been corrected."
74 boot_mesg -n " You may want to double-check that"
75 boot_mesg -n " everything was fixed properly."
76 boot_mesg "" ${NORMAL}
77 fi
78
79 if [ "${error_value}" = 2 -o "${error_value}" = 3 ]; then
80 echo_warning
81 boot_mesg -n "WARNING:\n\nFile system errors" ${WARNING}
82 boot_mesg -n " were found and have been been"
83 boot_mesg -n " corrected, but the nature of the"
84 boot_mesg -n " errors require this system to be"
85 boot_mesg -n " rebooted.\n\nAfter you press enter,"
86 boot_mesg -n " this system will be rebooted"
e147d1e6 87 boot_mesg -n "\n\nPress Enter to continue or wait a minute..." ${INFO}
73d9a908 88 boot_mesg "" ${NORMAL}
e147d1e6 89 read -t 60 ENTER
73d9a908
MT
90 reboot -f
91 fi
92
93 if [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then
94 echo_failure
94f6d10b 95 sleep 2
73d9a908
MT
96 boot_mesg -n "FAILURE:\n\nFile system errors" ${FAILURE}
97 boot_mesg -n " were encountered that could not be"
98 boot_mesg -n " fixed automatically. This system"
99 boot_mesg -n " cannot continue to boot and will"
100 boot_mesg -n " therefore be halted until those"
101 boot_mesg -n " errors are fixed manually by a"
94f6d10b 102 boot_mesg -n " System Administrator.\n\n"
73d9a908 103 boot_mesg "" ${NORMAL}
94f6d10b
AF
104 sulogin
105 reboot -f
73d9a908
MT
106 fi
107
108 if [ "${error_value}" -ge 16 ]; then
109 echo_failure
110 boot_mesg -n "FAILURE:\n\nUnexpected Failure" ${FAILURE}
111 boot_mesg -n " running fsck. Exited with error"
112 boot_mesg -n " code: ${error_value}."
113 boot_mesg "" ${NORMAL}
114 exit ${error_value}
115 fi
116 ;;
117 *)
118 echo "Usage: ${0} {start}"
119 exit 1
120 ;;
121esac