[Lunar-commits] <moonbase> upstart: an event based init replacement.
Florin Braescu
florin at lunar-linux.org
Sun Jul 6 15:34:20 CEST 2008
commit 1f384beee5c4ada81564bd7bef9db668c5a5dcc4
Author: Florin Braescu <florin at lunar-linux.org>
Date: Sun Mar 23 11:50:30 2008 +0200
upstart: an event based init replacement.
---
zlocal/upstart/BUILD | 15 +++++++++++++++
zlocal/upstart/DETAILS | 26 ++++++++++++++++++++++++++
zlocal/upstart/event.d/control-alt-delete | 8 ++++++++
zlocal/upstart/event.d/hostname | 24 ++++++++++++++++++++++++
zlocal/upstart/event.d/rc-default | 26 ++++++++++++++++++++++++++
zlocal/upstart/event.d/rc0 | 25 +++++++++++++++++++++++++
zlocal/upstart/event.d/rc1 | 20 ++++++++++++++++++++
zlocal/upstart/event.d/rc2 | 20 ++++++++++++++++++++
zlocal/upstart/event.d/rc3 | 20 ++++++++++++++++++++
zlocal/upstart/event.d/rc4 | 20 ++++++++++++++++++++
zlocal/upstart/event.d/rc5 | 20 ++++++++++++++++++++
zlocal/upstart/event.d/rc6 | 23 +++++++++++++++++++++++
zlocal/upstart/event.d/rcS | 20 ++++++++++++++++++++
zlocal/upstart/event.d/rcS-sulogin | 24 ++++++++++++++++++++++++
zlocal/upstart/event.d/sulogin | 20 ++++++++++++++++++++
zlocal/upstart/event.d/tty1 | 16 ++++++++++++++++
zlocal/upstart/event.d/tty2 | 16 ++++++++++++++++
zlocal/upstart/event.d/tty3 | 16 ++++++++++++++++
zlocal/upstart/event.d/tty4 | 16 ++++++++++++++++
zlocal/upstart/event.d/tty5 | 16 ++++++++++++++++
zlocal/upstart/event.d/tty6 | 16 ++++++++++++++++
21 files changed, 407 insertions(+), 0 deletions(-)
diff --git a/zlocal/upstart/BUILD b/zlocal/upstart/BUILD
new file mode 100644
index 0000000..e8e2635
--- /dev/null
+++ b/zlocal/upstart/BUILD
@@ -0,0 +1,15 @@
+(
+ ./configure --build=$BUILD \
+ --prefix=/usr \
+ --sbindir=/sbin \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --infodir=/usr/share/info \
+ --mandir=/usr/share/man \
+ $OPTS &&
+
+ default_make &&
+
+ cp -f $SCRIPT_DIRECTORY/event.d/* /etc/event.d/
+
+) > $C_FIFO 2>&1
diff --git a/zlocal/upstart/DETAILS b/zlocal/upstart/DETAILS
new file mode 100644
index 0000000..78e515e
--- /dev/null
+++ b/zlocal/upstart/DETAILS
@@ -0,0 +1,26 @@
+ MODULE=upstart
+ VERSION=0.3.9
+ SOURCE=$MODULE-${VERSION}.tar.bz2
+ SOURCE_URL=http://upstart.ubuntu.com/download/0.3/
+ SOURCE_VFY=sha1:1e105296e8bdd269ac211bec46f03d423a13d68f
+ WEB_SITE=http://upstart.ubuntu.com
+ ENTERED=20080106
+ UPDATED=20080106
+ SHORT="An event-based replacement for the /sbin/init daemon"
+
+cat << EOF
+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 is intended to be suitable for deployment in all Linux
+distributions as a replacement for the venerable sysvinit package.
+Feature highlights:
+ * tasks and Services are started and stopped by events;
+ * events are generated as tasks and services are run and stopped;
+ * events may also be generated at timed intervals, or when files are
+ changed (not yet implemented);
+ * events may be received from any other process on the system;
+ * services may be respawned if they die unexpectedly
+ * bi-directional communication with init daemon to discover which
+ jobs are running, why jobs failed, etc.
+EOF
diff --git a/zlocal/upstart/event.d/control-alt-delete b/zlocal/upstart/event.d/control-alt-delete
new file mode 100644
index 0000000..35cb130
--- /dev/null
+++ b/zlocal/upstart/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/zlocal/upstart/event.d/hostname b/zlocal/upstart/event.d/hostname
new file mode 100644
index 0000000..913e866
--- /dev/null
+++ b/zlocal/upstart/event.d/hostname
@@ -0,0 +1,24 @@
+description "Set the hostname"
+author "Scott James Remnant"
+
+start on startup
+
+console output
+script
+ if [ -f /etc/hostname ]; then
+ HOSTNAME="$(cat /etc/hostname)"
+ fi
+
+ # Keep current name if /etc/hostname is missing.
+ if [ -z "$HOSTNAME" ]; then
+ HOSTNAME="$(hostname)"
+ fi
+
+ # And set it to 'localhost' if no setting was found
+ if [ -z "$HOSTNAME" ]; then
+ HOSTNAME=localhost
+ fi
+
+ echo "Setting hostname to '$HOSTNAME'"
+ hostname "$HOSTNAME"
+end script
diff --git a/zlocal/upstart/event.d/rc-default b/zlocal/upstart/event.d/rc-default
new file mode 100644
index 0000000..133e997
--- /dev/null
+++ b/zlocal/upstart/event.d/rc-default
@@ -0,0 +1,26 @@
+# 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
+
+ /etc/init.d/bootmisc
+
+end script
diff --git a/zlocal/upstart/event.d/rc0 b/zlocal/upstart/event.d/rc0
new file mode 100644
index 0000000..d534826
--- /dev/null
+++ b/zlocal/upstart/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/zlocal/upstart/event.d/rc1 b/zlocal/upstart/event.d/rc1
new file mode 100644
index 0000000..8629369
--- /dev/null
+++ b/zlocal/upstart/event.d/rc1
@@ -0,0 +1,20 @@
+# rc1 - runlevel 1 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 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/zlocal/upstart/event.d/rc2 b/zlocal/upstart/event.d/rc2
new file mode 100644
index 0000000..b30ad7a
--- /dev/null
+++ b/zlocal/upstart/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/zlocal/upstart/event.d/rc3 b/zlocal/upstart/event.d/rc3
new file mode 100644
index 0000000..d9a22b9
--- /dev/null
+++ b/zlocal/upstart/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/zlocal/upstart/event.d/rc4 b/zlocal/upstart/event.d/rc4
new file mode 100644
index 0000000..f4eca3c
--- /dev/null
+++ b/zlocal/upstart/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/zlocal/upstart/event.d/rc5 b/zlocal/upstart/event.d/rc5
new file mode 100644
index 0000000..0544730
--- /dev/null
+++ b/zlocal/upstart/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/zlocal/upstart/event.d/rc6 b/zlocal/upstart/event.d/rc6
new file mode 100644
index 0000000..e3bfdaa
--- /dev/null
+++ b/zlocal/upstart/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/zlocal/upstart/event.d/rcS b/zlocal/upstart/event.d/rcS
new file mode 100644
index 0000000..406c247
--- /dev/null
+++ b/zlocal/upstart/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/zlocal/upstart/event.d/rcS-sulogin b/zlocal/upstart/event.d/rcS-sulogin
new file mode 100644
index 0000000..5807779
--- /dev/null
+++ b/zlocal/upstart/event.d/rcS-sulogin
@@ -0,0 +1,24 @@
+# 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
+ /sbin/sulogin
+
+ 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/zlocal/upstart/event.d/sulogin b/zlocal/upstart/event.d/sulogin
new file mode 100644
index 0000000..144ea27
--- /dev/null
+++ b/zlocal/upstart/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/zlocal/upstart/event.d/tty1 b/zlocal/upstart/event.d/tty1
new file mode 100644
index 0000000..e9700d6
--- /dev/null
+++ b/zlocal/upstart/event.d/tty1
@@ -0,0 +1,16 @@
+# tty1 - agetty
+#
+# This service maintains an agetty on tty1 from the point the system is
+# started until it is shut down again.
+
+start on runlevel 2
+start on runlevel 3
+start on runlevel 4
+start on runlevel 5
+
+stop on runlevel 0
+stop on runlevel 1
+stop on runlevel 6
+
+respawn
+exec /sbin/agetty 38400 tty1
diff --git a/zlocal/upstart/event.d/tty2 b/zlocal/upstart/event.d/tty2
new file mode 100644
index 0000000..bc54d70
--- /dev/null
+++ b/zlocal/upstart/event.d/tty2
@@ -0,0 +1,16 @@
+# tty2 - agetty
+#
+# This service maintains an agetty 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/agetty 38400 tty2
diff --git a/zlocal/upstart/event.d/tty3 b/zlocal/upstart/event.d/tty3
new file mode 100644
index 0000000..e676fb8
--- /dev/null
+++ b/zlocal/upstart/event.d/tty3
@@ -0,0 +1,16 @@
+# tty3 - agetty
+#
+# This service maintains an agetty 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/agetty 38400 tty3
diff --git a/zlocal/upstart/event.d/tty4 b/zlocal/upstart/event.d/tty4
new file mode 100644
index 0000000..9b0ec98
--- /dev/null
+++ b/zlocal/upstart/event.d/tty4
@@ -0,0 +1,16 @@
+# tty4 - agetty
+#
+# This service maintains an agetty 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/agetty 38400 tty4
diff --git a/zlocal/upstart/event.d/tty5 b/zlocal/upstart/event.d/tty5
new file mode 100644
index 0000000..079665c
--- /dev/null
+++ b/zlocal/upstart/event.d/tty5
@@ -0,0 +1,16 @@
+# tty5 - agetty
+#
+# This service maintains an agetty 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/agetty 38400 tty5
diff --git a/zlocal/upstart/event.d/tty6 b/zlocal/upstart/event.d/tty6
new file mode 100644
index 0000000..4ff4972
--- /dev/null
+++ b/zlocal/upstart/event.d/tty6
@@ -0,0 +1,16 @@
+# tty6 - agetty
+#
+# This service maintains an agetty 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/agetty 38400 tty6
More information about the Lunar-commits
mailing list