Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

lg188
Saturday, August 18th, 2012 at 2:51:47am MDT 

  1. #!/bin/sh
  2. # Copyright (c) 2010 TeamSpeak Systems GmbH
  3. # All rights reserved
  4.  
  5. COMMANDLINE_PARAMETERS="${2}" #add any command line parameters you want to pass here
  6. D1=$(readlink -f "$0")
  7. BINARYPATH="$(dirname "${D1}")"
  8. cd "${BINARYPATH}"
  9. LIBRARYPATH="$(pwd)"
  10.  
  11.  
  12. if [ -e ts3server_linux_x86 ]; then
  13.         if [ -z "`uname | grep Linux`" -o ! -z "`uname -m | grep 64`" ]; then
  14.                 echo "Do you have the right TS3 Server package for your system? You have: `uname` `uname -m`, not Linux i386."
  15.         fi
  16.         BINARYNAME="ts3server_linux_x86"
  17. elif [ -e ts3server_linux_amd64 ]; then
  18.         if [ -z "`uname | grep Linux`" -o -z "`uname -m | grep 64`" ]; then
  19.                 echo "Do you have the right TS3 Server package for your system? You have: `uname` `uname -m`, not Linux x86_64."
  20.         fi
  21.         BINARYNAME="ts3server_linux_amd64"
  22. elif [ -e ts3server_freebsd_x86 ]; then
  23.         if [ ! -z "`uname | grep Linux`" -o ! -z "`uname -m | grep 64`" ]; then
  24.                 echo "Do you have the right TS3 Server package for your system? You have: `uname` `uname -m`, not FreeBSD i386."
  25.         fi
  26.         BINARYNAME="ts3server_freebsd_x86"
  27. elif [ -e ts3server_freebsd_amd64 ]; then
  28.         if [ ! -z "`uname | grep Linux`" -o -z "`uname -m | grep 64`" ]; then
  29.                 echo "Do you have the right TS3 Server package for your system? You have: `uname` `uname -m`, not FreeBSD amd64."
  30.         fi
  31.         BINARYNAME="ts3server_freebsd_amd64"
  32. else
  33.         echo "Could not locate binary file, aborting"
  34.         exit 5
  35. fi
  36.  
  37. case "$1" in
  38.         start)
  39.                 if [ -e ts3server.pid ]; then
  40.                         if ( kill -0 $(cat ts3server.pid) 2> /dev/null ); then
  41.                                 echo "The server is already running, try restart or stop"
  42.                                 exit 1
  43.                         else
  44.                                 echo "ts3server.pid found, but no server running. Possibly your previously started server crashed"
  45.                                 echo "Please view the logfile for details."
  46.                                 rm ts3server.pid
  47.                         fi
  48.                 fi
  49.                 if [ "${UID}" = "0" ]; then
  50.                         echo WARNING ! For security reasons we advise: DO NOT RUN THE SERVER AS ROOT
  51.                         c=1
  52.                         while [ "$c" -le 10 ]; do
  53.                                 echo -n "!"
  54.                                 sleep 1
  55.                                 c=$((++c))
  56.                         done
  57.                         echo "!"
  58.                 fi
  59.                 echo "Starting the TeamSpeak 3 server"
  60.                 if [ -e "$BINARYNAME" ]; then
  61.                         if [ ! -x "$BINARYNAME" ]; then
  62.                                 echo "${BINARYNAME} is not executable, trying to set it"
  63.                                 chmod u+x "${BINARYNAME}"
  64.                         fi
  65.                         if [ -x "$BINARYNAME" ]; then
  66.                                 export LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}"
  67.                                 "./${BINARYNAME}" ${COMMANDLINE_PARAMETERS} > /dev/null &
  68.                                 echo $! > ts3server.pid
  69.                                 echo "TeamSpeak 3 server started, for details please view the log file"
  70.                         else
  71.                                 echo "${BINARNAME} is not exectuable, cannot start TeamSpeak 3 server"
  72.                         fi
  73.                 else
  74.                         echo "Could not find binary, aborting"
  75.                         exit 5
  76.                 fi
  77.         ;;
  78.         stop)
  79.                 if [ -e ts3server.pid ]; then
  80.                         echo -n "Stopping the TeamSpeak 3 server"
  81.                         if ( kill -TERM $(cat ts3server.pid) 2> /dev/null ); then
  82.                                 c=1
  83.                                 while [ "$c" -le 300 ]; do
  84.                                         if ( kill -0 $(cat ts3server.pid) 2> /dev/null ); then
  85.                                                 echo -n "."
  86.                                                 sleep 1
  87.                                         else
  88.                                                 break
  89.                                         fi
  90.                                         c=$((++c))
  91.                                 done
  92.                         fi
  93.                         if ( kill -0 $(cat ts3server.pid) 2> /dev/null ); then
  94.                                 echo "Server is not shutting down cleanly - killing"
  95.                                 kill -KILL $(cat ts3server.pid)
  96.                         else
  97.                                 echo "done"
  98.                         fi
  99.                         rm ts3server.pid
  100.                 else
  101.                         echo "No server running (ts3server.pid is missing)"
  102.                         exit 7
  103.                 fi
  104.         ;;
  105.         restart)
  106.                 $0 stop && $0 start || exit 1
  107.         ;;
  108.         status)
  109.                 if [ -e ts3server.pid ]; then
  110.                         if ( kill -0 $(cat ts3server.pid) 2> /dev/null ); then
  111.                                 echo "Server is running"
  112.                         else
  113.                                 echo "Server seems to have died"
  114.                         fi
  115.                 else
  116.                         echo "No server running (ts3server.pid is missing)"
  117.                 fi
  118.         ;;
  119.         *)
  120.                 echo "Usage: ${0} {start|stop|restart|status}"
  121.                 exit 2
  122. esac
  123. exit 0

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right