[17] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | # Tries to start the 7dtd instance. |
---|
| 4 | |
---|
| 5 | sdtdCommandStart() { |
---|
| 6 | if [ "$1" = "!" ]; then |
---|
| 7 | echo "Starting all instances:" |
---|
| 8 | for I in $(getInstanceList); do |
---|
| 9 | printf "%-*s: " 10 "$I" |
---|
| 10 | sdtdCommandStart $I |
---|
| 11 | done |
---|
| 12 | echo "All done" |
---|
| 13 | return |
---|
| 14 | fi |
---|
| 15 | |
---|
| 16 | if [ $(isValidInstance $1) -eq 0 ]; then |
---|
| 17 | echo "No instance given or not a valid instance!" |
---|
| 18 | return |
---|
| 19 | fi |
---|
| 20 | |
---|
| 21 | if [ $(isRunning $1) -eq 0 ]; then |
---|
| 22 | if [ ! `pgrep Xvfb` ]; then |
---|
| 23 | echo "Xvfb not yet running. Starting..." |
---|
| 24 | su -c "/usr/bin/Xvfb :1 -screen 0 640x480x16" $SDTD_USER 2>&1 | grep -v "Could not init font path element" & |
---|
| 25 | sleep 3 |
---|
| 26 | fi |
---|
| 27 | export DISPLAY=localhost:1.0 |
---|
| 28 | |
---|
| 29 | setAllPlayersOffline $1 |
---|
[18] | 30 | rm $SDTD_BASE/engine/7DaysToDie_Data/output_log.txt |
---|
[17] | 31 | |
---|
[20] | 32 | for H in $(getHooksFor serverPreStart); do |
---|
| 33 | $H $INSTANCE |
---|
| 34 | done |
---|
| 35 | |
---|
[17] | 36 | SSD_PID="--pidfile $(getInstancePath $1)/7dtd.pid --make-pidfile" |
---|
| 37 | SSD_DAEMON="--background --no-close" |
---|
| 38 | SSD_USER="--chuid $SDTD_USER:$SDTD_GROUP --user $SDTD_USER" |
---|
| 39 | OPTS="-quit -batchmode -nographics -configfile=$(getInstancePath $1)/config.xml -dedicated" |
---|
| 40 | |
---|
[25] | 41 | $SSD --start $SSD_PID $SSD_DAEMON $SSD_USER --chdir $SDTD_BASE/engine --exec $WINE -- $SDTD_BASE/engine/7DaysToDie.exe $OPTS > $(getInstancePath $1)/stdout.log 2>&1 |
---|
[17] | 42 | sleep 1 |
---|
[20] | 43 | |
---|
| 44 | for H in $(getHooksFor serverPostStart); do |
---|
| 45 | $H $INSTANCE |
---|
| 46 | done |
---|
| 47 | |
---|
[17] | 48 | if [ $(isRunning $1) -eq 1 ]; then |
---|
| 49 | SSD_MONITOR_PID="--pidfile $(getInstancePath $1)/monitor.pid --make-pidfile" |
---|
| 50 | SSD_MONITOR_DAEMON="--background" |
---|
[25] | 51 | $SSD --start $SSD_MONITOR_PID $SSD_MONITOR_DAEMON --exec "/usr/local/lib/7dtd/monitor-log.sh" -- "$1" |
---|
[17] | 52 | echo "Done!" |
---|
| 53 | else |
---|
| 54 | echo "Failed!" |
---|
| 55 | rm -f $(getInstancePath $1)/7dtd.pid |
---|
| 56 | fi |
---|
| 57 | else |
---|
| 58 | echo "Instance $1 is already running" |
---|
| 59 | fi |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | sdtdCommandStartHelp() { |
---|
| 63 | echo "Usage: $(basename $0) start <instance>" |
---|
| 64 | echo |
---|
| 65 | echo "Starts the given instance." |
---|
| 66 | echo "If <instance> is \"!\" all defined instances are started." |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | sdtdCommandStartDescription() { |
---|
| 70 | echo "Start the given instance" |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | sdtdCommandStartExpects() { |
---|
| 74 | case $1 in |
---|
| 75 | 2) |
---|
| 76 | echo "! $(getInstanceList)" |
---|
| 77 | ;; |
---|
| 78 | esac |
---|
| 79 | } |
---|
| 80 | |
---|