Bug#850703: systemd: incorrect LSB support with monit's init script

2017-01-11 Thread Vincent Lefevre
On 2017-01-11 18:20:14 +0100, Michael Biebl wrote:
> Given that we only have a handful of packages left which use $all, our
> time is better spent if those few packages add native service files.
> 
> Please consider filing a bug report against monit for that.

I've reported:

  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=851101

suggesting to replace

# Should-Start:  $all

by

# Should-Start:  $all mail-transport-agent

as I suppose that the $all is not really useful with systemd since
systemd can monitor its services (unlike SysV), at least in a better
way than monit.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Bug#850703: systemd: incorrect LSB support with monit's init script

2017-01-11 Thread Michael Biebl
Am 09.01.2017 um 16:41 schrieb Martin Pitt:
> Hello Vincent,
> 
> Vincent Lefevre [2017-01-09 15:15 +0100]:
>> The monit service (from the monit package) should be started last and
>> stopped first. This is not the case with systemd.
>>
>> # Should-Start:  $all
>> # Should-Stop:   $all
> 
> Please note that the SysV concept of "$all" is notoriously broken (what if
> another package uses $all too?), and cannot be represented sensibly in any
> non-serial init system (systemd, upstart, and even sysv with startpar). If
> monit needs to start/stop after/before other services, these should be
> enumerated explicitly.
> 
> That said, the SysV generator could approximate this a bit better by running
> "After=multi-user.target" instead of "Before=multi-user.target", i. e. similar
> to Type=idle.

So, we discussed this on IRC.
To add support for $all in the sysv-generator, we'd have to special case
it at various places as we already have an After=multi-user.target
ordering. This is quite ugly. And it wouldn't be a real fix anyway.

Given that we only have a handful of packages left which use $all, our
time is better spent if those few packages add native service files.

Please consider filing a bug report against monit for that.

I'll keep this bug report open for a while. Maybe someone has an idea
how to implement this cleanly. In which case we'd be fine with applying it.


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?



signature.asc
Description: OpenPGP digital signature


Bug#850703: systemd: incorrect LSB support with monit's init script

2017-01-09 Thread Michael Biebl
Am 09.01.2017 um 17:30 schrieb Vincent Lefevre:
> Hi Martin,
> 
> On 2017-01-09 16:41:20 +0100, Martin Pitt wrote:
>> Hello Vincent,
>>
>> Vincent Lefevre [2017-01-09 15:15 +0100]:
>>> The monit service (from the monit package) should be started last and
>>> stopped first. This is not the case with systemd.
>>>
>>> # Should-Start:  $all
>>> # Should-Stop:   $all
>>
>> Please note that the SysV concept of "$all" is notoriously broken
>> (what if another package uses $all too?),
> 
> I suppose that both should fall in the same class, with no
> dependencies between them. Actually, this is how it is specified
> in .
> 
>   $all  facility supported by insserv to start a script after all
> the scripts not depending on $all, at the end of the boot
> ^

Well, what is "the end of the boot"? How is this defined?

That aside, if you've seen the list I posted in my other reply, what
happens if monit wants to monitor reniced?


> monit can monitor arbitrary services, so that I suppose that it
> doesn't know in advance. A solution would be to have a way to
> enumerate all the available services on the system, and add them there
> dynamically at system start up, but isn't this equivalent to $all?

An alternative idea: monit has a grace period, say 5 min, when it is
started. Within this grace period it does not warn about non-running
services.

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?



signature.asc
Description: OpenPGP digital signature


Bug#850703: systemd: incorrect LSB support with monit's init script

2017-01-09 Thread Vincent Lefevre
Hi Martin,

On 2017-01-09 16:41:20 +0100, Martin Pitt wrote:
> Hello Vincent,
> 
> Vincent Lefevre [2017-01-09 15:15 +0100]:
> > The monit service (from the monit package) should be started last and
> > stopped first. This is not the case with systemd.
> >
> > # Should-Start:  $all
> > # Should-Stop:   $all
> 
> Please note that the SysV concept of "$all" is notoriously broken
> (what if another package uses $all too?),

I suppose that both should fall in the same class, with no
dependencies between them. Actually, this is how it is specified
in .

  $all  facility supported by insserv to start a script after all
the scripts not depending on $all, at the end of the boot
^
sequence. This only work for start ordering, not stop
ordering. Depending on a script depending on $all will
give incorrect ordering, as the script depending on $all
will be started after the script depending on it. 

According to this description, monit is incorrect for Should-Stop,
but anyway, the main problem may be with Should-Start.

> and cannot be represented sensibly in any non-serial init system
> (systemd, upstart, and even sysv with startpar). If monit needs to
> start/stop after/before other services, these should be enumerated
> explicitly.

