[Slackbuilds-users] Starting a daemon in rc

phalange at komputermatrix.com phalange at komputermatrix.com
Fri Mar 10 18:26:56 UTC 2023


On 2023-03-10 13:12, Jeremy Hansen wrote:
> On Fri, Mar 10, 2023, 9:11 AM <phalange at komputermatrix.com> wrote:
> 
>> On 2023-03-10 10:06, Ruben Schuller wrote:
>>> Hi!
>>> 
>>> 2023-03-10 phalange at komputermatrix.com:
>>> 
>>>> I have slackbuild for tailscale that includes a daemon. The
>> daemon
>>>> should ideally be started by the init system. But it requires an
>>>> internet connection, and in the case of using wifi, starting this
>>>> daemon from rc.local halts the init -- *I think* because it's
>>>> searching for a connection before wifi is connected.
>>>> 
>>>> Any suggestions for starting a daemon like this?
>>> 
>>> You could try the "daemon" package for this, it's shipped with
>>> Slackware
>>> and works pretty well! Here's how I do it for my dendrite
>> SlackBuild
>>> (not on SBo yet):
>>> 
>>> ----8<-------------------------------
>>> #!/bin/sh
>>> 
>>> if [ -f /etc/default/dendrite ]; then
>>> . /etc/default/dendrite
>>> fi
>>> 
>>> dendrite_start() {
>>> if [ -x /usr/bin/dendrite-monolith-server ]; then
>>> daemon -n dendrite -u dendrite --
>> dendrite-monolith-server-tls-key
>>> $TLSKEY -tls-cert $TLSCERT -config /etc/dendrite/dendrite.yaml
>>> fi
>>> }
>>> 
>>> dendrite_stop() {
>>> daemon -n dendrite -u dendrite --stop
>>> }
>>> 
>>> dendrite_restart() {
>>> dendrite_stop
>>> sleep 1
>>> dendrite_start
>>> }
>>> 
>>> case "$1" in
>>> 'start')
>>> dendrite_start
>>> ;;
>>> 'stop')
>>> dendrite_stop
>>> ;;
>>> 'restart')
>>> dendrite_restart
>>> ;;
>>> *)
>>> echo "usage $0 start|stop|restart"
>>> esac
>>> ----8<-------------------------------
>>> 
>>> I'm not sure how to handle the waiting for the network. I suppose
>> you
>>> could add something which checks if network manager is connected,
>> but
>>> be aware that there are people (myself included) who use the
>> classic
>>> Slackware network scripts for this and it wouldn't work. Maybe you
>>> could add something which pings the tailscale servers, you are
>> going
>>> to connect to them anyway.
>>> 
>>> Cheers
>>> Ruben
>>> _______________________________________________
>>> SlackBuilds-users mailing list
>>> SlackBuilds-users at slackbuilds.org
>>> https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users
>>> Archives -
>> https://lists.slackbuilds.org/pipermail/slackbuilds-users/
>>> FAQ - https://slackbuilds.org/faq/
>> 
>> Thanks Ruben, I appreciate the idea. Doesn't this require the user
>> to
>> issue a command still?
>> 
>> -AP
> 
> Personally, I'd just make a note of it in the README.
> 
> For people using Slackware's networking scripts, you could just add a
> simple command to rc.local.
> 
> if [ -x /etc/rc.d/rc.tailscale ]; then
>   /etc/rc.d/rc.tailscale start
> fi
> 
> For people using NetworkManager, they could add a script (maybe
> 00-tailscale.sh) to /etc/NetworkManager/dispatcher.d/ containing
> something like:
> 
> if [ "$2" = "up" ]; then
>   if [ -x /etc/rc.d/rc.tailscale ]; then
>     /etc/rc.d/rc.tailscale start
>   fi
> fi
> 
> I don't use NetworkManager, but I believe that is the correct format.
> 
> Jeremy
> _______________________________________________
> SlackBuilds-users mailing list
> SlackBuilds-users at slackbuilds.org
> https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users
> Archives - https://lists.slackbuilds.org/pipermail/slackbuilds-users/
> FAQ - https://slackbuilds.org/faq/

Ok thanks all, I'll test these out.


More information about the SlackBuilds-users mailing list