summaryrefslogtreecommitdiffstats
path: root/sbin/rc.S
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/rc.S')
-rwxr-xr-xsbin/rc.S141
1 files changed, 96 insertions, 45 deletions
diff --git a/sbin/rc.S b/sbin/rc.S
index b85c86b..db0ccd5 100755
--- a/sbin/rc.S
+++ b/sbin/rc.S
@@ -1,10 +1,4 @@
#!/bin/sh
-#
-# /etc/rc.d/rc.S: System initialization script.
-#
-# Mostly written by: Patrick J. Volkerding, <volkerdi@ftp.cdrom.com>
-#
-
umask 022
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
@@ -30,7 +24,7 @@ if [ ! -d /dev/pts -a -w /dev/ ] ; then
mkdir /dev/pts
fi
-# Création du /dev/root s'il n'existe pas
+# Create /dev/root if it doesn't exist
if [ ! -e /dev/root ] ; then
if grep -q " root=" /proc/cmdline ; then
set `sed -e "s/^.* root=\([^ ]\+\).*/\1/" < /proc/cmdline`
@@ -44,7 +38,7 @@ fi
# /sbin/e2fsck -n /dev/root
# fi
-# Création du /dev/boot s'il n'existe pas
+# Create /dev/boot if it doesn't exist
if [ ! -e /dev/boot ] ; then
if grep -q " boot=" /proc/cmdline ; then
set `sed -e "s/^.* boot=\([^ ]\+\).*/\1/" < /proc/cmdline`
@@ -59,30 +53,41 @@ fi
/sbin/fsck -a -A -C -R
if [ $? -gt 1 ] ; then
- echo "Error with fsck, run 'fsck -y -a'"
- PS1="(Repair filesystem) \#"; export PS1
- sulogin
- echo "Unmounting file systems..."
- umount -a
- mount -n -o remount,ro /
- sync
- echo "Rebooting system..."
- sleep 2
- reboot
- /bin/sh
+ #echo "Error with fsck, run 'fsck -y -a'"
+ #PS1="(Repair filesystem) \#"; export PS1
+ #sulogin
+ #echo "Unmounting file systems..."
+ #umount -a
+ #mount -n -o remount,ro /
+ #sync
+ #echo "Rebooting system..."
+ #sleep 2
+ #reboot
+ #/bin/sh
+ echo "Error with fsck, run 'fsck -y -a'."
+ echo " => remounting ALL filesystems READ-ONLY !!!"
+ # mount file systems in fstab (and create an entry for /)
+ # but not NFS because TCP/IP is not yet configured
+ mount -rnat nonfs,noproc,notmpfs
+ mount -nat tmpfs
+else
+ # mount file systems in fstab (and create an entry for /)
+ # but not NFS because TCP/IP is not yet configured
+ mount -nat nonfs,noproc
fi
-# mount file systems in fstab (and create an entry for /)
-# but not NFS because TCP/IP is not yet configured
-mount -nat nonfs,noproc
-if [ ! -w /var ] ; then
- echo "Mounting /var as tmpfs"
- umount /var >/dev/null 2>&1
- mount -o mode=755 -t tmpfs /var /var
+# check whether /var is already mounted read-write. If not, we'll do
+# it because it's unacceptable to work in read-only mode !
+if touch /var/.$BOOTID >/dev/null 2>&1; then
+ rm -f /var/.$BOOTID >/dev/null 2>&1
+else
+ echo "WARNING: Mounting /var as tmpfs !"
+ umount /var >/dev/null 2>&1
+ mount -o mode=755 -t tmpfs /var /var
fi
-# Creat /var directories if they don't exist
+# Create /var directories if they don't exist
if [ ! -d /var/tmp ] ; then mkdir -m 1777 /var/tmp ; fi
if [ ! -d /var/run ] ; then mkdir /var/run ; fi
if [ ! -d /var/lib ] ; then mkdir /var/lib ; fi
@@ -94,33 +99,79 @@ if [ ! -d /var/adm/. ] ; then ln -s log /var/adm ; fi
sync
-if [ ! -w /tmp ] ; then
- echo "Mounting /tmp as tmpfs"
- umount /tmp >/dev/null 2>&1
- mount -o mode=1777 -t tmpfs /tmp /tmp
+# check whether /tmp is already mounted read-write. If not, we'll do
+# it because it's unacceptable to work in read-only mode !
+if touch /tmp/.$BOOTID >/dev/null 2>&1; then
+ rm -f /tmp/.$BOOTID >/dev/null 2>&1
+else
+ echo "Mounting /tmp as tmpfs"
+ umount /tmp >/dev/null 2>&1
+ mount -o mode=1777 -t tmpfs /tmp /tmp
+ if [ $? != 0 ]; then
+ echo "WARNING: could not mount /tmp as tmpfs."
+ if [ -L /tmp ]; then
+ echo " /tmp is a symlink to nowhere. Trying to fix its destination :"
+ (cd / && mkdir -vp `readlink /tmp`)
+ if [ $? -eq 0 ]; then
+ echo " => Success ! Now trying to mount /tmp again :"
+ else
+ echo " => Failed ! Trying to make /tmp a directory :"
+ (mv -v /tmp /tmp.old || rm -vf /tmp) && mkdir -v /tmp
+ if [ $? -eq 0 ]; then
+ echo " => Success ! Now trying to mount /tmp again :"
+ else
+ echo " => Failed ! Trying again by remounting / RW :"
+ mount -vwo remount / && (mv -v /tmp /tmp.old || rm -vf /tmp) && mkdir -v /tmp
+ mount -vo remount /
+ if [ ! -d /tmp ]; then
+ echo " => Failed ! The system may be unstable !!!"
+ else
+ echo " => Success ! you were lucky, but check if / has been correctly remounted !"
+ echo " => Now trying to mount /tmp again :"
+ fi
+ fi
+ fi
+ elif [ ! -d /tmp ]; then
+ echo " Trying to make /tmp a directory :"
+ (mv -v /tmp /tmp.old || rm -vf /tmp) && mkdir -v /tmp
+ if [ $? -eq 0 ]; then
+ echo " => Success ! Now trying to mount /tmp again :"
+ else
+ echo " => Failed ! Trying again by remounting / RW :"
+ mount -vwo remount / && (mv -v /tmp /tmp.old || rm -vf /tmp) && mkdir -v /tmp
+ mount -vo remount /
+ if [ ! -d /tmp ]; then
+ echo " => FAILED ! The system may be unstable !!!"
+ else
+ echo " => Success ! you were lucky, but check if / has been correctly remounted !"
+ echo " => Now trying to mount /tmp again :"
+ fi
+ fi
+ fi
+
+ # either it was a directory, or it now is.
+ if [ -d /tmp ]; then
+ mount -o mode=1777 -t tmpfs /tmp /tmp && echo " => Success !" || echo " => FAILED ! /tmp is a directory but is unmountable !!! The system may be unstable"
+ fi
+ fi
fi
-/bin/rm -rf /tmp/* /tmp/.[^.]* /tmp/..?*
+/bin/rm -f /var/run/utmp /var/run/*.pid >/dev/null 2>&1
+/bin/rm -rf /tmp/* /tmp/.[^.]* /tmp/..?* >/dev/null 2>&1
touch /var/log/wtmp /var/log/lastlog
if mkdir /tmp/.$BOOTID ; then
dmesg > /tmp/.$BOOTID/dmesg
fi
-# Clean up temporary files on the /var volume:
-/bin/rm -f /var/run/utmp /var/run/*.pid
-
-# Looks like we have to create this.
-cat /dev/null > /var/run/utmp
-
# Writing Status
-for dir in / /dev /tmp /var /etc /boot ; do
- s=""
- if [ -L $dir ] ; then s=$s"a symbolic-link " ; t=L ; fi
- if [ -w $dir ] ; then s=$s"read-write "; t=RW ; else
- s=$s"read-only " ; t=RO ; fi
- echo "$dir is $s"
-done
+#for dir in / /dev /tmp /var /etc /boot ; do
+# s=""
+# if [ -L $dir ] ; then s=$s"a symbolic-link " ; t=L ; fi
+# if [ -w $dir ] ; then s=$s"read-write "; t=RW ; else
+# s=$s"read-only " ; t=RO ; fi
+# echo "$dir is $s"
+#done
echo "Base system done." | lcdtee