aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>1999-09-02 00:57:26 +0000
committerBill Nottingham <notting@redhat.com>1999-09-02 00:57:26 +0000
commite6d28cc5aaeabd53ed652eec63c2c22bb3f7e97c (patch)
tree519a94d0646687a868681da20d91e311c54f023f
parentacd1b3af175819b9209cde675deb4a88af32e506 (diff)
downloadinitscripts-e6d28cc5aaeabd53ed652eec63c2c22bb3f7e97c.tar
initscripts-e6d28cc5aaeabd53ed652eec63c2c22bb3f7e97c.tar.gz
initscripts-e6d28cc5aaeabd53ed652eec63c2c22bb3f7e97c.tar.bz2
initscripts-e6d28cc5aaeabd53ed652eec63c2c22bb3f7e97c.tar.xz
initscripts-e6d28cc5aaeabd53ed652eec63c2c22bb3f7e97c.zip
add interactive prompt to make Cristian & Preston happy
-rwxr-xr-xrc.d/init.d/functions3
-rwxr-xr-xrc.d/rc5
-rwxr-xr-xrc.d/rc.sysinit16
-rw-r--r--src/Makefile3
-rw-r--r--src/getkey.c47
5 files changed, 72 insertions, 2 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index eca7f56f..54e3a556 100755
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -230,6 +230,7 @@ echo_success() {
echo -n "OK"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo -n " ]"
+ echo -ne "\r"
return 0
}
@@ -240,6 +241,7 @@ echo_failure() {
echo -n "FAILED"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo -n "]"
+ echo -ne "\r"
return 1
}
@@ -250,6 +252,7 @@ echo_passed() {
echo -n "PASSED"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo -n "]"
+ echo -ne "\r"
return 1
}
diff --git a/rc.d/rc b/rc.d/rc
index bd0448c7..994814a8 100755
--- a/rc.d/rc
+++ b/rc.d/rc
@@ -21,10 +21,13 @@ export runlevel previous
# See if we want to be in user confirmation mode
if [ "$previous" = "N" ]; then
- if grep -i confirm /proc/cmdline >/dev/null ; then
+ if grep -i confirm /proc/cmdline >/dev/null || [ -f /tmp/confirm ] ; then
+ rm -f /tmp/confirm
CONFIRM=yes
+ echo "Entering interactive startup"
else
CONFIRM=
+ echo "Entering non-interactive startup"
fi
fi
diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit
index 1b323314..7295b3a2 100755
--- a/rc.d/rc.sysinit
+++ b/rc.d/rc.sysinit
@@ -25,6 +25,16 @@ fi
# Source functions
. /etc/rc.d/init.d/functions
+# Print a banner. ;)
+echo -en "\t\t\tWelcome to "
+[ "$BOOTUP" != "serial" ] && echo -en "\\033[1;31m
+echo -en "Red Hat"
+[ "$BOOTUP" != "serial" ] && echo -en "\\033[0;39m"
+echo " Linux"
+echo -en "\t\tPress 'I' to enter interactive startup."
+echo
+sleep 2
+
# Fix console loglevel
/sbin/loglevel $LOGLEVEL
@@ -367,6 +377,8 @@ if [ ! -f /fastboot ]; then
fi
fi
+
+{
# Mount all other filesystems (except for NFS and /proc, which is already
# mounted). Contrary to standard usage,
# filesystems are NOT unmounted in single user mode.
@@ -453,3 +465,7 @@ EOF
# Now that we have all of our basic modules loaded and the kernel going,
# let's dump the syslog ring somewhere so we can find it later
dmesg > /var/log/dmesg
+killall -TERM getkey >/dev/null 2>&1
+} &
+/sbin/getkey i && touch /tmp/confirm
+wait
diff --git a/src/Makefile b/src/Makefile
index 389c8b1c..8b9616ad 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,6 +1,6 @@
CFLAGS+=-Wall -D_GNU_SOURCE -g
-PROGS=usernetctl doexec netreport testd usleep ipcalc initlog minilogd loglevel
+PROGS=usernetctl doexec netreport testd usleep ipcalc initlog minilogd loglevel getkey
INITLOG_OBJS=initlog.o process.o
USLEEP_OBJS=usleep.o
@@ -19,6 +19,7 @@ install:
install -s -m 755 initlog $(ROOT)/sbin/initlog
install -s -m 755 minilogd $(ROOT)/sbin/minilogd
install -s -m 755 loglevel $(ROOT)/sbin/loglevel
+ install -s -m 755 getkey $(ROOT)/sbin/getkey
install -m 644 initlog.1 $(ROOT)/usr/man/man1
install -m 644 doexec.1 $(ROOT)/usr/man/man1
install -m 644 netreport.1 $(ROOT)/usr/man/man1
diff --git a/src/getkey.c b/src/getkey.c
new file mode 100644
index 00000000..b17558a3
--- /dev/null
+++ b/src/getkey.c
@@ -0,0 +1,47 @@
+
+#include <ctype.h>
+#include <signal.h>
+#include <string.h>
+#include <termios.h>
+#include <unistd.h>
+
+/* A very simple keygrabber. */
+
+struct termios tp;
+
+void reset_term(int x) {
+ tcsetattr(0,TCSANOW,&tp);
+ exit(x);
+}
+
+int main(int argc, char **argv) {
+ char foo[2];
+ int tp_if,tp_of,tp_lf;
+ int x;
+
+ if (argc>1) {
+ for (x=0;argv[1][x];x++) argv[1][x]=toupper(argv[1][x]);
+ }
+ foo[0]=foo[1]='\0';
+ signal(SIGTERM,reset_term);
+ tcgetattr(0,&tp);
+ tp_if=tp.c_iflag;
+ tp_of=tp.c_oflag;
+ tp_lf=tp.c_lflag;
+ tp.c_iflag=0;
+ tp.c_oflag &= ~OPOST;
+ tp.c_lflag &= ~(ISIG | ICANON);
+ tcsetattr(0,TCSANOW,&tp);
+ tp.c_iflag=tp_if;
+ tp.c_oflag=tp_of;
+ tp.c_lflag=tp_lf;
+ while (1) {
+ read(0,foo,1);
+ foo[0]=toupper(foo[0]);
+ /* Die if we get a control-c or control-d */
+ if (foo[0]==3 || foo[0]==4) reset_term(1);
+ if ((!argv[1]) || strstr(argv[1],foo)) {
+ reset_term(0);
+ }
+ }
+}