monit can monitor arbitrary services, so that I suppose that it
doesn't know in advance. A solution would be to have a way to
enumerate all the available services on the system, and add them there
dynamically at system start up, but isn't this equivalent to $all?

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Bug#850703: systemd: incorrect LSB support with monit's init script

2017-01-09 Thread Michael Biebl
Am 09.01.2017 um 16:41 schrieb Martin Pitt:
> Hello Vincent,
> 
> Vincent Lefevre [2017-01-09 15:15 +0100]:
>> The monit service (from the monit package) should be started last and
>> stopped first. This is not the case with systemd.
>>
>> # Should-Start:  $all
>> # Should-Stop:   $all
> 
> Please note that the SysV concept of "$all" is notoriously broken (what if
> another package uses $all too?), and cannot be represented sensibly in any
> non-serial init system (systemd, upstart, and even sysv with startpar). If
> monit needs to start/stop after/before other services, these should be
> enumerated explicitly.

Heh, I was about to write the (almost) exact same reply :-)

> That said, the SysV generator could approximate this a bit better by running
> "After=multi-user.target" instead of "Before=multi-user.target", i. e. similar
> to Type=idle.

As I was curious, how many packages are potentially affected, I grepped
over the archive. We have 17 packages using $all, 2 are sysvinit
specific, 4 have a native service file, so the remaining 11 are
potential candidates.

The idea of using After=multi-user.target is interesting. I probably
wouldn't complain if a patch for that was applied.

On the other hand, for the few packages remaining still shipping SysV
init scripts only, those could just add native service files.


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?
1  bootchart/init.d/bootchart:# Required-Start:$remote_fs $all
2  cardstories/init.d/cardstories:# Required-Start:$all
   cardstories/init.d/cardstories:# Required-Stop: $all
3  debian-edu-install/init.d/xdebian-edu-firstboot:# Required-Start:
$remote_fs $all
4  dhcp-probe/init.d/dhcp-probe:# Required-Start:$local_fs $remote_fs 
$syslog $network $all
5  dtc-xen-firewall/init.d/dtc-xen-firewall:# Required-Start:$remote_fs $all
   dtc-xen/init.d/dtc-xen:# Required-Start:$all
6  monit/init.d/monit:# Should-Start:  $all
   monit/init.d/monit:# Should-Stop:   $all
7  reniced/init.d/reniced:# Required-Start:$all
8  syslog-nagios-bridge/init.d/syslog-nagios-bridge:# Required-Start:$all
   syslog-nagios-bridge/init.d/syslog-nagios-bridge:# Required-Stop: $all
9  torque-scheduler/init.d/torque-scheduler:# Required-Start:$all
   torque-scheduler/init.d/torque-scheduler:# Required-Stop: $all
   torque-scheduler/init.d/torque-scheduler:# Should-Start:  $all
   torque-scheduler/init.d/torque-scheduler:# Should-Stop:   $all
10 xymon-client/init.d/xymon-client:# Should-Start:  $all
11 xymon/init.d/xymon:# Should-Start:  $all

12 bootchart2/init.d/bootchart-done:# Required-Start:$remote_fs $all
13 cloud-init/init.d/cloud-final:# Required-Start:$all cloud-config
14 plymouth/init.d/plymouth:# Required-Start:   udev $remote_fs $all
15 watchdog/init.d/watchdog:# Required-Start:$all
   watchdog/init.d/watchdog:# Required-Stop: $all
   watchdog/init.d/wd_keepalive:# X-Start-Before:$all

16 initscripts/init.d/rc.local:# Required-Start:$all
   initscripts/init.d/rmnologin:# Required-Start:$remote_fs $all
   initscripts/init.d/single:# Required-Start:$local_fs $all killprocs
17 bootlogd/init.d/stop-bootlogd:# Required-Start:$local_fs $all
   bootlogd/init.d/stop-bootlogd-single:# Required-Start:$local_fs $all



signature.asc
Description: OpenPGP digital signature


Bug#850703: systemd: incorrect LSB support with monit's init script

2017-01-09 Thread Martin Pitt
Hello Vincent,

Vincent Lefevre [2017-01-09 15:15 +0100]:
> The monit service (from the monit package) should be started last and
> stopped first. This is not the case with systemd.
>
> # Should-Start:  $all
> # Should-Stop:   $all

Please note that the SysV concept of "$all" is notoriously broken (what if
another package uses $all too?), and cannot be represented sensibly in any
non-serial init system (systemd, upstart, and even sysv with startpar). If
monit needs to start/stop after/before other services, these should be
enumerated explicitly.

