Bad test for $START_DARKSTAT in /etc/init.d/darkstat

Bug #1839492 reported by Marco Coletti
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
darkstat (Ubuntu)
New
Undecided
Unassigned

Bug Description

---
# apt show darkstat
Package: darkstat
Version: 3.0.719-1
Priority: optional
Section: universe/net
Origin: Ubuntu
Maintainer: Ubuntu Developers <email address hidden>
Original-Maintainer: Rene Mayorga <email address hidden>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 169 kB
Depends: libc6 (>= 2.17), libpcap0.8 (>= 0.9.8), zlib1g (>= 1:1.1.4), debconf (>= 0.5) | debconf-2.0, lsb-base (>= 3.0-6)
Homepage: https://unix4lyfe.org/darkstat/
Download-Size: 59.7 kB
APT-Manual-Installed: yes
APT-Sources: http://ubuntu.mirrors.ovh.net/ftp.ubuntu.com/ubuntu xenial/universe amd64 Packages
---

Darkstat does not start with any of the following commands:
/etc/init.d/darkstat start
service darkstat start
systemctl start darkstat

In /etc/darkstat/init.cfg I have:
---
START_DARKSTAT=yes
---

but in /etc/init.d/darkstat I see:
---
test "$START_DARKSTAT" = "yes" || exit 0
---
which looks like it would just exit when START_DARKSTAT=yes.

Workaround:
In /etc/darkstat/init.cfg set:
---
START_DARKSTAT=whatever_word_besides_no_or_yes
---

Tags: darkstat
Revision history for this message
Emil Mikulic (darkmoon) wrote :

Shouldn't:
 test "$START_DARKSTAT" = "yes" || exit 0
Mean "variable has to equal yes or else early exit" ?

$ test "$X" = "yes" || echo early exit
early exit
$ export X=yes; test "$X" = "yes" || echo early exit
$

What am I missing?

Revision history for this message
Marco Coletti (colemarc) wrote :

Yes, my bad, there is no bug in that expression.
Altough for some reason "systemctl restart darkstat" works while "systemctl start darkstat" does not.

Revision history for this message
Emil Mikulic (darkmoon) wrote :

What shows up on the console + in "journalctl -f" + in syslog when you run:

systemctl start darkstat
systemctl status darkstat.service

Revision history for this message
Marco Coletti (colemarc) wrote :
Download full text (3.6 KiB)

root@colm:~# systemctl start darkstat
root@colm:~# systemctl status darkstat
● darkstat.service - LSB: start darkstat monitoring system at boot time
   Loaded: loaded (/etc/init.d/darkstat; bad; vendor preset: enabled)
   Active: active (exited) since Mon 2019-08-26 23:49:16 CEST; 1 weeks 0 days ago
     Docs: man:systemd-sysv-generator(8)
  Process: 836 ExecStart=/etc/init.d/darkstat start (code=exited, status=0/SUCCESS)

Sep 03 13:52:47 colm.tk systemd[1]: Started LSB: start darkstat monitoring system at boot time.
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

root@colm:~# journalctl -f
Sep 03 13:52:47 colm.tk systemd[1]: Started LSB: start darkstat monitoring system at boot time.

root@colm:~# systemctl restart darkstat
root@colm:~# systemctl status darkstat
● darkstat.service - LSB: start darkstat monitoring system at boot time
   Loaded: loaded (/etc/init.d/darkstat; bad; vendor preset: enabled)
   Active: active (running) since Tue 2019-09-03 13:55:23 CEST; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 10121 ExecStop=/etc/init.d/darkstat stop (code=exited, status=0/SUCCESS)
  Process: 10129 ExecStart=/etc/init.d/darkstat start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/darkstat.service
           └─10135 /usr/sbin/darkstat -i eth0 -p 666 --chroot /var/lib/darkstat --pidfile /var/lib/darkstat/darkstat.pid

Sep 03 13:55:22 colm.tk systemd[1]: Starting LSB: start darkstat monitoring system at boot time...
Sep 03 13:55:22 colm.tk darkstat[10129]: * Starting darkstat network daemon : darkstat
Sep 03 13:55:23 colm.tk darkstat[10129]: * done
Sep 03 13:55:23 colm.tk darkstat[10129]: ...done.
Sep 03 13:55:23 colm.tk systemd[1]: Started LSB: start darkstat monitoring system at boot time.

Sep 03 13:55:22 colm.tk systemd[1]: Stopping LSB: start darkstat monitoring system at boot time...
Sep 03 13:55:22 colm.tk darkstat[10121]: * Stopping darkstat network daemon : darkstat...
Sep 03 13:55:22 colm.tk darkstat[10121]: ...done.
Sep 03 13:55:22 colm.tk systemd[1]: Stopped LSB: start darkstat monitoring system at boot time.
Sep 03 13:55:22 colm.tk audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=darkstat comm="systemd" exe="/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Sep 03 13:55:22 colm.tk systemd[1]: Starting LSB: start darkstat monitoring system at boot time...
Sep 03 13:55:22 colm.tk darkstat[10129]: * Starting darkstat network daemon : darkstat
Sep 03 13:55:23 colm.tk audit: ANOM_PROMISCUOUS dev=eth0 prom=256 old_prom=0 auid=4294967295 uid=0 gid=0 ses=4294967295
Sep 03 13:55:23 colm.tk audit[10135]: SYSCALL arch=c000003e syscall=54 success=yes exit=0 a0=4 a1=107 a2=1 a3=7ffeaf1b2820 items=0 ppid=10134 pid=10135 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="darkstat" exe="/usr/sbin/darkstat" key=(null)
Sep 03 13:55:23 colm.tk audit: PROCTITLE proctitle=2F7573722F7362696E2F6461726B73746174002D690065746830002D7000363636002D2D6368726F6F74002F7661722F6C69622F6461726B73746174002D2D70696466696C65002F7661722F6C69622F6461726B737461742F6461726B737461742E706964002D6...

