Entware / Entware-ng

Entware-ng
GNU General Public License v2.0
1.21k stars 153 forks source link

mosquitto init.d support #881

Closed serhatozkara closed 6 years ago

serhatozkara commented 6 years ago

Package: mosquitto-ssl mosquitto-nossl

Platform:

DD-WRT v3.0-r34929M std running on TP-Link Archer C7 v2

zyxmon commented 6 years ago

Please make a PR to add startup script. We cannot test all packages and add all startup scripts.

serhatozkara commented 6 years ago

This is the first time I'm using entware. If I could make an init script for it, i would gladly do so and create a PR :)

zyxmon commented 6 years ago

Most of the scripts look like this one - https://github.com/Entware-ng/entware-oldpackages-ports/blob/master/amule/files/S57amuled

serhatozkara commented 6 years ago

OK, I've created the S80mosquitto under init.d with the following content:

#!/bin/sh

ENABLED=yes
PROCS=mosquitto
ARGS="-c /opt/etc/mosquitto/mosquitto.conf"
PREARGS=""
DESC=$PROCS
PATH=/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

. /opt/etc/init.d/rc.func

mosquitto defaults to running under mosquitto:mosquitto user. Can we change that behaviour with the init script? If yes, i think this startup script is ready to commit. If not, default conf file should be modified to run under root user (not good) or mosquitto:mosquitto user and group should be created when installing mosquitto packages. Thanks for the heads up.

zyxmon commented 6 years ago

mosquitto defaults to running under mosquitto:mosquitto user.

Adding users and groups is firmware dependent. This may be the reason there is no startup script that should be universal.

serhatozkara commented 6 years ago

Hmm I didn't know about that. But as all (most?) processes run under root in a router environment, running it as root user shouldn't be a problem. (AFAIK) This is the the default conf: https://github.com/eclipse/mosquitto/blob/master/mosquitto.conf

# When run as root, drop privileges to this user and its primary 
# group.
# Leave blank to stay as root, but this is not recommended.
# If run as a non-root user, this setting has no effect.
# Note that on Windows this has no effect and so mosquitto should 
# be started by the user you wish it to run as.
#user mosquitto

The same thing stated under /opt/etc/mosquitto/mosquitto.conf It should run under root user as default if defined in conf file otherwise. But it's not running under root user by default and complains about mosquitto user when used in entware. Something is not right definitely.