aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJudd Vinet <judd@archlinux.org>2003-10-10 01:10:18 +0000
committerJudd Vinet <judd@archlinux.org>2003-10-10 01:10:18 +0000
commit7f4117b05f9e4730657779ec7d4b3b08ba12616c (patch)
tree7ae9206800c5f9495e8203f49a8ec8489536c6aa
parentbe8b6f59470b8779c3d4e10b3045507920931896 (diff)
downloadinitscripts-7f4117b05f9e4730657779ec7d4b3b08ba12616c.tar.xz
added color to rc messages and fixed bug #168
-rw-r--r--functions26
-rw-r--r--rc.conf2
-rwxr-xr-xrc.multi8
-rwxr-xr-xrc.shutdown59
-rwxr-xr-xrc.single66
-rwxr-xr-xrc.sysinit69
6 files changed, 132 insertions, 98 deletions
diff --git a/functions b/functions
index d79f30c..ab88827 100644
--- a/functions
+++ b/functions
@@ -3,26 +3,40 @@
# functions
#
-STAT_COL=68
+STAT_COL=$[`stty size | awk 'BEGIN { RS=" " }; END { print $1 }'` - 12]
deltext() {
echo -ne "\033[$(($STAT_COL+4))G"
}
stat_busy() {
- echo -n "[ $1 "
- awk "BEGIN { for (j=length(\"$1\"); j<$STAT_COL; j++) printf \" \" }"
- echo -n " BUSY ]"
+ if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
+ echo -ne "\033[1;32m| \033[1;37m$1\033[1;0m "
+ awk "BEGIN { for (j=length(\"$1\"); j<$STAT_COL; j++) printf \" \" }"
+ echo -ne " \033[1;34m[\033[1;33mbusy\033[1;34m]\033[1;0m"
+ else
+ echo -n "| $1 "
+ awk "BEGIN { for (j=length(\"$1\"); j<$STAT_COL; j++) printf \" \" }"
+ echo -n " [busy]"
+ fi
}
stat_done() {
deltext
- echo " DONE ]"
+ if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
+ echo -e " \033[1;34m[\033[1;32mdone\033[1;34m]\033[1;0m"
+ else
+ echo " [done]"
+ fi
}
stat_fail() {
deltext
- echo " FAILED ]"
+ if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
+ echo -e " \033[1;34m[\033[1;31mfail\033[1;34m]\033[1;0m"
+ else
+ echo " [fail]"
+ fi
}
stat_die() {
diff --git a/rc.conf b/rc.conf
index 59fb626..6b37163 100644
--- a/rc.conf
+++ b/rc.conf
@@ -9,11 +9,13 @@
# TIMEZONE: timezones are found in /usr/share/zoneinfo
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: fount in /usr/share/kbd/consolefonts (only needed for non-us)
+# USECOLOR: use ANSI color sequences in startup messages
#
HARDWARECLOCK="localtime"
TIMEZONE=Canada/Pacific
KEYMAP=us
CONSOLEFONT=
+USECOLOR="yes"
#
# Networking
diff --git a/rc.multi b/rc.multi
index 5e803b1..e33226e 100755
--- a/rc.multi
+++ b/rc.multi
@@ -8,13 +8,13 @@
# Start daemons
for daemon in "${DAEMONS[@]}"; do
- if [[ `echo $daemon | grep '^[^\!]' | wc -l` -eq 1 ]]; then
- /etc/rc.d/$daemon start
- fi
+ if [[ `echo $daemon | grep '^[^\!]' | wc -l` -eq 1 ]]; then
+ /etc/rc.d/$daemon start
+ fi
done
if [ -x /etc/rc.local ]; then
- /etc/rc.local
+ /etc/rc.local
fi
# End of file
diff --git a/rc.shutdown b/rc.shutdown
index ce13cef..78c85bb 100755
--- a/rc.shutdown
+++ b/rc.shutdown
@@ -9,24 +9,29 @@
# avoid staircase effect
/bin/stty onlcr
-echo -n "[ Shutting Down "
-echo " ]"
+if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
+ echo -e "\033[1;32m| \033[1;37mInitiating Shutdown...\033[1;0m"
+ echo -e "\033[1;32m|\033[1;0m"
+else
+ echo "| Initiating Shutdown..."
+ echo "|"
+fi
if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
- # Shutdown daemons
- let i=${#DAEMONS[@]}
- while [[ i -gt 0 ]]; do
- if [[ `echo ${DAEMONS[$i]} | grep '^[^\!]' | wc -l` -eq 1 ]]; then
- /etc/rc.d/${DAEMONS[$i]} stop
- fi
- let i=i-1
- done
- # find any leftover daemons and shut them down
- if [ -d /var/run/daemons ]; then
- for daemon in `ls /var/run/daemons`; do
- /etc/rc.d/$daemon stop
- done
- fi
+ # Shutdown daemons
+ let i=${#DAEMONS[@]}
+ while [[ i -ge 0 ]]; do
+ if [[ `echo ${DAEMONS[$i]} | grep '^[^\!]' | wc -l` -eq 1 ]]; then
+ /etc/rc.d/${DAEMONS[$i]} stop
+ fi
+ let i=i-1
+ done
+ # find any leftover daemons and shut them down
+ if [ -d /var/run/daemons ]; then
+ for daemon in `ls /var/run/daemons`; do
+ /etc/rc.d/$daemon stop
+ done
+ fi
fi
# Terminate all processes
@@ -45,9 +50,9 @@ stat_done
stat_busy "Saving System Clock"
if [ "$HARDWARECLOCK" = "UTC" ]; then
- /sbin/hwclock --utc --systohc
+ /sbin/hwclock --utc --systohc
else
- /sbin/hwclock --localtime --systohc
+ /sbin/hwclock --localtime --systohc
fi
stat_done
@@ -69,13 +74,19 @@ echo ""
# Power off or reboot
if [ "$RUNLEVEL" = "0" ]; then
- echo -n "[ POWER OFF "
- echo " ]"
- /sbin/poweroff -d -f -i
+ if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
+ echo -e ">>> \033[1;33mPOWER OFF\033[1;0m"
+ else
+ echo ">>> POWER OFF"
+ fi
+ /sbin/poweroff -d -f -i
else
- echo -n "[ REBOOTING "
- echo " ]"
- /sbin/reboot -d -f -i
+ if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
+ echo -e ">>> \033[1;33mREBOOTING\033[1;0m"
+ else
+ echo ">>> REBOOTING"
+ fi
+ /sbin/reboot -d -f -i
fi
# End of file
diff --git a/rc.single b/rc.single
index 24837ff..f96c0fe 100755
--- a/rc.single
+++ b/rc.single
@@ -7,45 +7,45 @@
. /etc/rc.d/functions
if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
- # Shutdown daemons
- let i=${#DAEMONS[@]}
- while [[ i -gt 0 ]]; do
- if [[ `echo ${DAEMONS[$i]} | grep '^[^\!]' | wc -l` -eq 1 ]]; then
- /etc/rc.d/${DAEMONS[$i]} stop
- fi
- let i=i-1
- done
- # find any leftover daemons and shut them down
- if [ -d /var/run/daemons ]; then
- for daemon in `ls /var/run/daemons`; do
- /etc/rc.d/$daemon stop
- done
- fi
+ # Shutdown daemons
+ let i=${#DAEMONS[@]}
+ while [[ i -gt 0 ]]; do
+ if [[ `echo ${DAEMONS[$i]} | grep '^[^\!]' | wc -l` -eq 1 ]]; then
+ /etc/rc.d/${DAEMONS[$i]} stop
+ fi
+ let i=i-1
+ done
+ # find any leftover daemons and shut them down
+ if [ -d /var/run/daemons ]; then
+ for daemon in `ls /var/run/daemons`; do
+ /etc/rc.d/$daemon stop
+ done
+ fi
fi
if [ "$PREVLEVEL" != "N" ]; then
- stat_busy "Sending SIGTERM To Processes"
- /sbin/killall5 -15 &> /dev/null
- /usr/bin/sleep 5
- stat_done
-
- stat_busy "Sending SIGKILL To Processes"
- /sbin/killall5 -9 &> /dev/null
- stat_done
-
- stat_busy "Starting DevFS Daemon"
- /sbin/devfsd /dev
- stat_done
-
- stat_busy "Starting Log Daemons"
- /usr/sbin/syslogd -m 0
- /usr/sbin/klogd -c 4
- stat_done
+ stat_busy "Sending SIGTERM To Processes"
+ /sbin/killall5 -15 &> /dev/null
+ /usr/bin/sleep 5
+ stat_done
+
+ stat_busy "Sending SIGKILL To Processes"
+ /sbin/killall5 -9 &> /dev/null
+ stat_done
+
+ stat_busy "Starting DevFS Daemon"
+ /sbin/devfsd /dev
+ stat_done
+
+ stat_busy "Starting Log Daemons"
+ /usr/sbin/syslogd -m 0
+ /usr/sbin/klogd -c 4
+ stat_done
fi
if [ "$RUNLEVEL" = "1" ]; then
- echo "Entering single-user mode..."
- exec /sbin/init -t1 S
+ echo "Entering single-user mode..."
+ exec /sbin/init -t1 S
fi
# End of file
diff --git a/rc.sysinit b/rc.sysinit
index 4ee2693..6124dbe 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -3,16 +3,25 @@
# /etc/rc.sysinit
#
-echo -n "[ "
-echo " ]"
-echo -n "[ Booting Arch Linux 0.5 "
-echo " ]"
-echo -n "[ "
-echo " ]"
-
. /etc/rc.conf
. /etc/rc.d/functions
+if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
+ echo -e "\n\033[1;32mArch Linux v0.5 \033[1;37m(\033[1;33mNova\033[1;37m)"
+ echo -e "\033[1;32m|\033[1;0m"
+ echo -e "\033[1;32m|\033[1;37m http://www.archlinux.org\033[1;0m"
+ echo -e "\033[1;32m|\033[1;0m Copyright 2002-2003 Judd Vinet"
+ echo -e "\033[1;32m|\033[1;0m Distributed under the GNU Public License (GPL)"
+ echo -e "\033[1;32m|\033[1;0m"
+else
+ echo -e "\nArch Linux v0.5 (Nova)"
+ echo "|"
+ echo "| http://www.archlinux.org"
+ echo "| Copyright 2002-2003 Judd Vinet"
+ echo "| Distributed under the GNU Public License (GPL)"
+ echo "|"
+fi
+
status "Starting DevFS Daemon" /sbin/devfsd /dev
if [ -f /etc/lvmtab ]; then
@@ -31,31 +40,29 @@ status "Activating Swap" /sbin/swapon -a
status "Mounting Root Read-only" /bin/mount -n -o remount,ro /
-if [ -x /sbin/fsck ]; then
- stat_busy "Checking Filesystems"
- /sbin/fsck -A -T -C -a
- if [ $? -gt 1 ]; then
- stat_fail
- echo
- echo "***************** FILESYSTEM CHECK FAILED ****************"
- echo "* *"
- echo "* Please repair manually and reboot. Note that the root *"
- echo "* file system is currently mounted read-only. To remount *"
- echo "* it read-write type: mount -n -o remount,rw / *"
- echo "* When you exit the maintainance shell the system will *"
- echo "* reboot automatically. *"
- echo "* *"
- echo "************************************************************"
- echo
- /sbin/sulogin -p
- echo "Automatic reboot in progress..."
- /bin/umount -a
- /bin/mount -n -o remount,ro /
- /sbin/reboot -f
- exit 0
- fi
- stat_done
+stat_busy "Checking Filesystems"
+/sbin/fsck -A -T -C -a
+if [ $? -gt 1 ]; then
+ stat_fail
+ echo
+ echo "***************** FILESYSTEM CHECK FAILED ****************"
+ echo "* *"
+ echo "* Please repair manually and reboot. Note that the root *"
+ echo "* file system is currently mounted read-only. To remount *"
+ echo "* it read-write type: mount -n -o remount,rw / *"
+ echo "* When you exit the maintainance shell the system will *"
+ echo "* reboot automatically. *"
+ echo "* *"
+ echo "************************************************************"
+ echo
+ /sbin/sulogin -p
+ echo "Automatic reboot in progress..."
+ /bin/umount -a
+ /bin/mount -n -o remount,ro /
+ /sbin/reboot -f
+ exit 0
fi
+stat_done
stat_busy "Mounting Local Filesystems"
/bin/mount -n -o remount,rw /