Browse Source

Drop support for upstart

tags/debian/1.49
Michael Biebl Felipe Sateler 4 years ago
parent
commit
eadbdac72f
4 changed files with 12 additions and 159 deletions
  1. +8
    -18
      man8/service.8
  2. +4
    -72
      script/invoke-rc.d
  3. +0
    -23
      script/service
  4. +0
    -46
      script/update-rc.d

+ 8
- 18
man8/service.8 View File

@@ -32,17 +32,16 @@ service \- run a System V init script

.SH DESCRIPTION
.B service
runs a System V init script, systemd unit, or upstart job in as predictable an
runs a System V init script or systemd unit in as predictable an
environment as possible, removing most environment variables and with the
current working directory set to \fB/\fR.

The
.I SCRIPT
parameter specifies a System V init script,
located in \fB/etc/init.d/\fISCRIPT\fR, or the name of a systemd unit, or the
name of an upstart job in \fB/etc/init\fR. The existence of a systemd unit or
upstart job of the same name as a script in /etc/init.d will cause the unit/job
to take precedence over the init.d script.
located in \fB/etc/init.d/\fISCRIPT\fR, or the name of a systemd unit.
The existence of a systemd unit of the same name as a script in /etc/init.d
will cause the unit to take precedence over the init.d script.
The supported values of
.I COMMAND
depend on the invoked script.
@@ -51,11 +50,9 @@ passes
.I COMMAND
and
.I OPTIONS
to the init script unmodified. For systemd units or upstart jobs, start, stop,
to the init script unmodified. For systemd units, start, stop,
status, and reload are passed through to their systemctl/initctl
equivalents. For upstart jobs, restart will call the upstart 'stop' for the
job, followed immediately by the 'start', and will exit with the return code of
the start command.
equivalents.

All scripts should support at least the
.B start
@@ -68,16 +65,14 @@ is \fB\-\-full-restart\fR, the script is run twice, first with the
.B stop
command, then with the
.B start
command. This option has no effect on upstart jobs.
command.

.B service \-\-status\-all
runs all init scripts, in alphabetical order, with the
.B status
command. The status is [ + ] for running services, [ - ] for stopped
services and [ ? ] for services without a 'status' command. This
option only calls status for sysvinit jobs; upstart jobs can be
queried in a similar manner with
\fBinitctl list\fR.
option only calls status for sysvinit jobs.

.SH EXIT CODES
.BR service
@@ -88,9 +83,6 @@ calls the init script and returns the status returned by it.
\fB/etc/init.d\fR
The directory containing System V init scripts.
.TP
\fB/etc/init\fR
The directory containing upstart jobs.
.TP
\fB/{lib,run,etc}/systemd/system\fR
The directories containing systemd units.

@@ -109,5 +101,3 @@ The only environment variables passed to the init scripts.
.BR invoke\-rc.d (8).
.br
.BR systemctl (1).
.br
.BR initctl (8).

+ 4
- 72
script/invoke-rc.d View File

@@ -36,7 +36,6 @@ FORCE=
RETRY=
RETURNFAILURE=
RC=
is_upstart=
is_systemd=
is_openrc=

@@ -266,15 +265,7 @@ fi
#NOTE: It may not be obvious, but "$@" from this point on must expand
#to the extra initscript parameters, except inside functions.

# Operate against system upstart, not session
unset UPSTART_SESSION
# If we're running on upstart and there's an upstart job of this name, do
# the rest with upstart instead of calling the init script.
if which initctl >/dev/null && initctl version 2>/dev/null | grep -q upstart \
&& initctl status ${INITSCRIPTID} 1>/dev/null 2>/dev/null
then
is_upstart=1
elif test -d /run/systemd/system ; then
if test -d /run/systemd/system ; then
is_systemd=1
UNIT="${INITSCRIPTID%.sh}.service"
elif test -f /run/openrc/softlevel ; then
@@ -283,13 +274,6 @@ elif test ! -f "${INITDPREFIX}${INITSCRIPTID}" ; then
## Verifies if the given initscript ID is known
## For sysvinit, this error is critical
printerror unknown initscript, ${INITDPREFIX}${INITSCRIPTID} not found.
# If the init script doesn't exist, but the upstart job does, we
# defer the error exit; we might be running in a chroot and
# policy-rc.d might say not to start the job anyway, in which case
# we don't want to exit non-zero.
if [ ! -e "/etc/init/${INITSCRIPTID}.conf" ]; then
exit 100
fi
fi

## Queries sysvinit for the current runlevel
@@ -422,9 +406,7 @@ fi

# test if /etc/init.d/initscript is actually executable
_executable=
if [ -n "$is_upstart" ]; then
_executable=1
elif [ -n "$is_systemd" ]; then
if [ -n "$is_systemd" ]; then
_executable=1
elif testexec "${INITDPREFIX}${INITSCRIPTID}"; then
_executable=1
@@ -476,22 +458,11 @@ getnextaction () {
ACTION="$@"
}

