Talk:Guides/Don’t Starve Together Dedicated Servers/@comment-27042537-20151004154341

For anyone that is interested. Below I have included the script that you can use for the dedicated server to be restarted in the event your host server reboots. The scripts references are based on this guides directions. You'll need to create the file in your /etc/init.d/ directory (command supplied below). I named the file "start_dst" for my own reference you may change it "name".sh with out the quotes.

sudo vim /etc/init.d/start_dst.sh



!i/bin/sh


 * 1) BEGIN INIT INFO
 * 2) Provides:          dst
 * 3) Short-Description: Don't starve server
 * 4) Description:       Starts a Dont Starve Together server
 * 5) END INIT INFO

NAME="Dont Starve together" USER="steam" SCREENREF="DST" BINARYPATH="/home/steam/steamapps/DST/bin" BINARYNAME="dontstarve_dedicated_server_nullrenderer" PIDFILE="dstserver.pid"
 * 1) The user that you installed DST server as
 * 1) should be the same as the dedicated server's install directory

cd "$BINARYPATH"

running { if [ -n "`pgrep -f $BINARYNAME`" ]; then return 0 else return 1 fi }

start { if ! running; then echo -n "Starting the $NAME server... " start-stop-daemon --start --chuid $USER --user $USER --chdir $BINARYPATH --exec "/usr/bin/screen" -- -dmS $SCREENREF $BINARYPATH pgrep -f $BINARYNAME > $PIDFILE if [ -s $PIDFILE ]; then echo "Done" else echo "Failed" rm $PIDFILE fi else echo "The $NAME server is already started." fi }

stop { if running; then echo -n "Stopping the $NAME server... " kill `cat $PIDFILE` while running; do sleep 1 done rm $PIDFILE echo "Done" else echo "The $NAME server is already stopped." fi }

case "$1" in start) start stop) stop restart) stop start status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi echo "Usage: $0 (start|stop|restart|status)" exit 1 esac exit 0



Navigate to the directory you created the file ealrier.

cd /etc/init.d/

updates the file to be excutable:

sudo chmod +x start_dst.sh

allow the script to run on boot:

sudo update-rc.d start_dst.sh defaults