You are not logged in.

#1 2010-11-15 21:29:36

tehsusenoh
Member
Registered: 2010-11-15
Posts: 3

Creating a Daemon?

I'm making a Source Dedicated Server using Arch and this guide - http://wiki.garrysmod.com/?title=Linux_ … rver_Setup

I was wondering, is there any way that I can create a daemon from the startup script? (It's near the bottom)

I would like it to have all of the usual start, stop and restart commands that daemons usually have.

Thanks,
tehsusenoh

Offline

#2 2010-11-15 21:48:13

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: Creating a Daemon?

Sure thing, check the source of a few daemons in /etc/rc.d/ to see how to build one, it's pretty straightforward.


ᶘ ᵒᴥᵒᶅ

Offline

#3 2010-11-15 22:22:54

tehsusenoh
Member
Registered: 2010-11-15
Posts: 3

Re: Creating a Daemon?

Here's what I have so far, but I don't know how to do the stat_fail conditions.

#!/bin/bash

daemon_name=srcdsd

. /etc/rc.conf
. /etc/rc.d/functions

start=su - gmod -c 'screen -A -m -d -S gm10server /home/gmod/srcds/orangebox/scrds_run -console -game garrysmod +maxplayers 1 +map gm_flatgrass -autoupdate'

case "$1" in
    start)
        stat_busy "Starting Source Dedicated Server"
        $start >/dev/null 2>&1 </dev/null
        add_daemon srcdsd
        stat_done
        fi
        ;;
    stop)
        stat_busy "Stopping Source Dedicated Server"
        killall srcds
    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
esac
exit 0

Any issues?  This is my first Arch install, so I'm learning.

Offline

Board footer

Powered by FluxBB