Viitor_sysvinit/etc/init.d/checkfs
kueller 53725ed8b6 V962 Branch
git-svn-id: svn://svn.compuextreme.de/Viitor/V962/Viitor_sysvinit@4439 504e572c-2e33-0410-9681-be2bf7408885
2008-05-03 17:02:59 +00:00

157 lines
5.2 KiB
Bash

#!/bin/bash
#Framework, welches ein komplettes Linux System aus den Sourcen erstellt
#dieses Framework wird im CVS Repository
#:pserver:cvs.compuextreme.de:/Data/cvs zur Verfügung gestellt
#
#Lage dieser Datei im Archiv: $Source$
#
#(c) 2003 Harald Kueller, Germany
#This program is free software; you can redistribute it and/or
#modify ist 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.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#See the GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; if not write to the Free Software Foundation,
#Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#InitScript zum Start des Daemons:
#Start/Stop Script checkfs
#FileSystem Checks initiieren
#Basierend auf einer Vorlage von linuxfromscratch.org
#
#Letzte Änderung von: $Author$
#Datum der letzten Änderung: $Date$
#Version der Datei: $Revision$
#
#$Log$
#Revision 1.8 2004/03/03 12:48:07 kueller
#Header auf neuen Viitor GPL Header umgestellt
#
#
#Revision 1.7 2003/10/27 12:03:11 kueller
#volume Aktivierung mit entsprechender Bootmeldung versehen, und in
#Abfrage auf LVM Binarys eingepackt.
#
#Revision 1.6 2003/10/26 11:33:39 kueller
#Config-Schnittstelle hat sich geaendert. Volume Groups koennen nicht mehr
#Ueber ein File erfragt werden, sondern ueber vgdisplay.
#
#Revision 1.5 2003/07/15 06:40:51 kueller
#Prüfen der vorhandenen Volumes über /etc/sysconfig/lvmtab nicht möglich, da hier
#die Volumes ohne Trennzeichen stehen. Dies laesst die for schleife nicht funktionieren,
#sobald mehr als ein Volume im System vorhanden ist.
#Volumes stehen aber als Datei nocheinamal unter /etc/sysconfig/lvmtab.d. Eine Auswertung
#auf diese Dateien funktioniert auch bei mehreren Volumes.
#
#Revision 1.4 2002/10/15 17:34:25 kueller
#Korrekturen beim Variablenhandling. Bei IF Abfragen sollten Variablen in
#Anfuehrungszeichen stehen
#
#Revision 1.3 2002/10/10 08:12:19 kueller
#Aktivierung der volumes in mountfs macht probleme beim fsck, zu
#zum Zeitpunkt des fsck laufes die Volumes noch nicht bekannt sind.
#Zum Aktivieren der Volumes ist mindestens das vonhandensein von /proc
#notwendig. Daher werden die "none" Filesysteme (tmpfs, procfs, ptsfs, usbfs)
#nun bereits in checkfs angemeldet. Ausserdem werden die Volumes vor dem
#start von fsck aktiviert. Dies sollte speziell probleme mit ext2 und ext3
#Filesystemen beheben.
#
#Revision 1.2 2002/09/22 14:54:41 hkueller
#Aktivierung des Swap Bereichs erfolgt nun nach der Aktivierung der Volumes.
#Damit darf auf eine Volume als Swap verwendung finden
#
#Revision 1.1.1.1 2001/09/23 00:02:08 kueller
#Neustart wg. Datenverlust
#
#Revision 1.1.1.1 2001/08/08 10:02:32 kueller
#sysvinit addons
#
#
# Begin /etc/init.d/checkfs
source /etc/init.d/functions
echo "Changing state of rootfs to rw"
/bin/mount -n -o remount,rw /
evaluate_retval
echo >/etc/mtab
/bin/mount -f -o remount,rw /
for i in `sed -e "/^#/d" /etc/fstab|awk '{print $2}'`; do
MOUNTPOINT=$i
DEVICE=`awk '{if( $2 == "'$MOUNTPOINT'") print $1}' /etc/fstab`
if [ "$DEVICE" == "none" ]; then
echo -n "Mounting $MOUNTPOINT"
mount $MOUNTPOINT
evaluate_retval
fi
done
if [ -f /sbin/vgscan ]; then
echo -n "Scanning Volumes"
/sbin/vgscan >/dev/null 2>&1
evaluate_retval
for i in `vgdisplay|grep "VG Name"|awk '{print $3}'`; do
echo -n "Activating Volume $i"
vgchange -a y $i
evaluate_retval
done
fi
if [ -f /fastboot ]
then
echo "Fast boot, no file system check"
else
echo "Changing state of rootfs to ro"
/bin/mount -n -o remount,ro /
evaluate_retval
if [ $? = 0 ]
then
if [ -f /forcefsck ]
then
echo -n "/forcefsck exists, forcing "
echo "file system check"
force="-f"
else
force=""
fi
echo "Checking file systems..."
/sbin/fsck $force -a -A -C -T
if [ $? -gt 1 ]
then
$FAILURE
echo
echo -n "fsck failed. Please repair your file "
echo "systems manually by running /sbin/fsck"
echo "without the -a option"
echo
echo -n "Please note that the root file system "
echo "is currently mounted in read-only mode."
echo
echo -n "I will start sulogin now. When you "
echo "logout I will reboot your system."
echo
$NORMAL
/sbin/sulogin
/sbin/reboot -f
else
print_status success
fi
else
echo -n "Cannot check root file system because it "
echo "could not be mounted in read-only mode."
fi
fi
# End /etc/init.d/checkfs