diff options
author | ncopa <ncopa@f176ef85-8d20-0410-844a-e957b5a1c371> | 2006-10-24 12:26:42 +0000 |
---|---|---|
committer | ncopa <ncopa@f176ef85-8d20-0410-844a-e957b5a1c371> | 2006-10-24 12:26:42 +0000 |
commit | c8b95b81b69af4a0f90340f5874dcfe6ff057a9d (patch) | |
tree | 94bc4f11d8c3466b02d5aee235ff15c4fed3c50f /init.d/checkroot.sh | |
download | alpine-baselayout-c8b95b81b69af4a0f90340f5874dcfe6ff057a9d.tar.bz2 alpine-baselayout-c8b95b81b69af4a0f90340f5874dcfe6ff057a9d.tar.xz |
initial import based on 1.0.1
Diffstat (limited to 'init.d/checkroot.sh')
-rwxr-xr-x | init.d/checkroot.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/init.d/checkroot.sh b/init.d/checkroot.sh new file mode 100755 index 0000000..94fc7ff --- /dev/null +++ b/init.d/checkroot.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +rootmode=rw +rootopts=rw +rootcheck=yes +udevfs= + +# read the fstab +sed 's/#.*//' /etc/fstab | while read fs mnt type opts dump pass junk +do + [ "$type" = udevfs ] && udefs="$fs" + [ "$mnt" != / ] && continue + rootopts="$opts" + [ "$pass" = 0 -o "$pass" = "" ] && rootcheck=no + case "$opts" in + ro|ro,*|*,ro|*,ro,*) + rootmode=ro + ;; + esac +done + +if [ "$rootcheck" = yes ] ; then + if grep "^$fs" /proc/mounts ; then + echo "$fs is mounted. Something is wrong. Please fix and reboot." + echo "sorry newbies..." + echo + echo "CONTROL-D will exit from this shell and reboot the system." + echo + /sbin/sulogin $CONSOLE + reboot -f + elif ! fsck -C "$fs" ; then + echo "fsck failed. Please repair manually and reboot. Please note" + echo "that the root file system is currently mounted read-only. To" + echo "remount it read-write:" + echo + echo " # mount -n -o remount,rw /" + echo + echo "CONTROL-D will exit from this shell and REBOOT the system." + echo + /sbin/sulogin $CONSOLE + reboot -f + fi +fi + +mount -o remount,$rootmode / + |