-
-
Save rtizzy/7b5ee41c8f578426b36f11bfa2a97b3f to your computer and use it in GitHub Desktop.
Revisions
-
jdavis created this gist
Dec 28, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,80 @@ #!/bin/sh # # Terraria Config # # Tmux session ID SESSION=terraria # Username to run as USERNAME=terraria # Location of Terraria files TERDIR=/home/terraria/Terraria # Server executable SERVER=${TERDIR}/TerrariaServer.exe # Server Config CONFIG=${TERDIR}/server.conf # World to load WORLD=${TERDIR}/Worlds/${WORLD_NAME}.wld # Source function library. . /etc/rc.d/init.d/functions ME=`whoami` as_user() { if [ $ME == $USERNAME ] ; then bash -c "$1" else su - $USERNAME -c "$1" fi } start() { if [ $UID -ne 0 ] ; then echo "User has insufficient privilege." exit 4 fi ARGS="-ip 0.0.0.0 -config ${CONFIG}" CMD="mono ${SERVER} ${ARGS}" echo "Starting Terraria Server... " as_user "tmux new-session -d -s $SESSION" as_user "tmux send-keys -t ${SESSION} \"$CMD\" C-m" } stop() { if [ $UID -ne 0 ] ; then echo "User has insufficient privilege." exit 4 fi as_user "tmux send-keys -t ${SESSION} \"exit\" C-m" echo "Stopped Terraria Server" } restart() { stop start } case "$1" in start) $1 ;; stop) $1 ;; restart) $1 ;; *) echo $"Usage: $0 {start|stop|restart}" exit 2 esac exit $?