systemd / active (exited)
Helmut Schneider
jumper99 at gmx.de
Fri Aug 30 08:29:09 UTC 2019
Ralf Mardorf via ubuntu-users wrote:
> On Thu, 29 Aug 2019 11:58:07 -0000 (UTC), Helmut Schneider wrote:
> > what do I have to do that systemd shows correctly if a daemon is
> > running or not?
[...]
> Start the service by a systemd unit and then check with systemctl.
>
> "systemd-sysv-generator is a generator that creates wrapper .service
> units for SysV init scripts" -
>
https://www.freedesktop.org/software/systemd/man/systemd-sysv-generator.html
>
> This likely means that the unit does start the init script, not calmd.
> The init script does start calmd. IOW I suspect systemd only returns
> the status of the init script, not of calmd.
systemd is a book with 7 seals for me, who ever had the idea completely
lost me. It starts with I have not idea how to use variables and start
clamd chrooted:
#! /bin/sh
### BEGIN INIT INFO
# Provides: clamav-daemon-chroot
# Required-Start: $remote_fs $syslog
# Should-Start:
# Required-Stop: $remote_fs $syslog
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: ClamAV daemon
# Description: Clam AntiVirus userspace daemon (chroot'ed)
### END INIT INFO
# This File is managed by puppet, don't edit it by hand.
# All changes will be overwritten automatically!
TMPDIR=/tmp
PATH=/sbin:/bin:/usr/sbin:/usr/bin
AMAVISD_USER=amavis
AMAVISD_GROUP=amavis
AMAVISD_ROOT=/var/amavis
DAEMON=/usr/sbin/clamd
NAME="clamd"
DESC="ClamAV daemon"
CLAMAVCONF=/etc/clamav/clamd.conf
CLAMAVPID=$(grep -i PidFile ${CLAMAVCONF} | awk '{print $2}')
. /lib/lsb/init-functions
case "$1" in
start)
log_action_msg "Starting ${DESC}..."
if (pgrep -f ${DAEMON} > /dev/null); then
log_failure_msg "$DESC is running"
else
chroot --userspec $(id -u ${AMAVISD_USER}):$(id
-g ${AMAVISD_GROUP}) ${AMAVISD_ROOT} ${DAEMON} --config-file
${CLAMAVCONF}
fi
log_success_msg "${DESC} is now up and running!"
;;
stop)
log_action_msg "Stopping ${DESC}..."
start-stop-daemon --stop --oknodo --name ${NAME}
--pidfile ${AMAVISD_ROOT}/${CLAMAVPID} --retry TERM/30/KILL/5 &&
log_success_msg "${DESC} stopped!" || log_failure_msg "Error stopping
${DESC}!"
;;
restart)
$0 stop && sleep 3
$0 start
;;
status)
start-stop-daemon --status --name $DAEMON --pidfile
${AMAVISD_ROOT}/${CLAMAVPID}
# start-stop-daemon returns LSB compliant exit status
codes
ret=$?
if [ "$ret" = 0 ]; then
log_success_msg "$NAME is running"
else
log_failure_msg "$NAME is not running"
exit "$ret"
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
More information about the ubuntu-users
mailing list