From: Stefan Schantl Date: Sun, 26 Jul 2009 20:14:25 +0000 (+0200) Subject: Added new package: upstart. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=784845d36e8415b096f9b6feab66bf08dd482373;p=ipfire-3.x.git Added new package: upstart. --- diff --git a/lfs/upstart b/lfs/upstart new file mode 100644 index 000000000..43f79afa4 --- /dev/null +++ b/lfs/upstart @@ -0,0 +1,98 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +PKG_NAME = upstart +PKG_VER = 0.6.2 +PKG_REL = 0 + +THISAPP = $(PKG_NAME)-$(PKG_VER) +DL_FILE = $(THISAPP).tar.bz2 +DIR_APP = $(DIR_SRC)/$(THISAPP) + +OBJECT = $(DIR_INFO)/$(STAGE_ORDER)_$(STAGE)/$(THISAPP) + +MAINTAINER = +GROUP = System/Base +CORE = yes +EXTRA = no +DEBUG = no +DEPS = +BUILD_DEPS = gettext dbus + +LICENSE = GPLv2+ +URL = http://upstart.ubuntu.com/ +SHORT_DESC = An event-driven init system. + +define LONG_DESC + 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. +endef + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +download: $(objects) + +info: + $(DO_PKG_INFO) + +install: $(OBJECT) + +packages: $(PACKAGES) + +$(PACKAGES): $(OBJECT) + @$(DO_PACKAGE) + +$(objects): + @$(LOAD) + +############################################################################### +# Installation Details +############################################################################### + +$(OBJECT): $(objects) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && $(EXTRACTOR) $(DIR_DL)/$(DL_FILE) + + cd $(DIR_APP) && ./configure \ + --prefix=/usr \ + --sbindir=/sbin \ + --sysconfdir=/etc \ + --libdir=/lib + + cd $(DIR_APP) && make $(PARALLELISMFLAGS) CFLAGS="$(CFLAGS)" + cd $(DIR_APP) && make install + + # Install Upstart events + cp -vaf $(DIR_SRC)/src/$(PKG_NAME)/* /etc/init/ + + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/src/rootfiles/core/upstart b/src/rootfiles/core/upstart new file mode 100644 index 000000000..b821f3d13 --- /dev/null +++ b/src/rootfiles/core/upstart @@ -0,0 +1,58 @@ +etc/dbus-1/system.d/Upstart.conf +etc/init +etc/init/control-alt-delete.conf +etc/init/mount-kernel-filesystems.conf +etc/init/sulogin.conf +#etc/init/load-modules.conf +#etc/init/swap.conf +etc/init/sysctl.conf +etc/init/udev.conf +etc/init/udevtrigger.conf +etc/init/checkfs.conf +#etc/init/mountfs.conf +etc/init/tty1.conf +etc/init/tty2.conf +etc/init/tty3.conf +etc/init/tty4.conf +etc/init/tty5.conf +etc/init/tty6.conf +etc/init/welcome.conf +sbin/halt +sbin/init +sbin/initctl +sbin/poweroff +sbin/reboot +sbin/restart +sbin/runlevel +sbin/shutdown +sbin/start +sbin/status +sbin/stop +sbin/telinit +#usr/share/locale/en@boldquot/LC_MESSAGES/upstart.mo +#usr/share/locale/en@quot/LC_MESSAGES/upstart.mo +#usr/share/man/man1/nih-dbus-tool.1 +#usr/share/man/man5/init.5 +#usr/share/man/man5/inittab.5 +#usr/share/man/man7/control-alt-delete.7 +#usr/share/man/man7/keyboard-request.7 +#usr/share/man/man7/power-status-changed.7 +#usr/share/man/man7/runlevel.7 +#usr/share/man/man7/started.7 +#usr/share/man/man7/starting.7 +#usr/share/man/man7/startup.7 +#usr/share/man/man7/stopped.7 +#usr/share/man/man7/stopping.7 +#usr/share/man/man7/upstart.7 +#usr/share/man/man8/halt.8 +#usr/share/man/man8/init.8 +#usr/share/man/man8/initctl.8 +#usr/share/man/man8/poweroff.8 +#usr/share/man/man8/reboot.8 +#usr/share/man/man8/restart.8 +#usr/share/man/man8/runlevel.8 +#usr/share/man/man8/shutdown.8 +#usr/share/man/man8/start.8 +#usr/share/man/man8/status.8 +#usr/share/man/man8/stop.8 +#usr/share/man/man8/telinit.8 diff --git a/src/upstart/checkfs.conf b/src/upstart/checkfs.conf new file mode 100644 index 000000000..bb550a873 --- /dev/null +++ b/src/upstart/checkfs.conf @@ -0,0 +1,88 @@ +description "Set sysctls from /etc/sysctl.conf" +author "IPFire Team" + +start on started udevtrigger + +console output + +script + . /lib/lsb/init-functions + + if [ -f /fastboot ]; then + echo "${INFO}/fastboot found!" + log_success_msg "Will not perform file system checks as requested." + exit 0 + fi + + mount -n -o remount,ro / >/dev/null + if [ ${?} != 0 ] + then + log_failure_msg "Mounting root file system in read-only mode" + echo -e "${FAILURE}FAILURE:\n" + echo -e -n "${FAILURE}Cannot check root filesystem because it " + echo -e "${FAILURE}could not be mounted" + echo -e "${FAILURE}in read-only mode.\n\n" + echo -e -n "${FAILURE}After you press Enter, this system will be " + echo -e "${FAILURE}halted and powered off.\n" + echo -e "${INFO}Press enter to continue...${NORMAL}" + read ENTER + /sbin/shutdown + fi + + if [ -f /forcefsck ] + then + echo "${INFO}/forcefsck found!" + log_success_msg "${INFO}Forcing file system checks as requested." + options="-f" + else + options="" + fi + + # Note: -a option used to be -p; but this fails e.g. + # on fsck.minix + fsck ${options} -a -A -C -T + error_value=${?} + + if [ "${error_value}" = 0 ] + then + log_success_msg "Checking file systems..." + elif [ "${error_value}" = 1 ] + then + log_warning_msg "Checking file systems..." + echo -e "${WARNING}WARNING:\n" + echo -e "${WARNING}File system errors were found and have been" + echo -e "${WARNING}corrected. You may want to double-check that" + echo -e "${WARNING}everything was fixed properly.${NORMAL}" + elif [ "${error_value}" = 2 -o "${error_value}" = 3 ]; then + log_warning_msg "Checking file systems..." + echo -e "${WARNING}WARNING:\n" + echo -e "${WARNING}File system errors were found and have been been" + echo -e "${WARNING}corrected, but the nature of the errors require" + echo -e "${WARNING}this system to be rebooted.\n" + echo -e "After you press enter, this system will be rebooted.\n" + echo -e "${INFO}Press Enter to continue...${NORMAL}" + read ENTER + reboot -f + elif [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then + log_failure_msg "Checking file systems..." + echo -e "${FAILURE}FAILURE:\n" + echo -e "${FAILURE}File system errors were encountered that could" + echo -e "${FAILURE}not be fixed automatically. This system cannot" + echo -e "${FAILURE}continue to boot and will therefore be halted" + echo -e "${FAILURE}until those errors are fixed manually by a" + echo -e "${FAILURE}System Administrator.\n" + echo -e "${FAILURE}After you press Enter, this system will be" + echo -e "${FAILURE}halted and powered off.\n" + echo -e "${INFO}Press Enter to continue...${NORMAL}" + read ENTER + /sbin/shutdown + elif [ "${error_value}" -ge 16 ]; then + log_failure_msg "Checking file systems..." + echo -e "${FAILURE}FAILURE:\n" + echo -e "${FAILURE}Unexpected Failure running fsck. Exited with error" + echo -e "${FAILURE}code: ${error_value}.${NORMAL}" + exit ${error_value} + fi + +end script + diff --git a/src/upstart/load-modules.conf b/src/upstart/load-modules.conf new file mode 100644 index 000000000..afbfd95a5 --- /dev/null +++ b/src/upstart/load-modules.conf @@ -0,0 +1,77 @@ +description "Load modules from /etc/modules" +author "Scott James Remnant" + +start on started sysctl + +console output + +script + . /lib/lsb/init-functions + + # Exit if there's no modules file or there are no + # valid entries + [ -r /etc/sysconfig/modules ] && \ + egrep -qv '^($|#)' /etc/sysconfig/modules || \ + exit 0 + + # If proc is mounted, find the current kernel + # message level + if [ -f /proc/sys/kernel/printk ]; then + prev_msg=`cat /proc/sys/kernel/printk | \ + sed 'l 1' | sed -n '2~0p' | \ + sed 's/\\\//'` + else + prev_msg="6" + fi + + # Now set the message level to 1 so not to make too + # much noise when loading modules + dmesg -n 1 + + # Only try to load modules if the user has actually given us + # some modules to load. + if egrep -qv '^(#|$)' /etc/sysconfig/modules 2>/dev/null + then + + # Read in the configuration file. + exec 9>&0 < /etc/sysconfig/modules + + message="${INFO}Loading modules:" + + while read module args; do + + # Ignore comments and blank lines. + case "${module}" in + ""|\#*) continue ;; + esac + + # Attempt to load the module, making + # sure to pass any arguments provided. + modprobe ${module} ${args} > /dev/null + + # Print the module name if successful, + # otherwise take note. + if [ ${?} -eq 0 ]; then + message="${message}${NORMAL} ${module}" + else + failedmod="${failedmod} ${module}" + fi + done + + # Print a message about successfully loaded + # modules on the correct line. + log_success_msg "${message}" + + # Print a failure message with a list of any + # modules that may have failed to load. + if [ "${failedmod}" ]; then + log_failure_msg "${FAILURE}Failed to load modules:${failedmod}" + fi + + exec 0>&9 9>&- + + fi + # Set the kernel message level back to it's previous value. + dmesg -n "${prev_msg}" + +end script diff --git a/src/upstart/loopback.conf b/src/upstart/loopback.conf new file mode 100644 index 000000000..f3c2696e4 --- /dev/null +++ b/src/upstart/loopback.conf @@ -0,0 +1,16 @@ +description "Bring up the loopback (127.0.0.1) network interface" +author "Scott James Remnant" + +start on stopped sysctl ok + +console output + +pre-start script + if [ ! -d /var/run/network ]; then + mkdir -m 0755 /var/run/network + fi +end script + +exec /sbin/ip addr add 127.0.0.1/8 label lo dev lo +exec /sbin/ip link set lo up + diff --git a/src/upstart/mount-kernel-filesystems.conf b/src/upstart/mount-kernel-filesystems.conf new file mode 100644 index 000000000..08e801ed0 --- /dev/null +++ b/src/upstart/mount-kernel-filesystems.conf @@ -0,0 +1,19 @@ +description "Mount kernel virtual filesystems" +author "Alex Smith" + +start on stopped welcome + +console output + +script + echo "Mounting kernel file systems..." + # Mount /proc and /sys + mountpoint -q /proc || mount -n -t proc -o nodev,noexec,nosuid proc /proc + # If the user requested to be quiet, then we should not display warnings + grep -q quiet /proc/cmdline && echo "0" > /proc/sys/kernel/printk + mountpoint -q /sys || mount -n -t sysfs -o nodev,noexec,nosuid sysfs /sys +end script + +post-start script + echo "mount sysproc DONE" +end script diff --git a/src/upstart/mountfs.conf b/src/upstart/mountfs.conf new file mode 100644 index 000000000..a2bfa6713 --- /dev/null +++ b/src/upstart/mountfs.conf @@ -0,0 +1,33 @@ +description "Set sysctls from /etc/sysctl.conf" +author "Scott James Remnant" + +start on started checkfs + +console output + +script + . /lib/lsb/init-functions + + message="Remounting root file system in read-write mode..." + mount -n -o remount,rw / >/dev/null + evaluate_retval standard + + # Remove fsck-related file system watermarks. + rm -f /fastboot /forcefsck + + message="Recording existing mounts in /etc/mtab..." + > /etc/mtab + mount -f / || failed=1 + mount -f /proc || failed=1 + mount -f /sys || failed=1 + (exit ${failed}) + evaluate_retval standard + + # This will mount all filesystems that do not have _netdev in + # their option list. _netdev denotes a network filesystem. + message="Mounting remaining file systems..." + mount -a -O no_netdev >/dev/null + evaluate_retval standard + +end script + diff --git a/src/upstart/sulogin.conf b/src/upstart/sulogin.conf new file mode 100644 index 000000000..931fb0624 --- /dev/null +++ b/src/upstart/sulogin.conf @@ -0,0 +1,18 @@ +# 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. + +#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/src/upstart/swap.conf b/src/upstart/swap.conf new file mode 100644 index 000000000..01fc5e53f --- /dev/null +++ b/src/upstart/swap.conf @@ -0,0 +1,12 @@ +description "Set sysctls from /etc/sysctl.conf" +author "Scott James Remnant" + +start on started udevtrigger + +console output + +pre-start script + echo "Activating all swap files/partitions..." +end script + +exec /sbin/swapon -a diff --git a/src/upstart/sysctl.conf b/src/upstart/sysctl.conf new file mode 100644 index 000000000..71ea6e55d --- /dev/null +++ b/src/upstart/sysctl.conf @@ -0,0 +1,12 @@ +description "Set sysctls from /etc/sysctl.conf" +author "Scott James Remnant" + +start on stopped mount-kernel-filesystems + +console output + +script + echo "Starting sysctl...." + /sbin/sysctl -q -p + echo "sysctl DONE" +end script diff --git a/src/upstart/tty1.conf b/src/upstart/tty1.conf new file mode 100644 index 000000000..35744dc0f --- /dev/null +++ b/src/upstart/tty1.conf @@ -0,0 +1,11 @@ +# tty1 - getty +# +# This service maintains a getty on tty1 from the point the system is +# started until it is shut down again. + +start on started udevtrigger +stop on shutdown + + +respawn +exec /sbin/agetty 9600 tty1 diff --git a/src/upstart/tty2.conf b/src/upstart/tty2.conf new file mode 100644 index 000000000..2cd0c9b04 --- /dev/null +++ b/src/upstart/tty2.conf @@ -0,0 +1,11 @@ +# tty2 - getty +# +# This service maintains a getty on tty2 from the point the system is +# started until it is shut down again. + +start on started udevtrigger +stop on shutdown + + +respawn +exec /sbin/agetty 9600 tty2 diff --git a/src/upstart/tty3.conf b/src/upstart/tty3.conf new file mode 100644 index 000000000..57ced1f8b --- /dev/null +++ b/src/upstart/tty3.conf @@ -0,0 +1,11 @@ +# tty3 - getty +# +# This service maintains a getty on tty3 from the point the system is +# started until it is shut down again. + +start on started udevtrigger +stop on shutdown + + +respawn +exec /sbin/agetty 9600 tty3 diff --git a/src/upstart/tty4.conf b/src/upstart/tty4.conf new file mode 100644 index 000000000..ad59f50f4 --- /dev/null +++ b/src/upstart/tty4.conf @@ -0,0 +1,10 @@ +# tty4 - getty +# +# This service maintains a getty on tty4 from the point the system is +# started until it is shut down again. + +start on started udevtrigger +stop on shutdown + +respawn +exec /sbin/agetty 9600 tty4 diff --git a/src/upstart/tty5.conf b/src/upstart/tty5.conf new file mode 100644 index 000000000..1378112fa --- /dev/null +++ b/src/upstart/tty5.conf @@ -0,0 +1,10 @@ +# tty5 - getty +# +# This service maintains a getty on tty5 from the point the system is +# started until it is shut down again. + +start on started udevtrigger +stop on shutdown + +respawn +exec /sbin/agetty 9600 tty5 diff --git a/src/upstart/tty6.conf b/src/upstart/tty6.conf new file mode 100644 index 000000000..6de2828f4 --- /dev/null +++ b/src/upstart/tty6.conf @@ -0,0 +1,14 @@ +# tty6 - getty +# +# This service maintains a getty on tty6 from the point the system is +# started until it is shut down again. + +start on started udevtrigger +stop on shutdown + +pre-start script + echo " TTY6 starting...." +end script + +respawn +exec /sbin/agetty 9600 tty6 diff --git a/src/upstart/udev.conf b/src/upstart/udev.conf new file mode 100644 index 000000000..5ce7c2dda --- /dev/null +++ b/src/upstart/udev.conf @@ -0,0 +1,20 @@ +description "Kernel event manager" +author "Scott James Remnant" + +start on started sysctl + +emits block-device-added block-device-removed +emits network-device-added network-device-removed + +console output + +pre-start script + + #mount -n -t tmpfs tmpfs /dev -o mode=755 + echo > /proc/sys/kernel/hotplug + cp -a /lib/udev/devices/* /dev + +script + +exec /sbin/udevd +respawn diff --git a/src/upstart/udevtrigger.conf b/src/upstart/udevtrigger.conf new file mode 100644 index 000000000..ff71c3d62 --- /dev/null +++ b/src/upstart/udevtrigger.conf @@ -0,0 +1,16 @@ +description "Set sysctls from /etc/sysctl.conf" +author "Scott James Remnant" + +start on started udev + +console output + +script + echo "Starting udev trigger..." + # Now traverse /sys in order to "coldplug" devices that have + # already been discovered + /sbin/udevadm trigger + + # Now wait for udevd to process the uevents we triggered + /sbin/udevadm settle --timeout=5 || true +end script diff --git a/src/upstart/welcome.conf b/src/upstart/welcome.conf new file mode 100644 index 000000000..8235a58ae --- /dev/null +++ b/src/upstart/welcome.conf @@ -0,0 +1,10 @@ +description "Set sysctls from /etc/sysctl.conf" +author "Scott James Remnant" + +start on startup + +console output + +script + echo "Welcome to IPFire $(cat /etc/system-release)" +end script