Subject: bug#831: mosquitto: Startup script fails

From: Koos van den Hout <[email-masked]>
Date: Sun, 28 Jan 2024 18:34:24 +0100

Package: mosquitto
Version: 2.0.11-1+deb11u1
Severity: normal
Tags: newcomer

Dear Maintainer,

I installed mosquitto mqtt server under Devuan chimera and it failed to
start. Searching for a solution found that this is known in the mosquitto
package

https://github.com/eclipse/mosquitto/issues/2659

This fix just hasn't been implemented in the Devuan Chimera mosquitto
package. Fixing the startup script by hand does fix the problem.

-- System Information:
Distributor ID:	Devuan
Description:	Devuan GNU/Linux 4 (chimaera)
Release:	4
Codename:	chimaera
Architecture: x86_64

Kernel: Linux 5.10.0-26-amd64 (SMP w/1 CPU thread)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled

Versions of packages mosquitto depends on:
ii  adduser                    3.118+deb11u1
ii  libc6                      2.31-13+deb11u7
ii  libcjson1                  1.7.14-1
ii  libdlt2                    2.18.6-1+deb11u1
ii  libelogind0 [libsystemd0]  246.10-2
ii  libmosquitto1              2.0.11-1+deb11u1
ii  libssl1.1                  1.1.1w-0+deb11u1
ii  libwebsockets16            4.0.20-2
ii  libwrap0                   7.6.q-31
ii  lsb-base                   11.1.0

mosquitto recommends no packages.

Versions of packages mosquitto suggests:
ii  apparmor  2.13.6-10

-- Configuration Files:
/etc/init.d/mosquitto changed:
set -e
PIDDIR=/run/mosquitto
PIDFILE="${PIDDIR}/mosquitto.pid"
DAEMON=/usr/sbin/mosquitto
test -x ${DAEMON} || exit 0
umask 022
. /lib/lsb/init-functions
run_by_init() {
    ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
}
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
create_pid_dir() {
    mkdir -p "$PIDDIR"
    chown mosquitto: "$PIDDIR"
}
case "$1" in
  start)
	if init_is_upstart; then
	    exit 1
	fi
	create_pid_dir
	log_daemon_msg "Starting network daemon:" "mosquitto"
	if start-stop-daemon -u mosquitto -c mosquitto --start --quiet --oknodo --background --pidfile ${PIDFILE} --exec ${DAEMON} -- -c /etc/mosquitto/mosquitto.conf ; then
	    log_end_msg 0
	else
	    log_end_msg 1
	fi
	;;
  stop)
	if init_is_upstart; then
	    exit 0
	fi
	log_daemon_msg "Stopping network daemon:" "mosquitto"
	if start-stop-daemon --stop --quiet --oknodo --pidfile ${PIDFILE}; then
	    log_end_msg 0
	    rm -f ${PIDFILE}
	else
	    log_end_msg 1
	fi
	;;
  reload|force-reload)
	if init_is_upstart; then
	    exit 1
	fi
	log_daemon_msg "Reloading network daemon configuration:" "mosquitto"
        if start-stop-daemon -u mosquitto --stop --signal HUP --quiet --oknodo --pidfile $PIDFILE; then
            log_end_msg 0
        else
            log_end_msg 1
        fi	
	;;
  restart)
	if init_is_upstart; then
	    exit 1
	fi
	log_daemon_msg "Restarting network daemon:" "mosquitto"
	if start-stop-daemon -u mosquitto --stop --quiet --oknodo --retry 30 --pidfile ${PIDFILE}; then
	    rm -f ${PIDFILE}
	fi
	create_pid_dir
	if start-stop-daemon -c mosquitto -u mosquitto --start --quiet --oknodo --background --pidfile ${PIDFILE} --exec ${DAEMON} -- -c /etc/mosquitto/mosquitto.conf ; then
	    log_end_msg 0
	else
	    log_end_msg 1
	fi
	;;
  try-restart)
	if init_is_upstart; then
	    exit 1
	fi
	log_daemon_msg "Restarting Mosquitto message broker" "mosquitto"
	set +e
	start-stop-daemon -u mosquitto --stop --quiet --retry 30 --pidfile ${PIDFILE}
	RET="$?"
	set -e
	case $RET in
	    0)
		# old daemon stopped
		rm -f ${PIDFILE}
		if start-stop-daemon -c mosquitto -u mosquitto --start --quiet --oknodo --background --pidfile ${PIDFILE} --exec ${DAEMON} -- -c /etc/mosquitto/mosquitto.conf ; then
		    log_end_msg 0
		else
		    log_end_msg 1
		fi
		;;
	    1)
		# daemon not running
		log_progress_msg "(not running)"
		log_end_msg 0
		;;
	    *)
		# failed to stop
		log_progress_msg "(failed to stop)"
		log_end_msg 1
		;;
	esac
	;;
  status)
	if init_is_upstart; then
	    exit 1
	fi
	status_of_proc -p ${PIDFILE} ${DAEMON} mosquitto && exit 0 || exit $?
	;;
  *)
	log_action_msg "Usage: /etc/init.d/mosquitto {start|stop|reload|force-reload|restart|try-restart|status}"
	exit 1
esac
exit 0

-- no debconf information

---

From: Mark Hindley <[email-masked]>
Date: Sun, 28 Jan 2024 17:43:22 +0000

Control: force-merge 628 -1

Hi,

This is fixed in version 2.0.17-1. See #628.

Force merging.

Mark