summarylogtreecommitdiffstats
path: root/tshock.sh
diff options
context:
space:
mode:
authorPhilip Abernethy2015-07-14 11:21:53 +0200
committerPhilip Abernethy2015-07-14 11:21:53 +0200
commitb6053ccbf830452b15012860cbdcc98752077124 (patch)
tree640752cac32a21a006fe05707df2edb6481d452c /tshock.sh
downloadaur-b6053ccbf830452b15012860cbdcc98752077124.tar.gz
Initial commit
Diffstat (limited to 'tshock.sh')
-rw-r--r--tshock.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/tshock.sh b/tshock.sh
new file mode 100644
index 000000000000..ec3a49d21567
--- /dev/null
+++ b/tshock.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+CONFDIR='/etc/conf.d/tshock'
+
+if [ -n "$2" ]; then
+ INSTANCE=$2
+else
+ INSTANCE=default
+fi
+
+if [ -r ${CONFDIR}/${INSTANCE}.conf ]; then
+ source ${CONFDIR}/${INSTANCE}.conf
+else
+ echo "TShock could not be started because ${CONFDIR}/${INSTANCE}.conf could not be read."
+ exit 1
+fi
+
+TMUX_CONSOLE=tshock-console-${INSTANCE}
+
+case "$1" in
+ start)
+ if [ ! $(tmux has -t ${TMUX_CONSOLE}) ]; then
+ tmux new-session -d -s ${TMUX_CONSOLE} -d "cd ${BASEDIR}; mono TerrariaServer.exe -port ${PORT} -world My\ Games/Terraria/Worlds/${WORLD}.wld"
+ if [ $? -gt 0 ]; then
+ exit 1
+ fi
+ else
+ echo "Tshock already running"
+ exit 1
+ fi
+ ;;
+
+ stop)
+ tmux send-keys -t ${TMUX_CONSOLE} 'broadcast NOTICE: Server shutting down in 5 seconds!' C-m
+ sleep 5
+ tmux send-keys -t ${TMUX_CONSOLE} 'exit' C-m
+ sleep 10
+ ;;
+
+ console)
+ tmux attach -t ${TMUX_CONSOLE}
+ ;;
+
+ install)
+ bash -c "cd ${BASEDIR}; mono TerrariaServer.exe"
+ ;;
+
+ *)
+ echo "usage: $0 {start|backup|console|install} [instance]"
+esac
+
+exit 0