source: scripts/usr/local/lib/7dtd/commands/start.sh@ 46

Last change on this file since 46 was 39, checked in by alloc, 10 years ago

Minor bootstrapper changes

File size: 1.8 KB
Line 
1#!/bin/bash
2
3# Tries to start the 7dtd instance.
4
5sdtdCommandStart() {
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 setAllPlayersOffline $1
23 rm -f $(getInstancePath $1)/output_log.txt
24
25 for H in $(getHooksFor serverPreStart); do
26 $H $INSTANCE
27 done
28
29 SSD_PID="--pidfile $(getInstancePath $1)/7dtd.pid --make-pidfile"
30 SSD_DAEMON="--background --no-close"
31 SSD_USER="--chuid $SDTD_USER:$SDTD_GROUP --user $SDTD_USER"
32 OPTS="-logfile $(getInstancePath $1)/output_log.txt -configfile=$(getInstancePath $1)/config.xml -dedicated"
33
34 LD_LIBRARY_PATH=$SDTD_BASE/linux_files $SSD --start $SSD_PID $SSD_DAEMON $SSD_USER --chdir $SDTD_BASE/engine --exec $SDTD_BASE/engine/7DaysToDie.x86 -- $OPTS > $(getInstancePath $1)/stdout.log 2>&1
35 sleep 1
36
37 for H in $(getHooksFor serverPostStart); do
38 $H $INSTANCE
39 done
40
41 if [ $(isRunning $1) -eq 1 ]; then
42 SSD_MONITOR_PID="--pidfile $(getInstancePath $1)/monitor.pid --make-pidfile"
43 SSD_MONITOR_DAEMON="--background"
44 $SSD --start $SSD_MONITOR_PID $SSD_MONITOR_DAEMON --exec "/usr/local/lib/7dtd/monitor-log.sh" -- "$1"
45 echo "Done!"
46 else
47 echo "Failed!"
48 rm -f $(getInstancePath $1)/7dtd.pid
49 fi
50 else
51 echo "Instance $1 is already running"
52 fi
53}
54
55sdtdCommandStartHelp() {
56 echo "Usage: $(basename $0) start <instance>"
57 echo
58 echo "Starts the given instance."
59 echo "If <instance> is \"!\" all defined instances are started."
60}
61
62sdtdCommandStartDescription() {
63 echo "Start the given instance"
64}
65
66sdtdCommandStartExpects() {
67 case $1 in
68 2)
69 echo "! $(getInstanceList)"
70 ;;
71 esac
72}
73
Note: See TracBrowser for help on using the repository browser.