about summary refs log tree commit diff
path: root/1
diff options
context:
space:
mode:
authorJuan RP <xtraeme@gmail.com>2014-04-26 19:44:43 +0200
committerJuan RP <xtraeme@gmail.com>2014-04-26 19:44:43 +0200
commit5c6c44f1852c079f299ab2de985ea093162018a3 (patch)
tree1d0beabd33ce3f0f43487c1fe4086618c0e2d014 /1
parent8a1345f49ced3c78064421fc821e85a61761fce0 (diff)
downloadrunit-void-5c6c44f1852c079f299ab2de985ea093162018a3.tar.gz
runit-void-5c6c44f1852c079f299ab2de985ea093162018a3.tar.xz
runit-void-5c6c44f1852c079f299ab2de985ea093162018a3.zip
1: misc tweaks, preparing for more changes...
Diffstat (limited to '1')
-rwxr-xr-x186
1 files changed, 60 insertions, 26 deletions
diff --git a/1 b/1
index c498ac7..e8f7b79 100755
--- a/1
+++ b/1
@@ -1,37 +1,66 @@
 #!/bin/sh
 # vim: set ts=4 sw=4 et:
 
+emergency_shell() {
+    echo "Cannot continue due to errors above, starting emergency shell."
+    echo "When ready type exit to continue booting."
+    /bin/sh -l
+}
+
+msg() {
+    # bold
+    printf "\033[1m=> $@\033[m"
+}
+
+msg_ok() {
+    # bold/green
+    printf "\033[1m\033[32m OK\033[m\n"
+}
+
+msg_fail() {
+    # bold/red
+    printf "\033[1m\033[31m FAIL\033[m\n"
+}
+
+msg_warn() {
+    # bold/yellow
+    printf "\033[1m\033[33mWARNING: $@\033[m"
+}
+
 PATH=/usr/bin:/usr/sbin
 
-echo "Welcome to Void!"
+msg "Welcome to Void!\n"
 
 . /etc/rc.conf
 
-echo "Mounting pseudo-filesystems..."
-
+msg "Mounting pseudo-filesystems...\n"
 mountpoint -q /proc || mount -t proc proc /proc -o nosuid,noexec,nodev
 mountpoint -q /sys || mount -t sysfs sys /sys -o nosuid,noexec,nodev
 mountpoint -q /run || mount -t tmpfs run /run -o mode=0755,nosuid,nodev
 mountpoint -q /dev || mount -t devtmpfs dev /dev -o mode=0755,nosuid
-
 mkdir -p -m0755 /run/runit /run/lvm /run/user /dev/pts /dev/shm
 mountpoint -q /dev/pts || mount -n -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
 mountpoint -q /dev/shm || mount -n -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
 
-echo "Remounting rootfs read-only..."
+msg "Remounting rootfs read-only...\n"
 mount -o remount,ro /
 
-echo "Setting up console fonts..."
+msg "Setting up ttys to unicode mode...\n"
 for i in /dev/tty[0-6]; do
     unicode_start < $i
-    [ -n "$CONSOLEFONT" ] && setfont ${CONSOLEMAP:+-m $CONSOLEMAP} $CONSOLEFONT -C $i
 done
+if [ -n "$CONSOLEFONT" ]; then
+    msg "Setting up ttys font to '${CONSOLEFONT}'...\n"
+    for i in /dev/tty[0-6]; do
+        setfont ${CONSOLEMAP:+-m $CONSOLEMAP} $CONSOLEFONT -C $i
+    done
+fi
 
-echo "Loading keymap ${KEYMAP:-us}..."
+msg "Setting up keymap to '${KEYMAP:-us}'...\n"
 loadkeys -q -u ${KEYMAP:-us}
 
 if [ -n "$HARDWARECLOCK" ]; then
-    echo "Setting up RTC to ${HARDWARECLOCK}..."
+    msg "Setting up RTC to '${HARDWARECLOCK}'...\n"
     TZ=$TIMEZONE hwclock --systz \
         ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z) --noadjfile}
 fi
@@ -41,45 +70,50 @@ if [ -x /usr/lib/systemd/systemd-udevd ]; then
 elif [ -x /usr/sbin/udevd ]; then
     _udevd=/usr/sbin/udevd
 else
-    echo "WARNING: cannot find udevd!"
+    msg_warn "cannot find udevd!\n"
 fi
 
 if [ -n "${_udevd}" ]; then
-    echo "Starting udevd and waiting for devices to settle..."
-    ${_udevd} --daemon
-    udevadm trigger --action=add --type=subsystems
-    udevadm trigger --action=add --type=devices
-    udevadm settle
+    msg "Starting udev and waiting for devices to settle...\n"
+    { ${_udevd} --daemon;
+        udevadm trigger --action=add --type=subsystems;
+        udevadm trigger --action=add --type=devices;
+        udevadm settle; } || emergency_shell
 fi
 
-echo "Setting up loopback interface..."
+msg "Setting up loopback interface...\n"
 ip link set up dev lo
 
-echo "Setting up hostname..."
 if [ -n "$HOSTNAME" ]; then
     echo "$HOSTNAME" > /proc/sys/kernel/hostname
 elif [ -r /etc/hostname ]; then
-    cat /etc/hostname > /proc/sys/kernel/hostname
+    HOSTNAME=$(cat /etc/hostname)
+    echo "$HOSTNAME" > /proc/sys/kernel/hostname
 fi
+msg "Setting up hostname to '${HOSTNAME}'...\n"
 
-echo "Checking filesystems..."
+msg "Checking filesystems:\n"
 fsck -A -T -a -t noopts=_netdev
+rval=$?
+if [ $rval -gt 1 ]; then
+    emergency_shell
+fi
 
-echo "Mounting rootfs read-write..."
+msg "Mounting rootfs read-write...\n"
 mount -o remount,rw /
 
-echo "Mounting all non-network filesystems..."
+msg "Mounting all non-network filesystems...\n"
 mount -a -t "nosysfs,nonfs,nonfs4,nosmbfs,nocifs" -O no_netdev
 
-echo "Initializing swap..."
+msg "Initializing swap...\n"
 swapon -a
 
 if [ -n "$TIMEZONE" ]; then
-    echo "Setting up timezone to ${TIMEZONE}..."
+    msg "Setting up timezone to '${TIMEZONE}'...\n"
     ln -sf "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
 fi
 
-echo "Initializing random seed..."
+msg "Initializing random seed...\n"
 cp /var/lib/random-seed /dev/urandom >/dev/null 2>&1 || true
 ( umask 077; dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 >/dev/null 2>&1 )
 
@@ -87,7 +121,7 @@ install -m0664 -o root -g utmp /dev/null /run/utmp
 rm -f /etc/nologin /forcefsck /forcequotacheck /fastboot
 
 if [ -n "$MODULES" ]; then
-    echo "Loading kernel modules..."
+    msg "Loading kernel modules: ${MODULES} ...\n"
     modprobe -ab ${MODULES}
 fi
 
@@ -96,4 +130,4 @@ dmesg >/var/log/dmesg.log
 install -m0 /dev/null /etc/runit/reboot
 install -m0 /dev/null /etc/runit/stopit
 
-echo "Initialization complete, starting services..."
+msg "Initialization complete, running stage 2...\n"