if [ -n "$is_upstart" ]; then
RUNNING=
DISABLED=
if status "$INITSCRIPTID" 2>/dev/null | grep -q ' start/'; then
RUNNING=1
fi
if ! initctl show-config -e "$INITSCRIPTID" | grep -q '^ start on'; then
DISABLED=1
fi
fi

## Executes initscript
## note that $ACTION is a space-separated list of actions
## to be attempted in order until one suceeds.
if test x${FORCE} != x || test ${RC} -eq 104 ; then
if [ -n "$is_upstart" ] || [ -n "$is_systemd" ] || testexec "${INITDPREFIX}${INITSCRIPTID}" ; then
if [ -n "$is_systemd" ] || testexec "${INITDPREFIX}${INITSCRIPTID}" ; then
RC=102
setechoactions ${ACTION}
while test ! -z "${ACTION}" ; do
@@ -500,46 +471,7 @@ if test x${FORCE} != x || test ${RC} -eq 104 ; then
printerror executing initscript action \"${saction}\"...
fi

if [ -n "$is_upstart" ]; then
case $saction in
status)
"$saction" "$INITSCRIPTID" && exit 0
;;
start|stop)
if [ -z "$RUNNING" ] && [ "$saction" = "stop" ]; then
exit 0
elif [ -n "$RUNNING" ] && [ "$saction" = "start" ]; then
exit 0
elif [ -n "$DISABLED" ] && [ "$saction" = "start" ]; then
exit 0
fi
$saction "$INITSCRIPTID" && exit 0
;;
restart)
if [ -n "$RUNNING" ] ; then
stop "$INITSCRIPTID"
fi

# If the job is disabled and is not currently
# running, the job is not restarted. However, if
# the job is disabled but has been forced into
# the running state, we *do* stop and restart it
# since this is expected behaviour
# for the admin who forced the start.
if [ -n "$DISABLED" ] && [ -z "$RUNNING" ]; then
exit 0
fi
start "$INITSCRIPTID" && exit 0
;;
reload|force-reload)
reload "$INITSCRIPTID" && exit 0
;;
*)
# This will almost certainly fail, but give it a try
initctl "$saction" "$INITSCRIPTID" && exit 0
;;
esac
elif [ -n "$is_systemd" ]; then
if [ -n "$is_systemd" ]; then
if [ -n "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
# If we are called by a maintainer script, chances are good that a
# new or updated sysv init script was installed. Reload daemon to


+ 0
- 23
script/service View File

@@ -129,29 +129,6 @@ while [ $# -gt 0 ]; do
esac
done

# Operate against system upstart, not session
unset UPSTART_SESSION
if [ -r "/etc/init/${SERVICE}.conf" ] && which initctl >/dev/null \
&& initctl version 2>/dev/null | grep -q upstart \
&& initctl status ${SERVICE} 2>/dev/null 1>/dev/null
then
# Upstart configuration exists for this job and we're running on upstart
case "${ACTION}" in
start|stop|status|reload)
# Action is a valid upstart action
exec ${ACTION} ${SERVICE} ${OPTIONS}
;;
restart|force-reload)
# Map restart to the usual sysvinit behavior.
# Map force-reload to restart as per Debian policy 9.3.2,
# since there is no way to know if "reload" is supported
stop ${SERVICE} ${OPTIONS} || :
exec start ${SERVICE} ${OPTIONS}
;;
esac
fi


run_via_sysvinit() {
# Otherwise, use the traditional sysvinit
if [ -x "${SERVICEDIR}/${SERVICE}" ]; then


+ 0
- 46
script/update-rc.d View File

@@ -166,50 +166,6 @@ sub make_systemd_links {
}
}

# Manage the .override file for upstart jobs, so update-rc.d enable/disable
# work on upstart systems the same as on sysvinit/systemd.
sub upstart_toggle {
my ($scriptname, $action) = @_;

# This needs to be done by manually parsing .override files instead of
# using initctl, because upstart might not be installed yet.
my $service_path;
if (-f "/etc/init/$scriptname.conf") {
$service_path = "/etc/init/$scriptname.override";
}
if (!defined($service_path)) {
return;
}
my $fh;
my $enabled = 1;
my $overrides = '';
if (open $fh, '<', $service_path) {
while (<$fh>) {
if (/^\s*manual\s*$/) {
$enabled = 0;
} else {
$overrides .= $_;
}
}
}
close($fh);

if ($enabled && $action eq 'disable') {
open $fh, '>>', $service_path or error("unable to write $service_path");
print $fh "manual\n";
close($fh);
} elsif (!$enabled && $action eq 'enable') {
if ($overrides ne '') {
open $fh, '>', $service_path . '.new' or error ("unable to write $service_path");
print $fh $overrides;
close($fh);
rename($service_path . '.new', $service_path) or error($!);
} else {
unlink($service_path) or error($!);
}
}
}

## Dependency based
sub insserv_updatercd {
my @args = @_;
@@ -307,8 +263,6 @@ sub insserv_updatercd {
} elsif ("disable" eq $action || "enable" eq $action) {
make_systemd_links($scriptname, $action);

upstart_toggle($scriptname, $action);

sysv_toggle($notreally, $action, $scriptname, @args);

if ( ! -x $insserv) {


Loading…
Cancel
Save