That said, the SysV generator could approximate this a bit better by running
"After=multi-user.target" instead of "Before=multi-user.target", i. e. similar
to Type=idle.

Martin

-- 
Martin Pitt| http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)



Bug#850703: systemd: incorrect LSB support with monit's init script

2017-01-09 Thread Vincent Lefevre
Package: systemd
Version: 232-8
Severity: normal

The monit service (from the monit package) should be started last and
stopped first. This is not the case with systemd.

I've attached monit's init script.

-- Package-specific info:

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500, 
'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.8.0-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages systemd depends on:
ii  adduser 3.115
ii  libacl1 2.2.52-3
ii  libapparmor12.10.95-8
ii  libaudit1   1:2.6.7-1
ii  libblkid1   2.29-1
ii  libc6   2.24-8
ii  libcap2 1:2.25-1
ii  libcryptsetup4  2:1.7.3-3
ii  libgcrypt20 1.7.5-2
ii  libgpg-error0   1.26-1
ii  libidn111.33-1
ii  libip4tc0   1.6.0+snapshot20161117-4
ii  libkmod223-2
ii  liblz4-10.0~r131-2
ii  liblzma55.2.2-1.2
ii  libmount1   2.29-1
ii  libpam0g1.1.8-3.5
ii  libseccomp2 2.3.1-2.1
ii  libselinux1 2.6-3
ii  libsystemd0 232-8
ii  mount   2.29-1
ii  util-linux  2.29-1

Versions of packages systemd recommends:
ii  dbus1.10.14-1
ii  libpam-systemd  232-8

Versions of packages systemd suggests:
ii  policykit-10.105-17
pn  systemd-container  
pn  systemd-ui 

Versions of packages systemd is related to:
pn  dracut   
ii  initramfs-tools  0.126
ii  udev 232-8

-- Configuration Files:
/etc/systemd/journald.conf changed:
[Journal]
Storage=persistent

/etc/systemd/system.conf changed:
[Manager]
DefaultTimeoutStopSec=20s


-- no debconf information
#!/bin/sh

### BEGIN INIT INFO
# Provides:  monit
# Required-Start:$remote_fs
# Required-Stop: $remote_fs
# Should-Start:  $all
# Should-Stop:   $all
# Default-Start: 2 3 4 5
# Default-Stop:  0 1 6
# Short-Description: service and resource monitoring daemon
# Description:   monit is a utility for managing and monitoring
#processes, programs, files, directories and filesystems
#on a Unix system. Monit conducts automatic maintenance
#and repair and can execute meaningful causal actions
#in error situations.
### END INIT INFO

set -e

. /lib/lsb/init-functions

DAEMON=/usr/bin/monit
CONFIG=/etc/monit/monitrc
NAME=monit
DESC="daemon monitor"
MONIT_OPTS=
PID="/run/$NAME.pid"

# Check if DAEMON binary exist
[ -f $DAEMON ] || exit 0

[ -f "/etc/default/$NAME" ] && . /etc/default/$NAME

MONIT_OPTS="-c $CONFIG $MONIT_OPTS"

monit_not_configured () {
  if [ "$1" != "stop" ]
  then
printf "\tplease configure $NAME and then edit /etc/default/$NAME\n"
printf "\tand set the \"START\" variable to \"yes\" in order to allow\n"
printf "\t$NAME to start\n"
  fi
  exit 0
}

monit_checks () {
  # Check if START variable is set to "yes", if not we exit.
  if [ "$START" != "yes" ]
  then
monit_not_configured $1
  fi
}

case "$1" in
  start)
log_daemon_msg "Starting $DESC" "$NAME"
monit_checks $1
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON 
-- $MONIT_OPTS 1>/dev/null
then
  log_end_msg 0
else
  log_end_msg 1
fi
;;
  stop)
log_daemon_msg "Stopping $DESC" "$NAME"
if start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet 
--pidfile $PID 1>/dev/null
then
  log_end_msg 0
else
  log_end_msg 1
fi
;;
  reload)
log_daemon_msg "Reloading $DESC configuration" "$NAME"
if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID 
--exec $DAEMON -- $MONIT_OPTS 1>/dev/null
then
  log_end_msg 0
else
  log_end_msg 1
fi
;;
  restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet --pidfile 
$PID 1>/dev/null
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON 
-- $MONIT_OPTS 1>/dev/null
then
  log_end_msg 0
else
  log_end_msg 1
fi
;;
  syntax)
$DAEMON $MONIT_OPTS -t
;;
  status)
status_of_proc -p $PID $DAEMON $NAME
;;
  *)
log_action_msg "Usage: /etc/init.d/$NAME 
{start|stop|reload|restart|force-reload|syntax|status}"
;;
esac

exit 0