source: scripts/usr/local/bin/7dtd-start.sh @ 16

Last change on this file since 16 was 16, checked in by alloc, 9 years ago

Minor cleanups

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/bin/bash
2# Version 3
3
4# Tries to start the 7dtd instance given as first parameter.
5# Returns:
6#  0 : Done
7#  1 : Was already running
8#  2 : No instance name given
9#  3 : No such instance
10#  5 : Unknown error when starting engine
11
12. /usr/local/bin/7dtd-common.sh
13checkRootLoadConf
14
15checkInstanceValid $1
16
17if [ $(isRunning $1) -eq 0 ]; then
18        if [ ! `pgrep Xvfb` ]; then
19                echo "Xvfb not yet running. Starting..."
20                su -c "/usr/bin/Xvfb :1 -screen 0 640x480x16" $SDTD_USER 2>&1 | grep -v "Could not init font path element" &
21                sleep 3
22        fi
23        export DISPLAY=localhost:1.0
24       
25        SSD_PID="--pidfile $(getInstancePath $1)/7dtd.pid --make-pidfile"
26        SSD_DAEMON="--background --no-close"
27        SSD_USER="--chuid $SDTD_USER:$SDTD_GROUP --user $SDTD_USER"
28        OPTS="-quit -batchmode -nographics -configfile=$(getInstancePath $1)/config.xml -dedicated"
29       
30        start-stop-daemon --start $SSD_PID $SSD_DAEMON $SSD_USER --chdir $SDTD_ROOT --exec $WINE -- $SDTD_ROOT/7DaysToDie.exe $OPTS > $(getInstancePath $1)/stdout.log 2>&1
31        sleep 1
32        if [ $(isRunning $1) -eq 1 ]; then
33                echo "Done!"
34                exit 0
35        else
36                echo "Failed!"
37                rm -f $(getInstancePath $1)/7dtd.pid
38                exit 5
39        fi
40else
41        echo "7dtd instance $1 is already running"
42        exit 1
43fi
Note: See TracBrowser for help on using the repository browser.