? daemons/runsystem.sh.in Index: Makeconf =================================================================== RCS file: /cvsroot/hurd/hurd/Makeconf,v retrieving revision 1.206 diff -u -p -r1.206 Makeconf --- Makeconf 10 Oct 2003 10:04:05 -0000 1.206 +++ Makeconf 26 Jan 2004 22:59:55 -0000 @@ -63,6 +63,7 @@ INCLUDES += -I.. $(top_srcdirinc) endif INCLUDES += -I$(..)include -I$(top_srcdir)/include CPPFLAGS += $(INCLUDES) \ + -DLIBEXECDIR=\"${libexecdir}\" \ -D_GNU_SOURCE -D_IO_MTSAFE_IO -D_FILE_OFFSET_BITS=64 \ $($*-CPPFLAGS) CFLAGS += -std=gnu99 -Wall -g -O3 Index: config.make.in =================================================================== RCS file: /cvsroot/hurd/hurd/config.make.in,v retrieving revision 1.16 diff -u -p -r1.16 config.make.in --- config.make.in 22 Aug 2002 21:25:03 -0000 1.16 +++ config.make.in 26 Jan 2004 22:59:55 -0000 @@ -15,17 +15,17 @@ prefix = @prefix@ exec_prefix = @exec_prefix@ # Directories where things get installed. -hurddir = $(exec_prefix)/hurd -libdir = $(exec_prefix)/lib -bindir = $(exec_prefix)/bin -sbindir = $(exec_prefix)/sbin -includedir = $(exec_prefix)/include -libexecdir = $(exec_prefix)/libexec -bootdir = $(exec_prefix)/boot -infodir = $(prefix)/info -sysconfdir = $(prefix)/etc -localstatedir = $(prefix)/var -sharedstatedir = $(prefix)/com +hurddir = ${exec_prefix}/hurd +libdir = @libdir@ +bindir = @bindir@ +sbindir = @sbindir@ +includedir = @includedir@ +libexecdir = @libexecdir@ +bootdir = ${exec_prefix}/boot +infodir = @infodir@ +sysconfdir = @sysconfdir@ +localstatedir = @localstatedir@ +sharedstatedir = @sharedstatedir@ # All of those directories together: installationdirlist = $(hurddir) $(libdir) $(bindir) $(sbindir) \ Index: daemons/Makefile =================================================================== RCS file: /cvsroot/hurd/hurd/daemons/Makefile,v retrieving revision 1.11 diff -u -p -r1.11 Makefile --- daemons/Makefile 18 Jun 1999 22:04:43 -0000 1.11 +++ daemons/Makefile 26 Jan 2004 22:59:55 -0000 @@ -42,3 +42,6 @@ runttys: runttys.o runttys-LDLIBS = -lutil runsystem: runsystem.sh + +runsystem.sh: runsystem.sh.in + sed -e 's#@libexecdir@#${libexecdir}#g' $< >$@ Index: init/init.c =================================================================== RCS file: /cvsroot/hurd/hurd/init/init.c,v retrieving revision 1.129 diff -u -p -r1.129 init.c --- init/init.c 8 May 2002 09:20:38 -0000 1.129 +++ init/init.c 26 Jan 2004 22:59:55 -0000 @@ -1010,7 +1010,7 @@ start_child (const char *prog, char **pr if (progargs == 0) { - const char *argv[] = { "/libexec/console-run", prog, 0 }; + const char *argv[] = { LIBEXECDIR "/console-run", prog, 0 }; err = argz_create ((char **) argv, &args, &arglen); } else @@ -1020,7 +1020,7 @@ start_child (const char *prog, char **pr ++argc; { const char *argv[2 + argc + 1]; - argv[0] = "/libexec/console-run"; + argv[0] = LIBEXECDIR "/console-run"; argv[1] = prog; argv[2 + argc] = 0; while (argc-- > 0) @@ -1079,7 +1079,7 @@ launch_something (const char *why) static unsigned int try; static const char *const tries[] = { - "/libexec/runsystem", + LIBEXECDIR "/runsystem", _PATH_BSHELL, "/bin/shd", /* XXX */ }; --- /dev/null 1969-12-31 19:00:00.000000000 -0500 +++ runsystem.sh.in 2004-01-26 17:27:07.000000000 -0500 @@ -0,0 +1,140 @@ +#!/bin/bash +# +# This program is run by /hurd/init at boot time after the essential +# servers are up, and is responsible for running the "userland" parts of a +# normal system. This includes running the single-user shell as well as a +# multi-user system. This program is expected never to exit. +# + + +### +### Where to find programs, etc. +### + +PATH=/bin:/sbin +export PATH + +# If we lose badly, try to exec each of these in turn. +fallback_shells='/bin/sh /bin/bash /bin/csh /bin/ash /bin/shd' + +# Shell used for normal single-user startup. +SHELL=/bin/sh + +# Programs that do multi-user startup. +RUNCOM=@libexecdir@/rc +RUNTTYS=@libexecdir@/runttys +# Signals that we should pass down to runttys. +runttys_sigs='TERM INT HUP TSTP' + +### + + +# If we get a SIGLOST, attempt to reopen the console in case +# our console ports were revoked. This lets us print messages. +function reopen_console () +{ + exec 1>/dev/console 2>&1 || exit 3 +} +trap 'reopen_console' SIGLOST + + +# Call this when we are losing badly enough that we want to punt normal +# startup entirely. We exec a single-user shell, so we will not come back +# here. The only way to get to multi-user from that shell will be +# explicitly exec this script or something like that. +function singleuser () +{ + test $# -eq 0 || echo "$0: $*" + for try in ${fallback_shells}; do + SHELL=${try} + exec ${SHELL} + done + exit 127 +} + + +# We expect to be started by console-run, which gives us no arguments and +# puts FALLBACK_CONSOLE=file-name in the environment if our console is +# other than a normal /dev/console. + +if [ "${FALLBACK_CONSOLE+set}" = set ]; then + singleuser "Running on fallback console ${FALLBACK_CONSOLE}" +fi + + +### +### Normal startup procedures +### + +# Parse the multiboot command line. We only pay attention to -s and -f. +# The first argument is the kernel file name; skip that. +shift +flags= +while [ $# -gt 0 ]; do + arg="$1" + shift + case "$arg" in + --*) ;; + *=*) ;; + -*) + flags="${flags}${arg#-}" + ;; + 'single'|'emergency') # Linux compat + flags="${flags}s" + ;; + 'fastboot') + flags="${flags}f" + ;; + esac +done + +# Check boot flags. +case "$flags" in +*s*) + rc=false # force single-user + ;; +*f*) + rc="${RUNCOM}" # fastboot + ;; +*) + rc="${RUNCOM} autoboot" # multi-user default + ;; +esac + +# Large infinite loop. If this script ever exits, init considers that +# a serious bogosity and punts to a fallback single-user shell. +# We handle here the normal transitions between single-user and multi-user. +while : ; do + + # Run the rc script. As long as it exits nonzero, punt to single-user. + # After the single-user shell exits, we will start over attempting to + # run rc; but later invocations strip the `autoboot' argument. + until $rc; do + rc=${RUNCOM} + + # Run single-user shell and repeat as long as it dies with a signal. + until ${SHELL} || test $? -lt 128; do + : + done + done + + # Now we are officially ready for normal multi-user operation. + + # Trap certain signals and send them on to runttys. For this to work, we + # must run it asynchronously and wait for it with the `wait' built-in. + runttys_pid=0 + for sig in $runttys_sigs; do + trap "kill -$sig \${runttys_pid}" $sig + done + + # This program reads /etc/ttys and starts the programs it says to. + ${RUNTTYS} & + runttys_pid=$! + + # Wait for runttys to die, meanwhile handling trapped signals. + wait + + # Go back to the top of the infinite loop, as if booting single-user. + rc=false + +done --- runsystem.sh.in 2004-01-26 17:27:07.000000000 -0500 +++ /dev/null 1969-12-31 19:00:00.000000000 -0500 @@ -1,140 +0,0 @@ -#!/bin/bash -# -# This program is run by /hurd/init at boot time after the essential -# servers are up, and is responsible for running the "userland" parts of a -# normal system. This includes running the single-user shell as well as a -# multi-user system. This program is expected never to exit. -# - - -### -### Where to find programs, etc. -### - -PATH=/bin:/sbin -export PATH - -# If we lose badly, try to exec each of these in turn. -fallback_shells='/bin/sh /bin/bash /bin/csh /bin/ash /bin/shd' - -# Shell used for normal single-user startup. -SHELL=/bin/sh - -# Programs that do multi-user startup. -RUNCOM=@libexecdir@/rc -RUNTTYS=@libexecdir@/runttys -# Signals that we should pass down to runttys. -runttys_sigs='TERM INT HUP TSTP' - -### - - -# If we get a SIGLOST, attempt to reopen the console in case -# our console ports were revoked. This lets us print messages. -function reopen_console () -{ - exec 1>/dev/console 2>&1 || exit 3 -} -trap 'reopen_console' SIGLOST - - -# Call this when we are losing badly enough that we want to punt normal -# startup entirely. We exec a single-user shell, so we will not come back -# here. The only way to get to multi-user from that shell will be -# explicitly exec this script or something like that. -function singleuser () -{ - test $# -eq 0 || echo "$0: $*" - for try in ${fallback_shells}; do - SHELL=${try} - exec ${SHELL} - done - exit 127 -} - - -# We expect to be started by console-run, which gives us no arguments and -# puts FALLBACK_CONSOLE=file-name in the environment if our console is -# other than a normal /dev/console. - -if [ "${FALLBACK_CONSOLE+set}" = set ]; then - singleuser "Running on fallback console ${FALLBACK_CONSOLE}" -fi - - -### -### Normal startup procedures -### - -# Parse the multiboot command line. We only pay attention to -s and -f. -# The first argument is the kernel file name; skip that. -shift -flags= -while [ $# -gt 0 ]; do - arg="$1" - shift - case "$arg" in - --*) ;; - *=*) ;; - -*) - flags="${flags}${arg#-}" - ;; - 'single'|'emergency') # Linux compat - flags="${flags}s" - ;; - 'fastboot') - flags="${flags}f" - ;; - esac -done - -# Check boot flags. -case "$flags" in -*s*) - rc=false # force single-user - ;; -*f*) - rc="${RUNCOM}" # fastboot - ;; -*) - rc="${RUNCOM} autoboot" # multi-user default - ;; -esac - -# Large infinite loop. If this script ever exits, init considers that -# a serious bogosity and punts to a fallback single-user shell. -# We handle here the normal transitions between single-user and multi-user. -while : ; do - - # Run the rc script. As long as it exits nonzero, punt to single-user. - # After the single-user shell exits, we will start over attempting to - # run rc; but later invocations strip the `autoboot' argument. - until $rc; do - rc=${RUNCOM} - - # Run single-user shell and repeat as long as it dies with a signal. - until ${SHELL} || test $? -lt 128; do - : - done - done - - # Now we are officially ready for normal multi-user operation. - - # Trap certain signals and send them on to runttys. For this to work, we - # must run it asynchronously and wait for it with the `wait' built-in. - runttys_pid=0 - for sig in $runttys_sigs; do - trap "kill -$sig \${runttys_pid}" $sig - done - - # This program reads /etc/ttys and starts the programs it says to. - ${RUNTTYS} & - runttys_pid=$! - - # Wait for runttys to die, meanwhile handling trapped signals. - wait - - # Go back to the top of the infinite loop, as if booting single-user. - rc=false - -done