#
#
-SUBDIRS = src lib ppp isapnp sysconfig rc.d doc man po init
+SUBDIRS = src lib ppp isapnp sysconfig rc.d doc man po
sysconf_DATA = \
adjtime \
- maybe merge ATM rc scripts
We are waiting for suggestions.
-
-upstart:
-+upstart_controlled --except reload
-+
-+# return true if service is considered "up"
-+# with upstart, upstart is consulted
-+# otherwise lockfile in subsys must exist
-+is_service_up() {
-+ use_upstart && is_upstart_running "$1" || [ -f /var/lock/subsys/"$1" ]
-+}
-+
-
-from nscd.init
-
sysconfig/interfaces/down.d/tnl/Makefile \
rc.d/Makefile rc.d/init.d/Makefile \
po/Makefile \
- init/Makefile \
])
AC_OUTPUT
template.init \
net-scripts.txt \
sysconfig.txt \
- sysvinitfiles \
- upstart.txt
+ sysvinitfiles
EXTRA_DIST = $(doc_DATA) $(noinst_DATA)
jade -t sgml -d polski.dsl rc-scripts.docb
#jade -t sgml -d polski.dsl test-ogonki.docb
-rst2html upstart.txt upstart.html
+++ /dev/null
-===================================
-Upstart event-based service startup
-===================================
-
-This version of rc-scripts support Upstart event-based service startup. This
-can co-exist with old-style startup scripts.
-
-Enabling/disabling event-base service startup
----------------------------------------------
-
-Upstart event-based service startup may be disabled on boot time
-by using a ``pld.no-upstart`` kernel command-line option.
-
-An init script may be called with ``USE_UPSTART=no`` environment variable
-to disable special upstart-related processing – this way one may use
-``/etc/rc.d/init.d/$service start`` to start a service even if upstart job
-for that service is present. The ``/sbin/service`` script has two new options
-``--upstart`` and ``--no-upstart`` to force new- or old-style service control.
-
-``USE_UPSTART=no`` can also be places in ``/etc/sysconfig/system``
-configuration file, though it can break ``*-upstart`` packages
-installation/removal a bit.
-
-Available events
-----------------
-
-Ubuntu-compatible system events
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-all-swaps
- when swaps from ``/etc/fstab`` are activated
-
-filesystem
- when basic filesystem hierarchy (FHS) is mounted
- NOTE: currently it doesn't wait for network filesystems!
-
-local-filesystems
- when all local filesystems are mounted and initialized
-
-root-filesystem
- when root filesystem is mounted r/w and initialized
-
-virtual-filesystems
- when virtual filesystems (/proc, /sys, etc.) are mounted
-
-PLD-specific system events:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-pld.sysinit-done
- when rc.sysinit finished its job
-
-pld.shutdown-started
-starting shutdown
-started shutdown
- when rc.shutdown starts
-
-pld.network-starting
-starting network
- just before network initialization is started
-
-pld.network-started
-started network
- when network is initialized
-
-pld.network-stopping
-stopping network
- just before network shutdown is started
-
-pld.network-stopped
-stopped network
- when network configuration is shut down
-
-Jobs
-~~~~
-
-The standard Upstart events are available for job control:
-starting(7) started(7) stopping(7) stopped(7) (see man pages)
-
-As relying on job name is not good enough when several alternative
-implementations of a service are available. In such case
-each of the alternative jobs should have an extra 'SERVICE_syslog=y'
-variable exported. In van then be used like this::
-
- start on started SERVICE_syslog=y
-
-Please note that using 'SERVICE=something' will not work, as the value
-will be inherited by any other job with 'export SERVICE'.
-
-Job events and enabling/disabling event-base service startup
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Please note that relying on events not raised by PLD service jobs
-or scripts (like 'startup') will make job ignore the 'pld.no-upstart'
-setting.
-
-
-Writing Upstart job descriptions
---------------------------------
-
-Job description files in ``/etc/init`` are not only the recipes to start
-a service, but also configuration files for that service. Keep that in mind
-when writing the ``*.conf`` files. No complicated logic, that can change from
-a release to a release, should be implemented there, the script should be
-readable, basic configuration settings easy to find and no upstart-controlled
-settings (like resource limit) reimplemented in the script or started daemon
-arguments.
-
-The syntax of the ``/etc/init/*.conf`` files is described in the init(5) man
-page.
-
-Instead of using ``/etc/sysconfig/$service`` files put the service
-configuration directly into the ``*.conf`` file. When 'env' stanza is used for
-that, the value may be overridden when starting the job with initctl.
-
-Simple example, the job description for syslog-ng::
-
- start on pld.network-started
- stop on pld.shutdown-started
-
- env SERVICE=syslog
- export SERVICE
-
- respawn
-
- console output
-
- exec /usr/sbin/syslog-ng -F -f /etc/syslog-ng/syslog-ng.conf
-
-Checking upstart configuration
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Since Upstart 1.3 one can check current configuration with::
-
- initctl check-config
-
-Also, with an 'initctl2dot' tool the configuration may be visualised in
-a graphical diagram.
-
-Tracking startup progress
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The easiest way to run a program from an upstart job is to ``exec`` it
-the way it will stay in foreground (that is what is the ``-F`` option in the
-example above for). However, when process is started this way Upstart cannot
-differentiate before the ``program starting failed`` and ``program has
-terminated`` cases. It will also assumed the job has started as soon as the
-command has been executed and that may be not what other jobs wait for.
-
-A 'proper daemon' first checks command line arguments and configuration, then
-forks two times and returns with success only when the child process is ready.
-Upstart can handle such daemons with ``expect daemon`` stanza. So, to manage
-such daemon via Upstart, exec so it daemonize and use ``expect daemon``
-directive to tell Upstart what happens. Unfortunately, when ``expect daemon``
-is used and the process forks only once or does some more weird thing, Upstart
-job may lock up. Also, libdaemon-based daemons don't play well with ``expect
-daemon``.
-
-When the service forks once ``expect fork`` should be used instead.
-
-There is also an ``expect stop`` option, probably the most elegant way to
-track process startup. The process doesn't have to fork in this case and
-Upstart doesn't have to track that forking. The process should raise SIGSTOP
-when it is ready – only then Upstart will emit the job's ``started`` event and
-let the process continue. Unfortunately, currently hardly anything supports
-this interface.
-
-When no ``expect`` stanza will help and we need to properly wait for process
-startup, then ``post-start`` script must be used. See the init(5) man page for
-details.
-
-Debuging jobs
-~~~~~~~~~~~~~
-
-Making sure job description is correct and Upstart will properly manage the
-process may be tricky. One way to check if the job was described and started
-properly is to use ``pstree -p`` command and compare it to ``initctl status``
-output. Example::
-
- # initctl status cherokee
- cherokee start/running, process 22419
-
- # pstree -p
- init(1)─┬─Terminal(19446)─┬─bash(8983)───console(9003)
- ....
- |-bacula-sd(3514)---{bacula-sd}(3520)
- |-cherokee(22419)-+-cherokee-worker(22423)-+-rrdtool(22425)
- | | |-{cherokee-worker}(22424)
- | | |-{cherokee-worker}(22426)
- | | |-{cherokee-worker}(22427)
- | | |-{cherokee-worker}(22428)
- | | |-{cherokee-worker}(22429)
- | | |-{cherokee-worker}(22430)
- | | |-{cherokee-worker}(22431)
- | | |-{cherokee-worker}(22432)
- | | |-{cherokee-worker}(22433)
- | | `-{cherokee-worker}(22434)
- | `-{cherokee}(22422)
- |-conserver(3471)---conserver(3477)
- ....
-
-
-As you can see, Upstart thinks the main process of 'cherokee' is '22419',
-and indeed this is the only 'cherokee' child of init. So this state is correct.
-
-Common problem that may appear in pstree output:
-
- 1. The main process pid differs from what Upstart thinks. That usually
- happens when bad 'expect fork' or 'expect daemon' is used. May cause
- Upstart lock-up when the PID reported by ``initctl status`` does not exist
- at all.
-
- 2. Init has multiple children processes for one job instance. It may happen
- when previously running job was not properly killed, when bad 'expect' was
- used or when the daemon does weird forking on startup.
-
-See also http://upstart.ubuntu.com/wiki/Debugging
-
-Updating init scripts
----------------------
-
-Parts of the system will still expect ``service $name`` or even, directly,
-``/etc/rc.d/init.d/$name`` scripts working. Also, LSB expects compatible
-init scripts in /etc/init.d. For this still to work, an upstart-controlled
-service is expected to have its ``/etc/rc.d/init.d/$name`` script also present.
-It must also be named exactly as the main upstart job for the service.
-
-The script must be a bit modified (in comparison to the traditional init
-scripts) to make use of the upstart features.
-
-For the start/stop/status/reload commands to work the script should include a
-``upstart_controlled`` command placed before commands are handled (and after
-``/etc/rc.d/init.d/function`` was included). This command (shell alias actually)
-will be ignored when upstart boot control is disabled or no upstart job is
-available for the service. Otherwise it will implement the basic LSB commands
-and exit.
-
-Sometimes some commands must be implemented in a special way (not all services
-may understand SIGHUP as a signal to reload their configuration) or extra
-commands are provided (like 'configtest'). In such case ``upstart_controlled``
-should be given a list of commands to implement or, preferrably, ``--except``
-and the list of commands which stay implemented in the script. If the first
-argument of the script is one to be of the 'not upstart_controlled' commands,
-processing will continue past 'upstart_controlled' call and the commands may
-be handled by the init script.
-
-When ``configtest`` is includes in the ``upstart_controlled --except`` list
-then ``$script configtest`` will be called before each restart/reload attempt,
-but only when done by ``/sbin/service`` or call to the script. Direct initctl
-calls are not affected.
-
-The minimal init script, for a service which will be controlled by upstart
-only would be::
-
- #!/bin/sh
-
- . /etc/rc.d/init.d/functions
-
- upstart_controlled
-
- echo "Service available only via upstart boot"
- exit 3
-
-Minimal change to an existing PLD script to handle upstart control is to add::
-
- upstart_controlled
-
-before the usual::
-
- RETVAL=0
- # See how we were called.
- case "$1" in
- start)
-
-Sometimes other upstart jobs will rely on a service started by the traditional
-init script. In such case, the script should emit appropriate events.
-
-e.g.::
-
- msg_starting "syslog-ng"
- emit starting JOB=syslog-ng SERVICE=syslog
- daemon /usr/sbin/syslog-ng -f /etc/syslog-ng/syslog-ng.conf $OPTIONS
- emit started JOB=syslog-ng SERVICE=syslog
- RETVAL=$?
-
-The ``emit`` function does nothing when upstart-controlled boot is disabled (not
-to trigger any upstart jobs), otherwise it calls ``/sbin/initctl emit``
-
-..
- vi: tw=78 ft=rst spl=en
+++ /dev/null
-@SET_MAKE@
-
-initdir = @initdir@
-
-init_DATA = random.conf rc.conf rcS-sulogin.conf rcS.conf udev.conf \
- allowlogin.conf sys-chroots.conf cpusets.conf cryptsetup.conf local.conf \
- modules.conf
-
-EXTRA_DIST = $(init_DATA)
+++ /dev/null
-description "Allow users to login"
-
-start on pld.sysinit-done
-stop on pld.shutdown-started
-
-console output
-
-pre-start script
- [ -f /etc/sysconfig/system ] && . /etc/sysconfig/system
-
- # exit early without loading big init.d functions
- case "$DELAY_LOGIN" in
- yes|Yes|YES|true|True|TRUE|on|On|ON|Y|y|1)
- ;;
- *)
- /sbin/initctl -q stop
- ;;
- esac
-end script
-
-script
- # Source function library.
- . /etc/rc.d/init.d/functions
-
- if is_yes "$DELAY_LOGIN" && [ -f /etc/nologin.boot ]; then
- run_cmd "Allowing users to login" rm -f /etc/nologin /etc/nologin.boot
- fi
- end script
-
-pre-stop script
- # Source function library.
- . /etc/rc.d/init.d/functions
-
- # /etc/nologin when shutting down system
- if is_yes "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
- nls "System shutdown in progress\n" > /etc/nologin
- chmod 644 /etc/nologin
- cp -fp /etc/nologin /etc/nologin.boot
- fi
-end script
+++ /dev/null
-description "Creates/Removes all cpu sets configured to start at boot time."
-
-start on pld.sysinit-done
-stop on pld.shutdown-started
-
-console output
-task
-
-pre-start script
- # test that cpusets are configured
- . /etc/sysconfig/system
- if [ "${CPUSETS:-no}" = "no" ]; then
- /sbin/initctl -q stop
- fi
-end script
-
-script
- export USE_UPSTART=no
- exec /etc/rc.d/init.d/cpusets start
-end script
-
-pre-stop script
- export USE_UPSTART=no
- exec /etc/rc.d/init.d/cpusets stop
-end script
+++ /dev/null
-description "Disk encryption via cryptsetup"
-
-start on pld.sysinit-done
-stop on pld.shutdown-started
-
-task
-
-script
- . /etc/rc.d/init.d/cryptsetup
- init_crypto
-end script
+++ /dev/null
-description "This script will be executed *after* all the other SysV style init scripts."
-
-# start when runlevel is reached (except 0 and 6)
-start on stopped rc RUNLEVEL=[!06]
-
-console output
-task
-
-pre-start script
- test -f /etc/rc.d/rc.local
-end script
-
-script
- . /etc/rc.d/rc.local
-end script
+++ /dev/null
-# module-init-tools - load modules from /etc/modules
-#
-# This task loads the kernel modules specified in the /etc/modules file
-
-description "load modules from /etc/modules"
-
-start on (startup
- and started udev)
-
-task
-
-script
- {
- read _x _y v _z
- old_IFS=$IFS
- # strip _* or -* from versions like: "2.6.25_vanilla-1", "2.6.25-1"
- IFS='_-'
- set -- $v
- v1=${1}
- IFS='.'
- set -- $v1
- IFS=$old_IFS
-
- kernel="$1.$2"
- kerneleq="$1.$2.$3"
- } < /proc/version
-
- # Loop over every line in modules file
- ( \
- grep -hvE '^(#|[[:blank:]]*$)' /etc/modules /etc/modules.$kernel /etc/modules.$kerneleq 2>/dev/null
- echo '' # make sure there is a LF at the end
- ) | while read module args; do
- [ -z "$module" ] && continue
- # strip comments
- args=${args%%#*}
- modprobe -s $module -- $args
- done
-end script
+++ /dev/null
-description "Save random entropy on shutdown and restore it at boot time"
-
-start on pld.sysinit-done
-stop on pld.shutdown-started
-
-env SEED_FILE=/var/run/random-seed
-
-pre-start script
- poolfile=/proc/sys/kernel/random/poolsize
- [ -r $poolfile ] && bytes="$(cat $poolfile)" || bytes=512
- if [ -f $SEED_FILE ]; then
- cat $SEED_FILE >/dev/urandom
- else
- touch $SEED_FILE
- fi
- chmod 600 $SEED_FILE
- dd if=/dev/urandom of=$SEED_FILE count=1 bs=$bytes 2>/dev/null
-end script
-
-post-stop script
- poolfile=/proc/sys/kernel/random/poolsize
- [ -r $poolfile ] && bytes="$(cat $poolfile)" || bytes=512
- touch $SEED_FILE
- chmod 600 $SEED_FILE
- dd if=/dev/urandom of=$SEED_FILE count=1 bs=$bytes 2>/dev/null
-end script
+++ /dev/null
-description "rc - System V runlevel compatibility\
- \
- This task runs the old sysv-rc runlevel scripts. It \
- is usually started by the telinit compatibility wrapper."
-
-start on runlevel [0123456]
-stop on runlevel [!$RUNLEVEL]
-
-emits shutdown
-emits network
-
-# rc.sysinit
-emits pld.sysinit-done
-
-# rc.shutdown
-emits pld.shutdown-started
-
-# /etc/rc.d/init.d/network
-emits pld.network-starting
-emits pld.network-started
-emits pld.network-stopping
-emits pld.network-stopped
-
-task
-
-export RUNLEVEL
-console output
-exec /etc/rc.d/rc $RUNLEVEL
+++ /dev/null
-description "rcS-sulogin - 'single-user' runlevel compatibility \
-\
-This task runs /bin/sh during 'single-user' mode, \
-then continues to the default runlevel."
-
-start on runlevel S
-stop on runlevel [!S]
-
-emits runlevel
-
-console owner
-script
- . /etc/rc.d/init.d/functions
- if ! is_no "$RUN_SULOGIN_ON_ERR"; then
- exec /sbin/sulogin
- else
- exec /bin/sh
- fi
-end script
-
-post-stop script
- if [ "$RUNLEVEL" = "S" ]; then
- runlevel=$(/bin/awk -F ':' '$3 == "initdefault" && $1 !~ "^#" { print $2 }' /etc/inittab)
- [ -z "$runlevel" ] && runlevel="3"
- exec telinit $runlevel
- fi
-end script
+++ /dev/null
-description "rcS - runlevel compatibility \
-\
-This task runs the old sysv-rc startup scripts."
-
-start on startup
-
-stop on runlevel
-
-emits all-swaps filesystem local-filesystems root-filesystem virtual-filesystems runlevel
-emits pld.sysinit-done
-
-task
-
-# Note: there can be no previous runlevel here, if we have one it's bad
-# information (we enter rc1 not rcS for maintenance). Run /etc/rc.d/rc
-# without information so that it defaults to previous=N runlevel=S.
-console output
-exec /etc/rc.d/rc.sysinit
-
-post-stop script
- if [ "$UPSTART_EVENTS" = "startup" ]; then
- runlevel=$(/bin/awk -F ':' '$3 == "initdefault" && $1 !~ "^#" { print $2 }' /etc/inittab)
- [ -z "$runlevel" ] && runlevel="3"
- for t in $(cat /proc/cmdline); do
- case $t in
- -s|single|S|s) runlevel="S" ;;
- [1-9]) runlevel="$t" ;;
- esac
- done
- exec telinit $runlevel
- fi
-end script
+++ /dev/null
-description "Starts and stops services in chroots"
-
-start on runlevel [0123456] and pld.sysinit-done
-stop on runlevel [!$RUNLEVEL]
-
-console output
-task
-
-pre-start script
- # test that chroots are configured
- . /etc/sysconfig/system
- test -n "$SYSTEM_CHROOTS" || /sbin/initctl -q stop
-end script
-
-script
- export USE_UPSTART=no
- exec /etc/rc.d/init.d/sys-chroots start
-end script
-
-pre-stop script
- export USE_UPSTART=no
- exec /etc/rc.d/init.d/sys-chroots stop
-end script
+++ /dev/null
-description "dummy job"
-
-# Dummy job so, the 'udev' dependecies are satisfied although udev is not
-# started by upstart"
-
-# vi: ft=upstart
CHARS="" # Characters displayed on the beginning of show line
CCHARS="$NORMAL" # Color of these characters (look at /etc/sysconfig/init-colors.gentoo example)
-# save from env, set by /sbin/service
-env_upstart=$USE_UPSTART
-
# Source configuration if available - may override default values
[ -r /etc/sysconfig/init-colors ] && . /etc/sysconfig/init-colors
[ -r /etc/sysconfig/system ] && . /etc/sysconfig/system
unset RC_FEDORA || :
fi
-[ "$env_upstart" ] && USE_UPSTART=$env_upstart
-
if [ -z "$VSERVER" -o "$VSERVER" = "detect" ]; then
{
while read _f _ctx; do
}
use_upstart () {
- # True when upstart-event-based boot should be used
- is_yes "$USE_UPSTART" && return 0
- is_no "$USE_UPSTART" && return 1
- if [ ! -x /sbin/initctl ] ; then
- USE_UPSTART="no"
- return 1
- fi
- local cmdline=$(cat /proc/cmdline 2>/dev/null)
- if strstr "$cmdline" "pld.no-upstart" ; then
- USE_UPSTART="no"
- return 1
- else
- USE_UPSTART="yes"
- return 0
- fi
+ return 1
}
-
emit () {
- # emit upstart signal
- # only when 'upstart' boot is enabled
- use_upstart || return 0
- /sbin/initctl emit "$@"
+ return 0
}
-
is_upstart_task() {
- # Return 0 if the given service is an upstart task.
- grep -q '^task' "/etc/init/$1.conf"
+ return 1
}
is_upstart_running() {
- # Return 0 if the given service is running via upstart
- initctl status "$1" 2>/dev/null | grep -q running
+ return 1
}
upstart_start() {
- local service=$1
- if is_upstart_running "${service}"; then
- msg_already_running "$service"
- return 0
- fi
-
- msg_starting "${service}"
- if errors=$(/sbin/initctl start ${service} 2>&1) ; then
- ok
- return 0
- else
- fail
- echo "$errors" >&2
- return 1
- fi
+ return 1
}
upstart_stop() {
- local service=$1
- if ! is_upstart_running "${service}"; then
- msg_not_running "$name"
- return 0
- fi
- msg_stopping "${service}"
- if errors=$(/sbin/initctl stop ${service}) ; then
- ok
- return 0
- else
- fail
- echo "$errors" >&2
- return 1
- fi
+ return 1
}
upstart_reload() {
- local service=$1
- if ! is_upstart_running "${service}" && ! is_upstart_task "${service}" ; then
- return 0
- fi
- msg_reloading "${service}"
- if errors=$(/sbin/initctl reload ${service}) ; then
- ok
- return 0
- else
- fail
- echo "$errors" >&2
- return 1
- fi
+ return 0
}
upstart_status() {
- # get service status
- # should be compliant with
- # http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
- local service=$1
- local status
- if is_upstart_task "${service}" ; then
- # we probably should have a way to handle task status
- return 0
- fi
- if ! status=$(/sbin/initctl status "${service}") ; then
- # program or service status is not known
- return 4
- fi
- if strstr "$status" "running" ; then
- # program is running or service is OK
- echo "$status"
- return 0
- else
- # program is not running
- echo "$status"
- return 3
- fi
- # TODO: other statuses
+ return 1
}
-
_upstart_controlled() {
- # If the service is to be handled by upstart
- # execute the start/stop/etc. commands the upstart way
- if ! use_upstart; then
- return 0
- fi
- local script=$1
- shift
- local command=$1
- [ $# -gt 0 ] && shift
- local name=$(basename "$script")
- if [ ! -f /etc/init/${name}.conf ] ; then
- return 0
- fi
- local commands
- local extra_commands
- local has_configtest
- if [ "$1" = "--except" ] ; then
- shift
- commands="$*"
- for cmd in $commands ; do
- if [ "$command" = "$cmd" ] ; then
- return 0
- fi
- case "$cmd" in
- start|stop|status|reload|restart|try-restart|force-reload)
- ;;
- configtest)
- has_configtest=yes
- extra_commands="|$cmd"
- ;;
- *)
- extra_commands="|$cmd"
- ;;
- esac
- done
- elif [ -n "$*" ] ; then
- commands="$*"
- local cmd
- local found=0
- # is there a better way
- for cmd in $commands ; do
- if [ "$command" = "$cmd" ] ; then
- found=1
- break;
- fi
- done
- if [ $found = 0 ] ; then
- # let the script handle it
- return 0
- fi
- fi
- case "$command" in
- start)
- upstart_start $name
- exit $?
- ;;
- stop)
- upstart_stop $name
- exit $?
- ;;
- status)
- upstart_status $name
- exit $?
- ;;
- restart)
- if is_yes "$has_configtest" ; then
- "$script" configtest || exit 1
- fi
- upstart_stop $name
- upstart_start $name
- exit $?
- ;;
- try-restart)
- if ! is_upstart_running "$name" ; then
- exit 0
- fi
- if is_yes "$has_configtest" ; then
- "$script" configtest || exit 1
- fi
- upstart_stop $name
- upstart_start $name
- exit $?
- ;;
- reload)
- if is_yes "$has_configtest" ; then
- "$script" configtest || exit 1
- fi
- if is_upstart_task "$name" ; then
- nls "$command not implemented for $name"
- exit 3
- else
- upstart_reload "$name"
- exit $?
- fi
- ;;
- force-reload)
- if is_yes "$has_configtest" ; then
- "$script" configtest || exit 1
- fi
- if is_upstart_task "$name" ; then
- upstart_stop "$name"
- upstart_start "$name"
- exit $?
- else
- upstart_reload "$name"
- exit $?
- fi
- ;;
- *)
- msg_usage "$0 {start|stop|restart|reload|force-reload|status$extra_commands}"
- exit 3
- ;;
- esac
- return 1 # should not happen
+ return 0
}
-
-# Usage:
-# somewhere at the begining of init script:
-# upstart_controlled
-# - to pass implement all upstart commands via initctl
-# start, stop, status, restart, reload and force_reload
-# are implemented
-# upstart_controlled command...
-# - to pass handle only specific commands the upstart way
-# and leave the rest to the script
-#
alias upstart_controlled='_upstart_controlled $0 "$@"'
rc_gettext_init
ip addr add 127.0.0.1/8 dev lo
fi
ip link set dev lo up
- emit net-device-up IFACE=lo
grep -E "^(lo|any)[[:blank:]]" /etc/sysconfig/static-routes | while read device args; do
if [[ "$args" = *:* ]]; then
if ! LC_ALL=C ip link show dev $device 2>/dev/null | grep -Fq UP; then
ip link set dev $device up >/dev/null 2>&1
- emit net-device-up IFACE=$device
fi
timeout=0
while [ $timeout -le $max_timeout ]; do
# Source function library.
. /etc/rc.d/init.d/functions
-upstart_controlled
-
start() {
if is_yes "$DELAY_LOGIN" && [ -f /etc/nologin.boot ]; then
run_cmd "Allowing users to login" rm -f /etc/nologin /etc/nologin.boot
# Source function library.
. /etc/rc.d/init.d/functions
-upstart_controlled
-
# See how we were called.
case "$1" in
start)
}
start() {
- emit pld.network-starting
- emit starting JOB=network
-
rc_splash "bootnetwork start"
network_init
network_postinit
touch /var/lock/subsys/network
- emit --no-wait pld.network-started
- emit --no-wait started JOB=network
}
stop() {
- emit pld.network-stopping
- emit stopping JOB=network
# If we go to runlevel 0, 1 or 6 then umount all network fs
if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then
if [ -x /etc/rc.d/init.d/netfs -a -f /var/lock/subsys/netfs ];
network_deinit
rm -f /var/lock/subsys/network >/dev/null 2>&1
- emit --no-wait pld.network-stopped
- emit --no-wait stopped JOB=network
}
# Reload all active interfaces
case "$1" in
start)
if is_yes "$VSERVER_ISOLATION_NET"; then
- emit pld.network-starting
- emit starting JOB=network
touch /var/lock/subsys/network
- emit pld.network-started
- emit --no-wait started JOB=network
else
start
fi
;;
stop)
if is_yes "$VSERVER_ISOLATION_NET"; then
- emit pld.network-stopping
- emit stopping JOB=network
rm -f /var/lock/subsys/network >/dev/null 2>&1
- emit pld.network-stopped
- emit --no-wait stopped JOB=network
else
stop
fi
return
fi
-upstart_controlled start stop
-
random_seed=/var/run/random-seed
poolfile=/proc/sys/kernel/random/poolsize
return
fi
- emit starting JOB=random
show "Initializing random number generator"
busy
# Carry a random seed from start-up to start-up
touch /var/lock/subsys/random
deltext
ok
- emit --nowait started JOB=random
}
stop() {
fi
# Carry a random seed from shut-down to start-up
- emit stopping JOB=random
show "Saving random seed"
busy
touch $random_seed
rm -f /var/lock/subsys/random >/dev/null 2>&1
deltext
ok
- emit --no-wait stopped JOB=random
}
status() {
# Source function library.
. /etc/rc.d/init.d/functions
-upstart_controlled
-
start() {
if [ "$previous" = "N" ]; then
runlevel=5
[ -f /var/lock/subsys/$subsys ] || \
[ -f /var/lock/subsys/${subsys}.init ] && continue
- # Check if it is managed by upstart
- use_upstart && [ -f /etc/init/${subsys}.conf ] && continue
-
# If we're in confirmation mode, get user confirmation
[ -n "$CONFIRM" ] &&
{
trap "echo" INT SEGV QUIT TERM
set +e
-emit pld.shutdown-started
-emit starting JOB=shutdown
-emit started JOB=shutdown
-
rc_splash "reboot"
# Kill all processes.
show "On the next boot fsck will be skipped."; ok
fi
- # not really sure where thse events should go
- emit stopped JOB=shutdown
- emit stopping JOB=shutdown
-
if [ -x /sbin/kexec ] && [ "$kexec_loaded" = "1" ]; then
show "Will now restart with kexec"
/sbin/kexec -e
for arg in $cmdline; do
case "$arg" in
- pld.no-upstart)
- # default is set in /etc/sysconfig/system or detected in init.d/functions
- USE_UPSTART=no
- ;;
noudev)
# default is set in /etc/sysconfig/system
START_UDEV=no
is_fsmounted devtmpfs /dev || mount -n -t devtmpfs devtmpfs /dev
load_kernel_modules modules.preudev
/sbin/start_udev
- use_upstart && [ -x /sbin/initctl ] && /sbin/initctl -q start udev
elif [ -x /lib/firmware/firmware-loader.sh ]; then
/sbin/sysctl -q -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh
fi
mount -f -t selinuxfs selinuxfs /selinux 2> /dev/null
fi
- emit --no-wait root-filesystem
- emit --no-wait virtual-filesystems
-
if [ ! -f /proc/modules ]; then
USEMODULES=
elif [ -z "$nomodules" ]; then
fi
# Load modules
- if ! use_upstart; then
- load_kernel_modules modules
- for f in /etc/modules-load.d/*.conf; do
- # already loaded by implicit "modules" load
- [ "${f##*/}" = "modules.conf" ] && continue
-
- [ -r $f ] || continue
- load_kernel_modules ${f##/etc/}
- done
- fi
+ load_kernel_modules modules
+ for f in /etc/modules-load.d/*.conf; do
+ # already loaded by implicit "modules" load
+ [ "${f##*/}" = "modules.conf" ] && continue
+
+ [ -r $f ] || continue
+ load_kernel_modules ${f##/etc/}
+ done
if ! is_no "$DM_MULTIPATH" && [ -x /sbin/multipath ]; then
modprobe -s dm-mod
run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
fi
- emit --no-wait local-filesystems
-
- # FIXME: this should be delayed until remote filesystems are mounted,
- # especialy when /usr or other standard fs is remote
- emit --no-wait filesystem
-
# Turn on process accounting
if [ -x /etc/rc.d/rc.acct ]; then
/etc/rc.d/rc.acct start
# ... and here finish configuring parameters
apply_sysctl
else
- emit --no-wait root-filesystem
- emit --no-wait virtual-filesystems
- emit --no-wait local-filesystems
- emit --no-wait filesystem
-
# /var/log should be writable now, so start saving the boot output
if [ "$RC_BOOTLOG" ]; then
echo > /var/log/boot.log
if ! is_yes "$VSERVER"; then
enable_swap
- emit --no-wait all-swaps
# If a SCSI tape has been detected, load the st module unconditionally
# since many SCSI tapes don't deal well with st being loaded and unloaded
i=$(($i-1))
done
cp -pf /var/log/dmesg /var/log/dmesg.0
-else
- emit --no-wait all-swaps
fi
if ! is_no "$RC_PROMPT"; then
rm -f /var/run/getkey_done
fi
echo
-
-emit --no-wait pld.sysinit-done
-
}
status_all() {
- local SERVICE TYPE has_systemd has_upstart
+ local SERVICE TYPE has_systemd
if [ "$USE_SYSTEMD" != "no" ] && [ -x /bin/systemd_booted ] && /bin/systemd_booted; then
has_systemd=1
unset has_systemd
fi
- if [ "$USE_UPSTART" != "no" ] && [ -x /sbin/initctl ]; then
- has_upstart=1
- else
- unset has_upstart
- fi
-
cd ${SERVICEDIR}
for SERVICE in *; do
case "${SERVICE}" in
if [ "$has_systemd" ] && [ -f /lib/systemd/system/${SERVICE}.service ]; then
# D for SystemD
TYPE='D'
- elif [ "$has_upstart" ] && [ -f /etc/init/${SERVICE}.conf ]; then
- # U for upstart
- TYPE='U'
else
# S for SysVinit
TYPE='S'
printf " %s %-60s %s\n" "$TYPE:[?]" "$SERVICE:" "unknown"
continue
else
- out=$(env -i USE_UPSTART=$USE_UPSTART LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status 2>&1)
+ out=$(env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status 2>&1)
if [ "$?" = "0" -a -n "$out" ]; then
printf " %s %-60s %s\n" "$TYPE:[+]" "$SERVICE:" "running"
continue
[ service_name [ command | --full-restart ] ]"
SERVICE=
-USE_UPSTART=
USE_SYSTEMD=
if [ -d /etc/rc.d/init.d ]; then
export SYSTEMCTL_SKIP_REDIRECT=1
shift
;;
- --upstart)
- USE_UPSTART=yes
- shift
- ;;
- --no-upstart)
- USE_UPSTART=no
- shift
- ;;
--no-systemd)
USE_SYSTEMD=no
shift
elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
SERVICE="${1}"
if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
- env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" stop
- env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" start
+ env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" stop
+ env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" start
exit $?
fi
elif [ -z "${SERVICE}" ]; then
echo >&2 "Redirecting to /bin/systemctl --output=cat ${ACTION} ${SERVICE}.service ${OPTIONS}"
exec /bin/systemctl --output=cat ${ACTION} ${SERVICE}.service ${OPTIONS}
elif [ -x "${SERVICEDIR}/${SERVICE}" ]; then
- exec env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" ${ACTION} ${OPTIONS}
+ exec env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" ${ACTION} ${OPTIONS}
else
echo "${SERVICE}: unrecognized service" >&2
exit 1