rootfscheck.sh 985 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. export PATH=/usr/bin:/usr/sbin:/bin:/sbin
  3. if [ "$1" != "stop" ]; then
  4. ROOTDEV=`findmnt -v -o SOURCE -n -M /`
  5. echo "Checking root file system (^C to skip)..."
  6. if [ -x /sbin/fsck ]; then
  7. /sbin/fsck -C -a "$ROOTDEV"
  8. fsckresult=$?
  9. if [ $((fsckresult & 4)) -eq 4 ]; then
  10. echo "***********************"
  11. echo "WARNING WARNING WARNING"
  12. echo "***********************"
  13. echo "The root file system has problems which require user attention."
  14. echo "A maintenance shell will now be started; system will then be rebooted."
  15. /sbin/sulogin
  16. /sbin/reboot --use-passed-cfd -r
  17. elif [ $(($fsckresult & 2)) -eq 2 ]; then
  18. echo "***********************"
  19. echo "WARNING WARNING WARNING"
  20. echo "***********************"
  21. echo "The root file system had problems (now repaired): rebooting..."
  22. sleep 5
  23. /sbin/reboot --use-passed-cfd -r
  24. fi
  25. else
  26. echo "WARNING - Could not find /sbin/fsck"
  27. fi
  28. fi;