From 9eeba20f44cc1e883606304091a03e64b8102244 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 4 Sep 2016 14:46:02 +0200 Subject: Fix installing runsystem.hurd * daemons/runsystem.hurd: Rename to daemons/runsystem.hurd.sh * daemons/Makefile (targets): Add runsystem.hurd (special-targets): Likewise. (runsystem.hurd): New rule, simply depends on runsystem.hurd.sh --- daemons/Makefile | 7 ++- daemons/runsystem.hurd | 155 ---------------------------------------------- daemons/runsystem.hurd.sh | 155 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+), 158 deletions(-) delete mode 100644 daemons/runsystem.hurd create mode 100644 daemons/runsystem.hurd.sh diff --git a/daemons/Makefile b/daemons/Makefile index 9d32617d..289fbf63 100644 --- a/daemons/Makefile +++ b/daemons/Makefile @@ -20,10 +20,10 @@ dir := daemons makemode := utilities -targets = rc getty mail.local console-run runttys runsystem -special-targets = rc runsystem +targets = rc getty mail.local console-run runttys runsystem runsystem.hurd +special-targets = rc runsystem runsystem.hurd SRCS = rc.sh runsystem.sh getty.c lmail.c console-run.c runttys.c \ - runsystem.hurd \ + runsystem.hurd.sh \ installationdir = $(libexecdir) @@ -45,3 +45,4 @@ runttys: runttys.o runttys-LDLIBS = -lutil runsystem: runsystem.sh +runsystem.hurd: runsystem.hurd.sh diff --git a/daemons/runsystem.hurd b/daemons/runsystem.hurd deleted file mode 100644 index f4f27711..00000000 --- a/daemons/runsystem.hurd +++ /dev/null @@ -1,155 +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 - -umask 022 - -# 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=/libexec/rc -RUNTTYS=/libexec/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 -} - - -# See whether pflocal is set up already, and do so if not (install case) -# -# Normally this should be the case, but we better make sure since -# without the pflocal server, pipe(2) does not work. -if ! test -e /servers/socket/1 ; then - # The root filesystem should be read-only at this point. - if fsysopts / --update --writable ; then - settrans -c /servers/socket/1 /hurd/pflocal - else - singleuser "Failed to create /servers/socket/1." - fi -fi - -# 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 diff --git a/daemons/runsystem.hurd.sh b/daemons/runsystem.hurd.sh new file mode 100644 index 00000000..f4f27711 --- /dev/null +++ b/daemons/runsystem.hurd.sh @@ -0,0 +1,155 @@ +#!/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 + +umask 022 + +# 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=/libexec/rc +RUNTTYS=/libexec/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 +} + + +# See whether pflocal is set up already, and do so if not (install case) +# +# Normally this should be the case, but we better make sure since +# without the pflocal server, pipe(2) does not work. +if ! test -e /servers/socket/1 ; then + # The root filesystem should be read-only at this point. + if fsysopts / --update --writable ; then + settrans -c /servers/socket/1 /hurd/pflocal + else + singleuser "Failed to create /servers/socket/1." + fi +fi + +# 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 -- cgit v1.2.3