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