Bug#629902: dh_installinit: should support LSB compliant scripts
Dmitry Bogatov
KAction at debian.org
Sun Jan 13 13:31:34 GMT 2019
[ Do you want me to re-submit this patch as merge request? ]
[2019-01-11 14:58] Felipe Sateler <fsateler at debian.org>
> > [2011-06-14 11:39] Joey Hess <joeyh at debian.org>
> > >
> > > part 1 text/plain 618
> > > Helmut Grohne wrote:
> > > > A failure from the update-rc.d cannot make postinst fail, because the
> > > > exit code is not checked.
> > >
> > > Yes it is (set -x), but I meant invoke-rc.d anyway, obviously.
> > >
> > > > So in my view the reason for a postinst failure is unrelated to
> > > > update-rc.d. Can you explain your reasoning?
> > >
> > > Simple separation of concerns, invoke-rc.d is responsible for running
> > > the init script and determining if it fails and propigating a failing
> > > exit status. debhelper allows it to do do. The right way to make 6 be
> > > ignored is to get invoke-rc.d to ignore it, not add cruft to every
> > > postinst that calls it.
> >
> > Here I propose patch to implement just that:
> > [...]
> I'm wary of unintended consequences here. Do we have services that return
> exit code 6 but as a failure code?
Seems there is nobody, who use exit code 6 for another purposes. You can
make sure by checking is output of 'grep -R "exit 6" -C6' in directory
with all init scripts unpacked:
munin-node-
munin-node-if [ ! -x $DAEMON ]; then
munin-node- log_failure_msg "Munin-Node appears to be uninstalled."
munin-node- exit 5
munin-node-elif [ ! -e $CONFFILE ]; then
munin-node- log_failure_msg "Munin-Node appears to be unconfigured."
munin-node: exit 6
munin-node-fi
munin-node-
munin-node-# Figure out if the pid file is in a non-standard location
munin-node-while read line; do
munin-node- line=${line%%\#*} # get rid of comments
munin-node- set -f
--
globus-gatekeeper- fi
globus-gatekeeper-
globus-gatekeeper- cert="${GLOBUS_GATEKEEPER_CERT_FILE:-/etc/grid-security/hostcert.pem}"
globus-gatekeeper- if [ ! -f $cert ]; then
globus-gatekeeper- echo "Error: Gatekeeper's certificate file ($cert) is missing."
globus-gatekeeper- echo "Failed to start globus-gatekeeper"
globus-gatekeeper: exit 6
globus-gatekeeper- fi
globus-gatekeeper-
globus-gatekeeper- key="${GLOBUS_GATEKEEPER_KEY_FILE:-/etc/grid-security/hostkey.pem}"
globus-gatekeeper- if [ ! -f $key ]; then
globus-gatekeeper- echo "Error: Gatekeeper's private key file is ($key) is missing."
globus-gatekeeper- echo "Failed to start globus-gatekeeper"
globus-gatekeeper: exit 6
globus-gatekeeper- fi
globus-gatekeeper-
globus-gatekeeper- if [ "${GLOBUS_GATEKEEPER_KERBEROS_ENABLED:-false}" = "true" ]; then
globus-gatekeeper- kflag="-k"
globus-gatekeeper- else
globus-gatekeeper- kflag=""
--
clamav-milter- log_failure_msg "'invoke-rc.d clamav-milter start'"
clamav-milter- if [ "$1" = "status" ]; then
clamav-milter- # program or service status is unknown
clamav-milter- exit 4;
clamav-milter- else
clamav-milter- # program is not configured
clamav-milter: exit 6;
clamav-milter- fi
clamav-milter-fi
clamav-milter-
clamav-milter-slurp_config "$CLAMAVCONF"
clamav-milter-[ -n "$User" ] || User=clamav
clamav-milter-
--
clamav-milter- log_failure_msg "Please edit $CLAMAVCONF and run 'invoke-rc.d clamav-milter start'"
clamav-milter- if [ "$1" = "status" ]; then
clamav-milter- # program or service status is unknown
clamav-milter- exit 4;
clamav-milter- else
clamav-milter- # program is not configured
clamav-milter: exit 6;
clamav-milter- fi
clamav-milter-fi
clamav-milter-
clamav-milter-if is_true "$Foreground"; then
clamav-milter- if [ ! -x "$SUPERVISOR" ] ; then
clamav-milter- log_failure_msg "Foreground specified, but $SUPERVISOR not found"
clamav-milter- if [ "$1" = "status" ]; then
clamav-milter- # program or service status is unknown
clamav-milter- exit 4;
clamav-milter- else
clamav-milter- # program is not configured correctly
clamav-milter: exit 6;
clamav-milter- fi
clamav-milter- else
clamav-milter- RUN_SUPERVISED=1
clamav-milter- fi
clamav-milter-fi
clamav-milter-
--
clamav-milter- log_failure_msg "$NAME: Can not continue with PidFile not set"
clamav-milter- if [ "$1" = "status" ]; then
clamav-milter- # program or service status is unknown
clamav-milter- exit 4;
clamav-milter- else
clamav-milter- # program is not configured correctly
clamav-milter: exit 6;
clamav-milter- fi
clamav-milter-fi
clamav-milter-
clamav-milter-if [ -z "$MilterSocket" ]
clamav-milter-then
clamav-milter- log_failure_msg "$NAME: Can not continue with MilterSocket not set"
clamav-milter- if [ "$1" = "status" ]; then
clamav-milter- # program or service status is unknown
clamav-milter- exit 4;
clamav-milter- else
clamav-milter- # program is not configured correctly
clamav-milter: exit 6;
clamav-milter- fi
clamav-milter-fi
clamav-milter-
clamav-milter-if [ ! -f "$THEPIDFILE" ]
clamav-milter-then
clamav-milter- touch "$THEPIDFILE"
--
spampd-
spampd-case "$1" in
spampd- start)
spampd- if ! istrue "${STARTSPAMPD}"; then
spampd- log_warning_msg "Starting $DESC: $NAME (disabled in /etc/default/$NAME)."
spampd- # LSB 2.1: 6 mean unconfigured. This seems appropriate here.
spampd: exit 6
spampd- fi
spampd- log_daemon_msg "Starting $DESC" "$NAME"
spampd- # if spampd is already running, exit 0 as demanded by LSB 2.1
spampd- # this also removes the PIDFILE if it exists but has no matching
spampd- # process
spampd- if check_pid $PROGRAM $PIDFILE ; then
--
icinga- return 0 # no named pipe exists
icinga- fi
icinga-}
icinga-
icinga-if [ ! -f "$ICINGACFG" ]; then
icinga- log_failure_msg "There is no configuration file for Icinga."
icinga: exit 6
icinga-fi
icinga-
icinga-THEPIDFILE=$(get_config "lock_file")
icinga-[ -n "$THEPIDFILE" ] || THEPIDFILE='/var/run/icinga/icinga.pid'
icinga-
icinga-start () {
--
icinga- else
icinga- log_warning_msg "Not running."
icinga- fi
icinga- else
icinga- log_failure_msg "errors in config!"
icinga- log_end_msg 6
icinga: exit 6
icinga- fi
icinga-}
icinga-
icinga-check_run
icinga-
icinga-case "$1" in
--
rtirq-# Check for existence of needed config file and read it.
rtirq-RTIRQ_CONFIG=/etc/sysconfig/rtirq
rtirq-[ -r ${RTIRQ_CONFIG} ] || RTIRQ_CONFIG=/etc/default/rtirq
rtirq-[ -r ${RTIRQ_CONFIG} ] || RTIRQ_CONFIG=/etc/rtirq.conf
rtirq-[ -r ${RTIRQ_CONFIG} ] || {
rtirq- echo "`basename $0`: ${RTIRQ_CONFIG}: not found."
rtirq: [ "${RTIRQ_ACTION}" = "stop" ] && exit 0 || exit 6
rtirq-}
rtirq-
rtirq-# Read configuration.
rtirq-source ${RTIRQ_CONFIG}
rtirq-
rtirq-# Colon delimited trail list of already assigned IRQ numbers,
--
conman- # Exit if the package has been removed.
conman- ##
conman- [ -x "$DAEMON" ] || exit 5 # LSB: program not installed
conman-
conman- # Exit if the configuration has been removed.
conman- ##
conman: [ -z "$CONFIG" -o -r "$CONFIG" ] || exit 6 # LSB: program not configured
conman-}
conman-
conman-service_fini ()
conman-{
conman-# Return the exit status.
conman-##
--
nagios4- return 0 # no named pipe exists
nagios4- fi
nagios4-}
nagios4-
nagios4-if [ ! -f "$NAGIOSCFG" ]; then
nagios4- log_failure_msg "There is no configuration file for Nagios 3."
nagios4: exit 6
nagios4-fi
nagios4-
nagios4-THEPIDFILE=$(get_config "lock_file")
nagios4-[ -n "$THEPIDFILE" ] || THEPIDFILE='/var/run/nagios4/nagios.pid'
nagios4-
nagios4-start () {
--
nagios4- else
nagios4- log_warning_msg "Not running."
nagios4- fi
nagios4- else
nagios4- log_failure_msg "errors in config!"
nagios4- log_end_msg 6
nagios4: exit 6
nagios4- fi
nagios4-}
nagios4-
nagios4-check() {
nagios4- $DAEMON -v $NAGIOSCFG
nagios4-}
--
powerman- # Exit if the package has been removed.
powerman- ##
powerman- [ -x "$DAEMON" ] || exit 5 # LSB: program not installed
powerman-
powerman- # Exit if the configuration has been removed.
powerman- ##
powerman: [ -z "$CONFIG" -o -r "$CONFIG" ] || exit 6 # LSB: program not configured
powerman-}
powerman-
powerman-service_fini ()
powerman-{
powerman-# Return the exit status.
powerman-##
--
oss4-base- then
oss4-base- OPTIONS="`grep -v -h '^#' $OSSETCDIR/conf/osscore.conf|sed 's/ //g'`"
oss4-base- fi
oss4-base- if ! /sbin/modprobe osscore $OPTIONS
oss4-base- then
oss4-base- log_action_end_msg 60 "Cannot load the osscore module"
oss4-base: exit 60
oss4-base- fi
oss4-base-
oss4-base- # Load oss drivers
oss4-base- for n in `cat $OSSETCDIR/installed_drivers | sed 's/#.*//'`
oss4-base- do
oss4-base- OPTIONS=
--
mumudvb-}
mumudvb-
mumudvb-case "$1" in
mumudvb- start)
mumudvb- if [ ! -f "$DEFAULT_FILE" ]; then
mumudvb- log_failure_msg "$DEFAULT_FILE not found, Can't start $NAME"
mumudvb: exit 6
mumudvb- fi
mumudvb-
mumudvb- log_daemon_msg "Starting $DESC: $NAME"
mumudvb- do_start
mumudvb- log_end_msg $?
mumudvb- ;;
--
dhcpcd- local x=
dhcpcd-
dhcpcd- case "$($DHCPCD --version)" in
dhcpcd- [1234].*)
dhcpcd- log_failure_msg "Not running $NAME because an older version" \
dhcpcd- "is currently preferred"
dhcpcd: exit 6
dhcpcd- esac
dhcpcd-
dhcpcd- for x in /var/run/dhcpcd-*.pid; do
dhcpcd- [ -f "$x" ] || continue
dhcpcd- log_failure_msg "Not running $NAME because there is aleady an" \
dhcpcd- "interface specific instance"
dhcpcd- log_failure_msg "$x"
dhcpcd: exit 6
dhcpcd- done
dhcpcd-
dhcpcd- if grep -q "^[[:space:]]*iface[[:space:]]*.*[[:space:]]*inet[[:space:]]*dhcp" \
dhcpcd- $INTERFACES; then
dhcpcd- log_failure_msg "Not running $NAME because $INTERFACES"
dhcpcd- log_failure_msg "defines some interfaces that will use a" \
dhcpcd- "DHCP client"
dhcpcd: exit 6
dhcpcd- fi
dhcpcd-}
dhcpcd-
dhcpcd-case "$1" in
dhcpcd-start)
dhcpcd- sanity
--
clamav-daemon- log_failure_msg "'invoke-rc.d clamav-daemon start'"
clamav-daemon- if [ "$1" = "status" ]; then
clamav-daemon- # program or service status is unknown
clamav-daemon- exit 4;
clamav-daemon- else
clamav-daemon- # program is not configured
clamav-daemon: exit 6;
clamav-daemon- fi
clamav-daemon-fi
clamav-daemon-
clamav-daemon-slurp_config "$CLAMAVCONF"
clamav-daemon-
clamav-daemon-if [ -n "$Example" ]; then
--
clamav-daemon- log_failure_msg "Please edit $CLAMAVCONF and run 'invoke-rc.d clamav-daemon start'"
clamav-daemon- if [ "$1" = "status" ]; then
clamav-daemon- # program or service status is unknown
clamav-daemon- exit 4;
clamav-daemon- else
clamav-daemon- # program is not configured
clamav-daemon: exit 6;
clamav-daemon- fi
clamav-daemon-fi
clamav-daemon-
clamav-daemon-if is_true "$Foreground"; then
clamav-daemon- if [ ! -x "$SUPERVISOR" ] ; then
clamav-daemon- log_failure_msg "Foreground specified, but $SUPERVISORNAME not found"
clamav-daemon- if [ "$1" = "status" ]; then
clamav-daemon- # program or service status is unknown
clamav-daemon- exit 4;
clamav-daemon- else
clamav-daemon- # program is not configured correctly
clamav-daemon: exit 6;
clamav-daemon- fi
clamav-daemon- else
clamav-daemon- RUN_SUPERVISED=1
clamav-daemon- fi
clamav-daemon-fi
clamav-daemon-
--
boinc-client- "executable."
boinc-client- exit 5
boinc-client-fi
boinc-client-
boinc-client-if [ ! -d "$BOINC_DIR" ]; then
boinc-client- log_failure_msg "BOINC data directory '$BOINC_DIR' does not exist."
boinc-client: exit 6
boinc-client-fi
boinc-client-
boinc-client-if [ -z "$BOINC_USER" ]; then
boinc-client- log_failure_msg "BOINC_USER variable is empty. Set it to a user to run" \
boinc-client- "the BOINC core client."
boinc-client: exit 6
boinc-client-fi
boinc-client-
boinc-client-if [ ! -z "$BOINC_OPTS" ]; then
boinc-client- (echo $BOINC_OPTS | grep -- '--daemon' 1>/dev/null) &&
boinc-client- log_warning_msg "\`--daemon' option detected \
boinc-client- on /etc/default/boinc-client, this \
--
munge-# Exit if the package has been removed.
munge-##
munge-[ -x "$DAEMON" ] || exit 0 # program not installed
munge-
munge-# Exit if the configuration has been removed.
munge-##
munge:[ -z "$CONFIG" -o -r "$CONFIG" ] || exit 6 # program not configured
munge-
munge-###############################################################################
munge-
munge-service_init ()
munge-{
munge-# Initialize the environment.
--
drbd- out=$($DRBDADM sh-nop 2>&1); ex=$?
drbd- [[ $ex = 127 ]] && exit 5 # LSB for "not installed"
drbd- log_daemon_msg "Starting DRBD resources"
drbd- if [[ $ex != 0 ]] ; then
drbd- printf "\n%s\n" "$out" >&2
drbd- log_end_msg 1
drbd: exit 6 # LSB for "not configured"
drbd- fi
drbd-
drbd- $DRBDADM adjust-with-progress all
drbd- [[ $? -gt 1 ]] && exit 20
drbd-
drbd- # make sure udev has time to create the device files
--
snort- fi
snort- fi
snort- done
snort-
snort- if [ "$got_instance" = 0 ] && [ "$ALLOW_UNAVAILABLE" = "no" ]; then
snort- log_failure_msg "No snort instance found to be started!" >&2
snort: exit 6
snort- fi
snort-
snort- if [ $myret -eq 0 ] ; then
snort- log_end_msg 0
snort- else
snort- log_end_msg 1
--
snort- myret=$(expr "$myret" + 1)
snort- ;;
snort- esac
snort- done
snort- if [ "$got_instance" = 0 ]; then
snort- log_failure_msg "no snort instance found to be started!" >&2
snort: exit 6
snort- fi
snort-
snort- if [ $myret -eq 0 ] ; then
snort- log_end_msg 0
snort- else
snort- log_end_msg 1
--
smokeping- return
smokeping- fi
smokeping- if [ -z "$SHARED_SECRET" ]
smokeping- then
smokeping- log_progress_msg "(missing \$SHARED_SECRET setting)"
smokeping- log_end_msg 6 # program is not configured
smokeping: exit 6
smokeping- fi
smokeping- if [ ! -r "$SHARED_SECRET" ]
smokeping- then
smokeping- log_progress_msg "(invalid \$SHARED_SECRET setting)"
smokeping- log_end_msg 2 # invalid or excess argument(s)
smokeping- exit 2
smokeping- fi
smokeping- if [ -z "$MASTER_URL" ]
smokeping- then
smokeping- log_progress_msg "(missing \$MASTER_URL setting)"
smokeping- log_end_msg 6 # program is not configured
smokeping: exit 6
smokeping- fi
smokeping- DAEMON_ARGS="$DAEMON_ARGS --master-url $MASTER_URL --shared-secret $SHARED_SECRET"
smokeping- if [ -n "$SLAVE_NAME" ]
smokeping- then
smokeping- DAEMON_ARGS="$DAEMON_ARGS --slave-name $SLAVE_NAME"
smokeping- fi
--
smokeping- echo "Checking smokeping configuration file syntax..."
smokeping- # Check whether the configuration file is available
smokeping- if [ ! -r "$CONFIG" ] && [ "$MODE" = "master" ]
smokeping- then
smokeping- log_progress_msg "($CONFIG does not exist)"
smokeping- log_end_msg 6 # program is not configured
smokeping: exit 6
smokeping- fi
smokeping- if [ ! -d /var/run/smokeping ]; then
smokeping- mkdir /var/run/smokeping
smokeping- chown ${DAEMON_USER}.root /var/run/smokeping
smokeping- chmod 0755 /var/run/smokeping
smokeping- fi
smokeping: ${DAEMON} --config=${CONFIG} --check || exit 6
smokeping-}
smokeping-
smokeping-case "$1" in
smokeping- start)
smokeping- check_config
smokeping- log_daemon_msg "Starting $DESC" $NAME
--
fetchmail- exit 0
fetchmail-fi
fetchmail-
fetchmail-if [ ! -e $CONFFILE ]; then
fetchmail- log_failure_msg "$CONFFILE not found."
fetchmail- log_failure_msg "can not start fetchmail daemon... consider disabling the script"
fetchmail: exit 6
fetchmail-fi
fetchmail-
fetchmail-
fetchmail-test -f $DAEMON || exit 0
fetchmail-
fetchmail-if [ "$1" = "start" ]; then
More information about the Pkg-systemd-maintainers
mailing list