Adds the upstart package to ptxdist. As we needed some way to start and stop services I first had a look on sysvinit. As this package is broken, I spent some effort on upstart.
It uses the current stable upstart and scripts taken from Ubuntu 8.10. There are still minor issues, but it replaces the Busybox inittab hack and provides even more and better features. I also tried version 0.5.0 but this seems to be beta and WIP. Signed-off-by: Carsten Schlote <[email protected]> -- Carsten Schlote <[email protected]> konzeptpark.de
[upstart-0.3.9] Add upstart package to ptxdist Adds the upstart package to ptxdist. As we needed some way to start and stop services I first had a look on sysvinit. As this package is broken, I spent some effort on upstart. It uses the current stable upstart and scripts taken from Ubuntu 8.10. There are still minor issues, but it replaces the Busybox inittab hack and provides even more and better features. I also tried version 0.5.0 but this seems to be beta and WIP. Signed-off-by: Carsten Schlote <[email protected]> diff --git a/generic/etc/default/rcS b/generic/etc/default/rcS new file mode 100644 index 0000000..090d64b --- /dev/null +++ b/generic/etc/default/rcS @@ -0,0 +1,17 @@ +# +# /etc/default/rcS +# +# Default settings for the scripts in /etc/rcS.d/ +# +# For information about these variables see the rcS(5) manual page. +# +# This file belongs to the "initscripts" package. + +TMPTIME=0 +SULOGIN=no +DELAYLOGIN=no +UTC=no +VERBOSE=no +FSCKFIX=no +RAMRUN=yes +RAMLOCK=yes diff --git a/generic/etc/event.d/control-alt-delete b/generic/etc/event.d/control-alt-delete new file mode 100644 index 0000000..35cb130 --- /dev/null +++ b/generic/etc/event.d/control-alt-delete @@ -0,0 +1,8 @@ +# control-alt-delete - emergency keypress handling +# +# This task is run whenever the Control-Alt-Delete key combination is +# pressed. Usually used to shut down the machine. + +start on control-alt-delete + +exec /sbin/shutdown -r now "Control-Alt-Delete pressed" diff --git a/generic/etc/event.d/logd b/generic/etc/event.d/logd new file mode 100644 index 0000000..3cbc052 --- /dev/null +++ b/generic/etc/event.d/logd @@ -0,0 +1,16 @@ +# logd +# +# This service is started automatically by init so that the output from +# other services can be logged. + +description "service logging daemon" +author "Scott James Remnant <[email protected]>" + +stop on runlevel 0 +stop on runlevel 1 +stop on runlevel 6 + +console output + +exec /sbin/logd +respawn diff --git a/generic/etc/event.d/rc-default b/generic/etc/event.d/rc-default new file mode 100644 index 0000000..191763d --- /dev/null +++ b/generic/etc/event.d/rc-default @@ -0,0 +1,23 @@ +# rc - runlevel compatibility +# +# This task guesses what the "default runlevel" should be and starts the +# appropriate script. + +start on stopped rcS + +script + runlevel --reboot || true + + if grep -q -w -- "-s\|single\|S" /proc/cmdline; then + telinit S + elif [ -r /etc/inittab ]; then + RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)" + if [ -n "$RL" ]; then + telinit $RL + else + telinit 2 + fi + else + telinit 2 + fi +end script diff --git a/generic/etc/event.d/rc0 b/generic/etc/event.d/rc0 new file mode 100644 index 0000000..d534826 --- /dev/null +++ b/generic/etc/event.d/rc0 @@ -0,0 +1,25 @@ +# rc0 - runlevel 0 compatibility +# +# This task runs the old sysv-rc runlevel 0 ("halt/poweroff") scripts with +# the decision as to whether to halt or power off the system left up to the +# script (and thus /etc/default/poweroff). + +start on runlevel 0 + +stop on runlevel [!0] + +console output +script + set $(runlevel || true) + if [ "$2" != "0" ] && [ "$2" != "6" ]; then + set $(runlevel --set 0 || true) + fi + + if [ "$1" != "unknown" ]; then + PREVLEVEL=$1 + RUNLEVEL=$2 + export PREVLEVEL RUNLEVEL + fi + + exec /etc/init.d/rc 0 +end script diff --git a/generic/etc/event.d/rc1 b/generic/etc/event.d/rc1 new file mode 100644 index 0000000..e016416 --- /dev/null +++ b/generic/etc/event.d/rc1 @@ -0,0 +1,19 @@ +# rc1 - runlevel 1 compatibility +# +# This task runs the old sysv-rc runlevel 1 ("single-user") scripts. + +start on runlevel 1 + +stop on runlevel [!1] + +console output +script + set $(runlevel --set 1 || true) + if [ "$1" != "unknown" ]; then + PREVLEVEL=$1 + RUNLEVEL=$2 + export PREVLEVEL RUNLEVEL + fi + + exec /etc/init.d/rc 1 +end script diff --git a/generic/etc/event.d/rc2 b/generic/etc/event.d/rc2 new file mode 100644 index 0000000..7a72972 --- /dev/null +++ b/generic/etc/event.d/rc2 @@ -0,0 +1,20 @@ +# rc2 - runlevel 2 compatibility +# +# This task runs the old sysv-rc runlevel 2 ("multi-user") scripts. It +# is usually started by the telinit compatibility wrapper. + +start on runlevel 2 + +stop on runlevel [!2] + +console output +script + set $(runlevel --set 2 || true) + if [ "$1" != "unknown" ]; then + PREVLEVEL=$1 + RUNLEVEL=$2 + export PREVLEVEL RUNLEVEL + fi + + exec /etc/init.d/rc 2 +end script diff --git a/generic/etc/event.d/rc3 b/generic/etc/event.d/rc3 new file mode 100644 index 0000000..e8b7b98 --- /dev/null +++ b/generic/etc/event.d/rc3 @@ -0,0 +1,20 @@ +# rc3 - runlevel 3 compatibility +# +# This task runs the old sysv-rc runlevel 3 (user defined) scripts. It +# is usually started by the telinit compatibility wrapper. + +start on runlevel 3 + +stop on runlevel [!3] + +console output +script + set $(runlevel --set 3 || true) + if [ "$1" != "unknown" ]; then + PREVLEVEL=$1 + RUNLEVEL=$2 + export PREVLEVEL RUNLEVEL + fi + + exec /etc/init.d/rc 3 +end script diff --git a/generic/etc/event.d/rc4 b/generic/etc/event.d/rc4 new file mode 100644 index 0000000..5f58090 --- /dev/null +++ b/generic/etc/event.d/rc4 @@ -0,0 +1,20 @@ +# rc4 - runlevel 4 compatibility +# +# This task runs the old sysv-rc runlevel 4 (user defined) scripts. It +# is usually started by the telinit compatibility wrapper. + +start on runlevel 4 + +stop on runlevel [!4] + +console output +script + set $(runlevel --set 4 || true) + if [ "$1" != "unknown" ]; then + PREVLEVEL=$1 + RUNLEVEL=$2 + export PREVLEVEL RUNLEVEL + fi + + exec /etc/init.d/rc 4 +end script diff --git a/generic/etc/event.d/rc5 b/generic/etc/event.d/rc5 new file mode 100644 index 0000000..ba3244b --- /dev/null +++ b/generic/etc/event.d/rc5 @@ -0,0 +1,20 @@ +# rc5 - runlevel 5 compatibility +# +# This task runs the old sysv-rc runlevel 5 (user defined) scripts. It +# is usually started by the telinit compatibility wrapper. + +start on runlevel 5 + +stop on runlevel [!5] + +console output +script + set $(runlevel --set 5 || true) + if [ "$1" != "unknown" ]; then + PREVLEVEL=$1 + RUNLEVEL=$2 + export PREVLEVEL RUNLEVEL + fi + + exec /etc/init.d/rc 5 +end script diff --git a/generic/etc/event.d/rc6 b/generic/etc/event.d/rc6 new file mode 100644 index 0000000..e3bfdaa --- /dev/null +++ b/generic/etc/event.d/rc6 @@ -0,0 +1,23 @@ +# rc6 - runlevel 6 compatibility +# +# This task runs the old sysv-rc runlevel 6 ("reboot") scripts. + +start on runlevel 6 + +stop on runlevel [!6] + +console output +script + set $(runlevel || true) + if [ "$2" != "0" ] && [ "$2" != "6" ]; then + set $(runlevel --set 6 || true) + fi + + if [ "$1" != "unknown" ]; then + PREVLEVEL=$1 + RUNLEVEL=$2 + export PREVLEVEL RUNLEVEL + fi + + exec /etc/init.d/rc 6 +end script diff --git a/generic/etc/event.d/rcS b/generic/etc/event.d/rcS new file mode 100644 index 0000000..406c247 --- /dev/null +++ b/generic/etc/event.d/rcS @@ -0,0 +1,20 @@ +# rcS - runlevel compatibility +# +# This task runs the old sysv-rc startup scripts. + +start on startup + +stop on runlevel + +# Note: there can be no previous runlevel here, if we have one it's bad +# information (we enter rc1 not rcS for maintenance). +console output +script + runlevel --set S >/dev/null || true + + PREVLEVEL=N + RUNLEVEL=S + export PREVLEVEL RUNLEVEL + + exec /etc/init.d/rcS +end script diff --git a/generic/etc/event.d/rcS-sulogin b/generic/etc/event.d/rcS-sulogin new file mode 100644 index 0000000..cc4af11 --- /dev/null +++ b/generic/etc/event.d/rcS-sulogin @@ -0,0 +1,28 @@ +# rcS-sulogin - "single-user" runlevel compatibility +# +# This task runs the sulogin binary during "single-user" mode. + +start on runlevel S + +stop on runlevel + +console owner +script + runlevel --set S >/dev/null || true + if [ -x /usr/share/recovery-mode/recovery-menu ]; then + /usr/share/recovery-mode/recovery-menu + else + /sbin/sulogin + fi + + if [ -r /etc/inittab ]; then + RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)" + if [ -n "$RL" ]; then + telinit $RL + else + telinit 2 + fi + else + telinit 2 + fi +end script diff --git a/generic/etc/event.d/sulogin b/generic/etc/event.d/sulogin new file mode 100644 index 0000000..144ea27 --- /dev/null +++ b/generic/etc/event.d/sulogin @@ -0,0 +1,20 @@ +# sulogin - rescue mode +# +# This task ensures that should the system fail to have any active jobs +# that the system administrator can rescue it; by giving them a shell. + +# Disabled since this would get started when init is re-exec'd, and +# "console owner" kills X. +# start on stalled + +exec /sbin/sulogin +console owner + +pre-start script + echo + echo "The system has reached a state where there are no jobs running." + echo "A shell will be spawned so that you may start such jobs that are" + echo "necessary." + echo + echo "Type 'exit' when finished." +end script diff --git a/generic/etc/event.d/tty1 b/generic/etc/event.d/tty1 new file mode 100644 index 0000000..0debbde --- /dev/null +++ b/generic/etc/event.d/tty1 @@ -0,0 +1,16 @@ +# tty1 - getty +# +# This service maintains a getty on tty1 from the point the system is +# started until it is shut down again. + +start on stopped rc2 +start on stopped rc3 +start on stopped rc4 +start on stopped rc5 + +stop on runlevel 0 +stop on runlevel 1 +stop on runlevel 6 + +respawn +exec /sbin/getty 38400 tty1 diff --git a/generic/etc/event.d/tty2 b/generic/etc/event.d/tty2 new file mode 100644 index 0000000..3f07f87 --- /dev/null +++ b/generic/etc/event.d/tty2 @@ -0,0 +1,16 @@ +# tty2 - getty +# +# This service maintains a getty on tty2 from the point the system is +# started until it is shut down again. + +start on runlevel 2 +start on runlevel 3 + +stop on runlevel 0 +stop on runlevel 1 +stop on runlevel 4 +stop on runlevel 5 +stop on runlevel 6 + +respawn +exec /sbin/getty 38400 tty2 diff --git a/generic/etc/event.d/tty3 b/generic/etc/event.d/tty3 new file mode 100644 index 0000000..b489222 --- /dev/null +++ b/generic/etc/event.d/tty3 @@ -0,0 +1,16 @@ +# tty3 - getty +# +# This service maintains a getty on tty3 from the point the system is +# started until it is shut down again. + +start on runlevel 2 +start on runlevel 3 + +stop on runlevel 0 +stop on runlevel 1 +stop on runlevel 4 +stop on runlevel 5 +stop on runlevel 6 + +respawn +exec /sbin/getty 38400 tty3 diff --git a/generic/etc/event.d/tty4 b/generic/etc/event.d/tty4 new file mode 100644 index 0000000..ea1783c --- /dev/null +++ b/generic/etc/event.d/tty4 @@ -0,0 +1,16 @@ +# tty4 - getty +# +# This service maintains a getty on tty4 from the point the system is +# started until it is shut down again. + +start on runlevel 2 +start on runlevel 3 + +stop on runlevel 0 +stop on runlevel 1 +stop on runlevel 4 +stop on runlevel 5 +stop on runlevel 6 + +respawn +exec /sbin/getty 38400 tty4 diff --git a/generic/etc/event.d/tty5 b/generic/etc/event.d/tty5 new file mode 100644 index 0000000..f218908 --- /dev/null +++ b/generic/etc/event.d/tty5 @@ -0,0 +1,16 @@ +# tty5 - getty +# +# This service maintains a getty on tty5 from the point the system is +# started until it is shut down again. + +start on runlevel 2 +start on runlevel 3 + +stop on runlevel 0 +stop on runlevel 1 +stop on runlevel 4 +stop on runlevel 5 +stop on runlevel 6 + +respawn +exec /sbin/getty 38400 tty5 diff --git a/generic/etc/event.d/tty6 b/generic/etc/event.d/tty6 new file mode 100644 index 0000000..1c5994e --- /dev/null +++ b/generic/etc/event.d/tty6 @@ -0,0 +1,16 @@ +# tty6 - getty +# +# This service maintains a getty on tty6 from the point the system is +# started until it is shut down again. + +start on runlevel 2 +start on runlevel 3 + +stop on runlevel 0 +stop on runlevel 1 +stop on runlevel 4 +stop on runlevel 5 +stop on runlevel 6 + +respawn +exec /sbin/getty 38400 tty6 diff --git a/generic/etc/init.d/halt b/generic/etc/init.d/halt new file mode 100755 index 0000000..fc45095 --- /dev/null +++ b/generic/etc/init.d/halt @@ -0,0 +1,84 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: halt +# Required-Start: +# Required-Stop: +# Default-Start: +# Default-Stop: 0 +# Short-Description: Execute the halt command. +# Description: +### END INIT INFO + +NETDOWN=yes + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +#[ -f /etc/default/halt ] && . /etc/default/halt +HALT=poweroff + +#. /lib/lsb/init-functions + +do_stop () { + if [ "$INIT_HALT" = "" ] + then + case "$HALT" in + [Pp]*) + INIT_HALT=POWEROFF + ;; + [Hh]*) + INIT_HALT=HALT + ;; + *) + INIT_HALT=POWEROFF + ;; + esac + fi + + # See if we need to cut the power. + if [ "$INIT_HALT" = "POWEROFF" ] && [ -x /etc/init.d/ups-monitor ] + then + /etc/init.d/ups-monitor poweroff + fi + + # Don't shut down drives if we're using RAID. + hddown="-h" + if grep -qs '^md.*active' /proc/mdstat + then + hddown="" + fi + + # If INIT_HALT=HALT don't poweroff. + poweroff="-p" + if [ "$INIT_HALT" = "HALT" ] + then + poweroff="" + fi + + # Make it possible to not shut down network interfaces, + # needed to use wake-on-lan + netdown="-i" + if [ "$NETDOWN" = "no" ]; then + netdown="" + fi + + #log_action_msg "Will now halt" + logger -p 0 "Will now halt" + halt -d -f $netdown $poweroff $hddown +} + +case "$1" in + start) + # No-op + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + do_stop + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac + diff --git a/generic/etc/init.d/rc b/generic/etc/init.d/rc new file mode 100755 index 0000000..a28a7ba --- /dev/null +++ b/generic/etc/init.d/rc @@ -0,0 +1,385 @@ +#! /bin/sh +# +# rc +# +# Starts/stops services on runlevel changes. +# +# Optimization: A start script is not run when the service was already +# configured to run in the previous runlevel. A stop script is not run +# when the the service was already configured not to run in the previous +# runlevel. +# +# Authors: +# Miquel van Smoorenburg <[email protected]> +# Bruce Perens <[email protected]> + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +export PATH + +# Un-comment the following for debugging. +# debug=echo + +# Specify method used to enable concurrent init.d scripts. +# Valid options are 'none', 'shell' and 'startpar'. To enable the +# concurrent boot option, the init.d script order must allow for +# concurrency. This is not the case with the default boot sequence in +# Debian as of 2008-01-20. Before enabling concurrency, one need to +# check the sequence values of all boot scripts, and make sure only +# scripts that can be started in parallel have the same sequence +# number, and that a scripts dependencies have a earlier sequence +# number. See the insserv package for a away to reorder the boot +# automatically to allow this. +CONCURRENCY=none + +# Make sure the name survive changing the argument list +scriptname="$0" + +umask 022 + +on_exit() { + echo "error: '$scriptname' exited outside the expected code flow." +} +trap on_exit EXIT # Enable emergency handler + +# Ignore CTRL-C only in this shell, so we can interrupt subprocesses. +trap ":" INT QUIT TSTP + +# Set onlcr to avoid staircase effect. +stty onlcr 0>&1 + +# Functions for splash progress bars +if [ -e /lib/init/splash-functions-base ] ; then + . /lib/init/splash-functions-base +else + # Quiet down script if old initscripts version without /lib/init/splash-functions-base is used. + splash_progress() { return 1; } +fi + +# Now find out what the current and what the previous runlevel are. + +runlevel=$RUNLEVEL +# Get first argument. Set new runlevel to this argument. +[ "$1" != "" ] && runlevel=$1 +if [ "$runlevel" = "" ] +then + echo "Usage: $scriptname <runlevel>" >&2 + exit 1 +fi +previous=$PREVLEVEL +[ "$previous" = "" ] && previous=N + +export runlevel previous + +. /etc/default/rcS +export VERBOSE + +if [ -f /lib/lsb/init-functions ] ; then + . /lib/lsb/init-functions +else + log_action_msg() { echo $@; } +fi + +# +# Stub to do progress bar ticks (for splash programs) on startup +# +startup_progress() { + # Avoid divide by zero if anyone moved xdm/kdm/gdm first in a runlevel. + if [ 0 -eq "$num_steps" ] ; then return; fi + + step=$(($step + $step_change)) + progress=$(($step * $progress_size / $num_steps + $first_step)) + $debug splash_progress "$progress" || true +} + +sh=sh +# Debian Policy ยง9.3.1 requires .sh scripts in runlevel S to be +# sourced However, some important packages currently contain .sh +# scripts that do "exit" at some point, thus killing this process and +# the boot. Bad! See also bug #339955. +#[ S = "$runlevel" ] && sh=. + +# +# Check if we are able to use make like booting. It require the +# insserv package to be enabled. +# +if [ startpar = "$CONCURRENCY" ] ; then + test -s /etc/init.d/.depend.boot || CONCURRENCY="none" + test -s /etc/init.d/.depend.start || CONCURRENCY="none" + test -s /etc/init.d/.depend.stop || CONCURRENCY="none" + startpar -v > /dev/null 2>&1 || CONCURRENCY="none" + + # startpar do not work properly at the start of rcS.d/. Avoid it. + # See #457896 for details. + + if [ S = "$runlevel" ] ; then + CONCURRENCY=none + fi +fi + +# +# Start script or program. +# +case "$CONCURRENCY" in + shell) + log_action_msg "Using shell-style concurrent boot in runlevel $runlevel" + startup() { + action=$1 + shift + scripts="$@" + backgrounded=0 + for script in $scripts ; do + case "$script" in + *.sh) + if [ "." = "$sh" ] ; then + RC_SAVE_PATH="$PATH" + set -- "$action" + $debug . "$script" + PATH="$RC_SAVE_PATH" + startup_progress + else + $debug $sh "$script" $action + startup_progress + fi + ;; + *) + $debug "$script" $action & + startup_progress + backgrounded=1 + ;; + esac + done + [ 1 = "$backgrounded" ] && wait + } + ;; + startpar) + log_action_msg "Using startpar-style concurrent boot in runlevel $runlevel" + startup() { + action=$1 + shift + scripts="$@" + # Make sure .sh scripts are sourced in runlevel S + if [ "." = "$sh" ] ; then + newscripts= + for script in $scripts ; do + case "$script" in + *.sh) + RC_SAVE_PATH="$PATH" + set -- "$action" + $debug . "$script" + PATH="$RC_SAVE_PATH" + startup_progress + ;; + *) + newscripts="$newscripts $script" + step=$(($step + $step_change)) + ;; + esac + done + scripts="$newscripts" + else + # Update progress bar counter and jump to the new position + for script in $scripts ; do + step=$(($step + $step_change)) + done + fi + + # startpar is not able to handle time jumps. So the + # hwclock.sh scripts should not be executed from + # within startpar. The .sh hack above make this + # problem irrelevant. [pere 2005-09-10] + [ -n "$scripts" ] && $debug startpar -a $action $scripts + + # Jump back one step to compencate for stepping one + # time too many in the for loop, and to keep the same + # location as the startup_progress call in the *.sh + # case. + step=$(($step - $step_change)) + startup_progress + } + ;; + none|*) + startup() { + action=$1 + shift + scripts="$@" + for script in $scripts ; do + case "$script" in + *.sh) + if [ "." = "$sh" ] ; then + RC_SAVE_PATH="$PATH" + set "$action" + $debug . "$script" + PATH="$RC_SAVE_PATH" + startup_progress + else + $debug $sh "$script" $action + startup_progress + fi + ;; + *) + $debug "$script" $action + startup_progress + ;; + esac + done + } + ;; +esac + +# Is there an rc directory for this new runlevel? +if [ -d /etc/rc$runlevel.d ] +then + # Find out where in the progress bar the initramfs got to. + PROGRESS_STATE=0 + if [ -f /dev/.initramfs/progress_state ]; then + . /dev/.initramfs/progress_state + fi + + # Split the remaining portion of the progress bar into thirds + progress_size=$(((100 - $PROGRESS_STATE) / 3)) + + case "$runlevel" in + 0|6) + ACTION=stop + # Count down from 0 to -100 and use the entire bar + first_step=0 + progress_size=100 + step_change=-1 + ;; + S) + ACTION=start + # Begin where the initramfs left off and use 2/3 + # of the remaining space + first_step=$PROGRESS_STATE + progress_size=$(($progress_size * 2)) + step_change=1 + ;; + *) + ACTION=start + # Begin where rcS left off and use the final 1/3 of + # the space (by leaving progress_size unchanged) + first_step=$(($progress_size * 2 + $PROGRESS_STATE)) + step_change=1 + ;; + esac + + # Count the number of scripts we need to run + # (for progress bars) + num_steps=0 + for s in /etc/rc$runlevel.d/[SK]*; do + case "${s##/etc/rc$runlevel.d/S??}" in + gdm|xdm|kdm|ltsp-client|ltsp-client-core|reboot|halt) + break + ;; + esac + num_steps=$(($num_steps + 1)) + done + step=0 + + # First, run the KILL scripts. + if [ "$previous" != N ] + then + # Run all scripts with the same level in parallel + CURLEVEL="" + for s in /etc/rc$runlevel.d/K* + do + # Extract order value from symlink + level=${s#/etc/rc$runlevel.d/K} + level=${level%%[a-zA-Z]*} + if [ "$level" = "$CURLEVEL" ] + then + continue + fi + CURLEVEL=$level + SCRIPTS="" + for i in /etc/rc$runlevel.d/K$level* + do + # Check if the script is there. + [ ! -f $i ] && continue + + # + # Find stop script in previous runlevel but + # no start script there. + # + suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9]} + previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix + previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix + # + # If there is a stop script in the previous level + # and _no_ start script there, we don't + # have to re-stop the service. + # + [ -f $previous_stop ] && [ ! -f $previous_start ] && continue + + # Stop the service. + SCRIPTS="$SCRIPTS $i" + done + startup stop $SCRIPTS + done + fi + + # Now run the START scripts for this runlevel. + # Run all scripts with the same level in parallel + CURLEVEL="" + for s in /etc/rc$runlevel.d/S* + do + # Extract order value from symlink + level=${s#/etc/rc$runlevel.d/S} + level=${level%%[a-zA-Z]*} + if [ "$level" = "$CURLEVEL" ] + then + continue + fi + CURLEVEL=$level + SCRIPTS="" + for i in /etc/rc$runlevel.d/S$level* + do + [ ! -f $i ] && continue + + if [ "$previous" != N ] + then + # + # Find start script in previous runlevel and + # stop script in this runlevel. + # + suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]} + stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix + previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix + # + # If there is a start script in the previous level + # and _no_ stop script in this level, we don't + # have to re-start the service. + # + if [ start = "$ACTION" ] ; then + [ -f $previous_start ] && [ ! -f $stop ] && continue + else + # Workaround for the special + # handling of runlevels 0 and 6. + previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix + # + # If there is a stop script in the previous level + # and _no_ start script there, we don't + # have to re-stop the service. + # + [ -f $previous_stop ] && [ ! -f $previous_start ] && continue + fi + + fi + SCRIPTS="$SCRIPTS $i" + done + startup $ACTION $SCRIPTS + done +fi + +if [ S = "$runlevel" ] +then + # + # For compatibility, run the files in /etc/rc.boot too. + # + [ -d /etc/rc.boot ] && run-parts /etc/rc.boot +fi + +trap - EXIT # Disable emergency handler + +exit 0 + diff --git a/generic/etc/init.d/rcS b/generic/etc/init.d/rcS index 3a8df90..ea09f53 100755 --- a/generic/etc/init.d/rcS +++ b/generic/etc/init.d/rcS @@ -23,6 +23,12 @@ echo "done." 1> $OUT # set hostname test -e /etc/hostname && hostname -F /etc/hostname -echo "running rc.d services..." 1> $OUT -run-parts -a start /etc/rc.d 1> $OUT +echo "running rcS.d services..." 1> $OUT +if [ -e /etc/default/rcS ]; then + exec /etc/init.d/rc S 1> $OUT + # FIXME: Move early init stuff to rc?.d directories + # FIXME: runlevel doesn't work yet, reports unknown +else + run-parts -a start /etc/rc.d 1> $OUT +fi diff --git a/generic/etc/init.d/reboot b/generic/etc/init.d/reboot new file mode 100755 index 0000000..c942325 --- /dev/null +++ b/generic/etc/init.d/reboot @@ -0,0 +1,39 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: reboot +# Required-Start: +# Required-Stop: +# Default-Start: +# Default-Stop: 6 +# Short-Description: Execute the reboot command. +# Description: +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +#. /lib/lsb/init-functions + +do_stop () { + # Message should end with a newline since kFreeBSD may + # print more stuff (see #323749) + #log_action_msg "Will now restart" + logger -p 0 "Will now restart" + reboot -f -i +} + +case "$1" in + start) + # No-op + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + do_stop + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac diff --git a/patches/upstart-0.3.9/generic/series b/patches/upstart-0.3.9/generic/series new file mode 100644 index 0000000..ef3bc7b --- /dev/null +++ b/patches/upstart-0.3.9/generic/series @@ -0,0 +1 @@ +upstart-cross-fixes.diff diff --git a/patches/upstart-0.3.9/generic/upstart-cross-fixes.diff b/patches/upstart-0.3.9/generic/upstart-cross-fixes.diff new file mode 100644 index 0000000..454e7bf --- /dev/null +++ b/patches/upstart-0.3.9/generic/upstart-cross-fixes.diff @@ -0,0 +1,11 @@ +git --diff a/ +--- upstart-0.3.9.orig/upstart/wire.c 2007-10-11 22:50:58.000000000 +0200 ++++ upstart-0.3.9/upstart/wire.c 2008-12-29 09:35:29.000000000 +0100 +@@ -28,6 +28,7 @@ + + #include <stdarg.h> + #include <string.h> ++#include <limits.h> + + #include <nih/macros.h> + #include <nih/alloc.h> diff --git a/rules/upstart.in b/rules/upstart.in new file mode 100644 index 0000000..5cb0823 --- /dev/null +++ b/rules/upstart.in @@ -0,0 +1,80 @@ +## SECTION=shell_and_console +menuconfig UPSTART + tristate + prompt "upstart" + select DBUS + help + Upstart is an event-based replacement for the /sbin/init daemon which handles + starting of tasks and services during boot, stopping them during shutdown + and supervising them while the system is running. + + It was originally developed for the Ubuntu distribution, but is intended to be + suitable for deployment in all Linux distributions as a replacement for the venerable System-V init. + +if UPSTART + +if PTXCONF_BUSYBOX_INIT + comment "BusyBox' init is selected" +endif + +config UPSTART_COMPAT + bool + prompt "install compatibilty sysv utils" + help + Install the init program, this init support runlevel + + +if UPSTART_COMPAT + +if PTXCONF_BUSYBOX_HALT + comment "BusyBox' halt is selected" +endif + +#config UPSTART_RUNLEVEL +# bool +# prompt "runlevel" +# help +# This tool is used to switch to another runlevel. + +if PTXCONF_BUSYBOX_RUNLEVEL + comment "BusyBox' runlevel is selected" +endif + +#config UPSTART_SULOGIN +# bool +# prompt "sulogin" +# help +# Single-user login + +#config UPSTART_WALL +# bool +# prompt "wall" +# help +# wall - write a message to users + +#config UPSTART_LAST +# bool +# prompt "last" +# help +# last - show listing of last logged in users + +#config UPSTART_MESG +# bool +# prompt "mesg" +# help +# mesg - control write access to your terminal + +#if PTXCONF_BUSYBOX_MESG +# comment "busybox mesg is selected" +#endif + +endif + +config UPSTART_LOGD + bool + prompt "logd" + help + logd runs in the background and copies all strings sent to + the /dev/console device to a logfile. + +endif diff --git a/rules/upstart.make b/rules/upstart.make new file mode 100644 index 0000000..ab34a7f --- /dev/null +++ b/rules/upstart.make @@ -0,0 +1,234 @@ +# -*-makefile-*- +# $Id$ +# +# Copyright (C) 2008 by Carsten Schlote <[email protected]> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# We provide this package +# +PACKAGES-$(PTXCONF_UPSTART) += upstart + +# +# Paths and names +# +UPSTART_VERSION := 0.3.9 +UPSTART := upstart-$(UPSTART_VERSION) +UPSTART_SUFFIX := tar.bz2 +UPSTART_URL := http://upstart.ubuntu.com/download/0.3/$(UPSTART).$(UPSTART_SUFFIX) +UPSTART_SOURCE := $(SRCDIR)/$(UPSTART).$(UPSTART_SUFFIX) +UPSTART_DIR := $(BUILDDIR)/$(UPSTART) + +# ---------------------------------------------------------------------------- +# Get +# ---------------------------------------------------------------------------- + +$(UPSTART_SOURCE): + @$(call targetinfo) + @$(call get, UPSTART) + +# ---------------------------------------------------------------------------- +# Extract +# ---------------------------------------------------------------------------- + +$(STATEDIR)/upstart.extract: + @$(call targetinfo) + @$(call clean, $(UPSTART_DIR)) + @$(call extract, UPSTART) + @$(call patchin, UPSTART) + @$(call touch) + +# ---------------------------------------------------------------------------- +# Prepare +# ---------------------------------------------------------------------------- + +UPSTART_PATH := PATH=$(CROSS_PATH) +UPSTART_ENV := $(CROSS_ENV) + +# +# autoconf +# +UPSTART_AUTOCONF := $(CROSS_AUTOCONF_ROOT) + +ifdef PTXCONF_UPSTART_COMPAT +UPSTART_AUTOCONF += --enable-compat +endif + +$(STATEDIR)/upstart.prepare: + @$(call targetinfo) + @$(call clean, $(UPSTART_DIR)/config.cache) + cd $(UPSTART_DIR) && \ + $(UPSTART_PATH) $(UPSTART_ENV) \ + ./configure $(UPSTART_AUTOCONF) + @$(call touch) + +# ---------------------------------------------------------------------------- +# Compile +# ---------------------------------------------------------------------------- + +$(STATEDIR)/upstart.compile: + @$(call targetinfo) + cd $(UPSTART_DIR) && $(UPSTART_PATH) $(MAKE) $(PARALLELMFLAGS) + @$(call touch) + +# ---------------------------------------------------------------------------- +# Install +# ---------------------------------------------------------------------------- + +$(STATEDIR)/upstart.install: + @$(call targetinfo) + @$(call install, UPSTART) + @$(call touch) + +# ---------------------------------------------------------------------------- +# Target-Install +# ---------------------------------------------------------------------------- + +$(STATEDIR)/upstart.targetinstall: + @$(call targetinfo) + + @$(call install_init, upstart) + @$(call install_fixup, upstart,PACKAGE,upstart) + @$(call install_fixup, upstart,PRIORITY,optional) + @$(call install_fixup, upstart,VERSION,$(UPSTART_VERSION)) + @$(call install_fixup, upstart,SECTION,base) + @$(call install_fixup, upstart,AUTHOR,"Carsten Schlote <[email protected]>") + @$(call install_fixup, upstart,DEPENDS,) + @$(call install_fixup, upstart,DESCRIPTION,missing) + + #-- Shared libraries ----------------------------------------------------- + @$(call install_copy, upstart, 0, 0, 0754, $(UPSTART_DIR)/nih/.libs/libnih.so.0.0.0, /lib/libnih.so.0.0.0, n) + @$(call install_link, upstart, libnih.so.0.0.0, /lib/libnih.so.0) + @$(call install_link, upstart, libnih.so.0.0.0, /lib/libnih.so) + + @$(call install_copy, upstart, 0, 0, 0754, $(UPSTART_DIR)/upstart/.libs/libupstart.so.0.0.0, /lib/libupstart.so.0.0.0, n) + @$(call install_link, upstart, libupstart.so.0.0.0, /lib/libupstart.so.0) + @$(call install_link, upstart, libupstart.so.0.0.0, /lib/libupstart.so) + + #-- Basic upstart tools -------------------------------------------------- + @$(call install_copy, upstart, 0, 0, 0755, $(UPSTART_DIR)/init/init, /sbin/init) + + @$(call install_copy, upstart, 0, 0, 0754, $(UPSTART_DIR)/util/initctl, /sbin/initctl, n) + @$(call install_link, upstart, initctl, /sbin/start) + @$(call install_link, upstart, initctl, /sbin/status) + @$(call install_link, upstart, initctl, /sbin/stop) + + #-- Compat tools ---------------------------------------------------------- +ifdef PTXCONF_UPSTART_COMPAT + @$(call install_copy, upstart, 0, 0, 0754, $(UPSTART_DIR)/compat/sysv/reboot, /sbin/reboot, n) + @$(call install_link, upstart, reboot, /sbin/halt) + @$(call install_link, upstart, reboot, /sbin/poweroff) + @$(call install_link, upstart, reboot, /sbin/halt) + @$(call install_copy, upstart, 0, 0, 0754, $(UPSTART_DIR)/compat/sysv/runlevel, /sbin/runlevel, n) + @$(call install_copy, upstart, 0, 0, 0754, $(UPSTART_DIR)/compat/sysv/shutdown, /sbin/shutdown, n) + @$(call install_copy, upstart, 0, 0, 0754, $(UPSTART_DIR)/compat/sysv/telinit, /sbin/telinit, n) +endif + + + #-- Default configs taken from ubuntu ----------------------------------------------- + #-- FIXME - Should be scanned in loop - remove tty stuff below first + @$(call install_copy, upstart, 0, 0, 0755, /etc/event.d) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/control-alt-delete, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/rc0, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/rc1, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/rc2, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/rc3, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/rc4, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/rc5, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/rc6, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/rc-default, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/rcS, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/rcS-sulogin, n) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/sulogin, n) + + #-- FIXME - Should be in projectroot and copied in a loop.... + #...@$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/tty1, n) + #...@$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/tty2, n) + #...@$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/tty3, n) + #...@$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/tty4, n) + #...@$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/tty5, n) + #...@$(call install_alternative, upstart, 0, 0, 0754, /etc/event.d/tty6, n) + +ifdef PTXCONF_UPSTART_COMPAT + @$(call install_copy, upstart, 0, 0, 0755, /etc/default) + @$(call install_alternative, upstart, 0, 0, 0754, /etc/default/rcS, n) + + @$(call install_copy, upstart, 0, 0, 0755, /etc/init.d) + @$(call install_copy, upstart, 0, 0, 0754, $(PTXDIST_TOPDIR)/generic/etc/init.d/rc, /etc/init.d/rc, n); + @$(call install_copy, upstart, 0, 0, 0754, $(PTXDIST_TOPDIR)/generic/etc/init.d/reboot, /etc/init.d/reboot, n); + @$(call install_copy, upstart, 0, 0, 0754, $(PTXDIST_TOPDIR)/generic/etc/init.d/halt, /etc/init.d/halt, n); + + @$(call install_copy, upstart, 0, 0, 0755, /etc/rc.d) + @$(call install_link, upstart, rc.d, /etc/rcS.d) + + @$(call install_copy, upstart, 0, 0, 0754, /etc/rc0.d) + @$(call install_link, upstart, ../init.d/halt, /etc/rc0.d/S90_halt) + @$(call install_copy, upstart, 0, 0, 0754, /etc/rc1.d) + @$(call install_copy, upstart, 0, 0, 0754, /etc/rc2.d) + @$(call install_link, upstart, rc2.d, /etc/rc3.d) + @$(call install_link, upstart, rc2.d, /etc/rc4.d) + @$(call install_copy, upstart, 0, 0, 0754, /etc/rc5.d) + @$(call install_copy, upstart, 0, 0, 0754, /etc/rc6.d) + @$(call install_link, upstart, ../init.d/reboot, /etc/rc6.d/S90_reboot) + +endif + + #-- Logging deamon -------------------------------------------------------- +ifdef PTXCONF_UPSTART_LOGD + @$(call install_copy, upstart, 0, 0, 0755, $(UPSTART_DIR)/logd/logd, /sbin/logd, n) + @$(call install_copy, upstart, 0, 0, 0755, $(UPSTART_DIR)/logd/event.d/logd, /etc/event.d/logd, n) +endif + + +#ifdef PTXCONF_UPSTART_RUNLEVEL +# @$(call install_copy, upstart, 0, 0, 0755, $(UPSTART_DIR)/util/runlevel, /sbin/runlevel) +#endif +# ifdef PTXCONF_UPSTART_KILLALL5 +# @$(call install_copy, upstart, 0, 0, 0755, $(UPSTART_DIR)/src/killall5, /sbin/killall5) +# endif +# ifdef PTXCONF_UPSTART_SULOGIN +# @$(call install_copy, upstart, 0, 0, 0755, $(UPSTART_DIR)/src/sulogin, /sbin/sulogin) +# endif +# ifdef PTXCONF_UPSTART_WALL +# @$(call install_copy, upstart, 0, 0, 0755, $(UPSTART_DIR)/src/wall, /usr/bin/wall) +# endif +# ifdef PTXCONF_UPSTART_LAST +# @$(call install_copy, upstart, 0, 0, 0755, $(UPSTART_DIR)/src/last, /usr/bin/last) +# endif +# ifdef PTXCONF_UPSTART_MESG +# @$(call install_copy, upstart, 0, 0, 0755, $(UPSTART_DIR)/src/mesg, /usr/bin/mesg) +# endif +#ifdef PTXCONF_UPSTART_BSDINIT +# @$(call clean, $(BSDINIT_DIR)) +# @$(call get, BSDINIT) +# @$(call extract, BSDINIT) +# @$(call install_copy, upstart, 0, 0, 0644, $(BSDINIT_DIR)/inittab, /etc/inittab, n) +# @$(call install_copy, upstart, 0, 0, 0755, /etc/rc.d) +# @$(call install_copy, upstart, 0, 0, 0754, $(BSDINIT_DIR)/rc.0, /etc/rc.d/rc.0, n) +# @$(call install_copy, upstart, 0, 0, 0754, $(BSDINIT_DIR)/rc.1, /etc/rc.d/rc.1, n) +# @$(call install_copy, upstart, 0, 0, 0754, $(BSDINIT_DIR)/rc.2, /etc/rc.d/rc.2, n) +# @$(call install_copy, upstart, 0, 0, 0754, $(BSDINIT_DIR)/rc.5, /etc/rc.d/rc.5, n) +# @$(call install_copy, upstart, 0, 0, 0754, $(BSDINIT_DIR)/rc.sysinit, /etc/rc.d/rc.sysinit, n) +# @$(call install_link, upstart, rc.2, /etc/rc.d/rc.3) +# @$(call install_link, upstart, rc.2, /etc/rc.d/rc.4) +# @$(call install_link, upstart, rc.0, /etc/rc.d/rc.6) +#endif + @$(call install_finish, upstart) + + @$(call touch) + +# ---------------------------------------------------------------------------- +# Clean +# ---------------------------------------------------------------------------- + +upstart_clean: + rm -rf $(STATEDIR)/upstart.* + rm -rf $(PKGDIR)/upstart_* + rm -rf $(UPSTART_DIR) + +# vim: syntax=make
-- ptxdist mailing list [email protected]
