4 # Symlink target for initscripts that have been converted to Upstart.
8 INITSCRIPT
="$(basename "$0")"
9 JOB
="${INITSCRIPT%.sh}"
11 if [ "$JOB" = "upstart-job" ]; then
13 echo "Usage: upstart-job JOB COMMAND" 1>&2
22 echo "Usage: $0 COMMAND" 1>&2
31 if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
37 $ECHO "Rather than invoking init scripts through /etc/init.d, use the service(8)"
38 $ECHO "utility, e.g. service $INITSCRIPT $COMMAND"
40 # Only check if jobs are disabled if the currently _running_ version of
41 # Upstart (which may be older than the latest _installed_ version)
42 # supports such a query.
44 # This check is necessary to handle the scenario when upgrading from a
45 # release without the 'show-config' command (introduced in
46 # Upstart for Ubuntu version 0.9.7) since without this check, all
47 # installed packages with associated Upstart jobs would be considered
50 # Once Upstart can maintain state on re-exec, this change can be
51 # dropped (since the currently running version of Upstart will always
52 # match the latest installed version).
54 UPSTART_VERSION_RUNNING
=$
(initctl version|
awk '{print $3}'|
tr -d ')')
56 if dpkg
--compare-versions "$UPSTART_VERSION_RUNNING" ge
0.9.7
58 initctl show-config
-e "$JOB"|
grep -q '^ start on' || DISABLED
=1
64 $ECHO "Since the script you are attempting to invoke has been converted to an"
65 $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
70 $ECHO "Since the script you are attempting to invoke has been converted to an"
71 $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
72 if status
"$JOB" 2>/dev
/null |
grep -q ' start/'; then
75 if [ -z "$RUNNING" ] && [ "$COMMAND" = "stop" ]; then
77 elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
79 elif [ -n "$DISABLED" ] && [ "$COMMAND" = "start" ]; then
86 $ECHO "Since the script you are attempting to invoke has been converted to an"
87 $ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities,"
88 $ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available."
89 if status
"$JOB" 2>/dev
/null |
grep -q ' start/'; then
92 if [ -n "$RUNNING" ] ; then
95 # If the job is disabled and is not currently running, the job is
96 # not restarted. However, if the job is disabled but has been forced into the
97 # running state, we *do* stop and restart it since this is expected behaviour
98 # for the admin who forced the start.
99 if [ -n "$DISABLED" ] && [ -z "$RUNNING" ]; then
106 $ECHO "Since the script you are attempting to invoke has been converted to an"
107 $ECHO "Upstart job, you may also use the reload(8) utility, e.g. reload $JOB"
112 $ECHO "The script you are attempting to invoke has been converted to an Upstart" 1>&2
113 $ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2