Read more...

Revision history for this message
Emil Mikulic (darkmoon) wrote :

Apparently "bad" just means it's not a native systemd service.

So it doesn't start on boot? And it doesn't start on "systemctl start darkstat"?

Revision history for this message
Marco Coletti (colemarc) wrote :

I never checked it just after a boot, but the process was always missing before a "systemctl restart".
"systemctl start" definitely does not start the process.

Revision history for this message
Emil Mikulic (darkmoon) wrote :

Ok so after boot what does "systemctl status darkstat" say? Because in #4 it was running with no errors.

Revision history for this message
Marco Coletti (colemarc) wrote :
Download full text (3.2 KiB)

Just after boot:

● darkstat.service - LSB: start darkstat monitoring system at boot time
   Loaded: loaded (/etc/init.d/darkstat; bad; vendor preset: enabled)
   Active: active (running) since Wed 2019-09-04 15:56:16 CEST; 2min 30s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 859 ExecStart=/etc/init.d/darkstat start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/darkstat.service
           └─970 /usr/sbin/darkstat -i eth0 -p 666 --chroot /var/lib/darkstat --pidfile /var/lib/darkstat/darkstat.pi

Sep 04 15:56:14 colm.tk systemd[1]: Starting LSB: start darkstat monitoring system at boot time...
Sep 04 15:56:14 colm.tk darkstat[859]: * Starting darkstat network daemon : darkstat
Sep 04 15:56:16 colm.tk darkstat[859]: * done
Sep 04 15:56:16 colm.tk darkstat[859]: ...done.
Sep 04 15:56:16 colm.tk systemd[1]: Started LSB: start darkstat monitoring system at boot time.

So yes, it does start at boot.

And now it starts with "start" too:

root@colm:~# systemctl stop darkstat
root@colm:~# systemctl status darkstat
● darkstat.service - LSB: start darkstat monitoring system at boot time
   Loaded: loaded (/etc/init.d/darkstat; bad; vendor preset: enabled)
   Active: inactive (dead) since Wed 2019-09-04 15:59:49 CEST; 3s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1877 ExecStop=/etc/init.d/darkstat stop (code=exited, status=0/SUCCESS)
  Process: 859 ExecStart=/etc/init.d/darkstat start (code=exited, status=0/SUCCESS)

Sep 04 15:56:14 colm.tk darkstat[859]: * Starting darkstat network daemon : darkstat
Sep 04 15:56:16 colm.tk darkstat[859]: * done
Sep 04 15:56:16 colm.tk darkstat[859]: ...done.
Sep 04 15:56:16 colm.tk systemd[1]: Started LSB: start darkstat monitoring system at boot time.
Sep 04 15:59:48 colm.tk systemd[1]: Stopping LSB: start darkstat monitoring system at boot time...
Sep 04 15:59:48 colm.tk darkstat[1877]: * Stopping darkstat network daemon : darkstat...
Sep 04 15:59:49 colm.tk darkstat[1877]: * stopped
Sep 04 15:59:49 colm.tk darkstat[1877]: ...done.
Sep 04 15:59:49 colm.tk systemd[1]: Stopped LSB: start darkstat monitoring system at boot time.

root@colm:~# systemctl start darkstat
root@colm:~# systemctl status darkstat
● darkstat.service - LSB: start darkstat monitoring system at boot time
   Loaded: loaded (/etc/init.d/darkstat; bad; vendor preset: enabled)
   Active: active (running) since Wed 2019-09-04 16:00:33 CEST; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1877 ExecStop=/etc/init.d/darkstat stop (code=exited, status=0/SUCCESS)
  Process: 1992 ExecStart=/etc/init.d/darkstat start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/darkstat.service
           └─1998 /usr/sbin/darkstat -i eth0 -p 666 --chroot /var/lib/darkstat --pidfile /var/lib/darkstat/darkstat.p

Sep 04 16:00:33 colm.tk systemd[1]: Starting LSB: start darkstat monitoring system at boot time...
Sep 04 16:00:33 colm.tk darkstat[1992]: * Starting darkstat network daemon : darkstat
Sep 04 16:00:33 colm.tk darkstat[1992]: * done
Sep 04 16:00:33 colm.tk darkstat[1992]: ...done.
Sep 04 16:00:33 colm.tk systemd[1]: Started LSB: start darkstat monitoring system at boot time.

Well, I could swear...

Read more...

Revision history for this message
Emil Mikulic (darkmoon) wrote :

Glad you got it resolved. ;)

The only other thing I can think of is that it sometimes fails to start at boot because of an ordering/timing problem (i.e. listening on an interface before it's up'd). Make darkstat log to syslog, reboot, and examine the syslog.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.