• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 605
  • Last Modified:

TeamSpeak Restart

I'm looking for a way to run SSH commands via a PHP file and stop and restart my Teamspeak server.  I want this for some of my staff to be able to restart the server that cannot use SSH.

Is there a way to do this?

When they click the link it would need to run this command:

./ts3server_startscript.sh stop

Open in new window

Then delay about 10 seconds.

Then run this command:
./ts3server_startscript.sh start inifile=ts3server.ini

Open in new window

The location of the start script is /home/starcit/ts/teamspeak3-server_linux-amd64
Nathan Riley
Nathan Riley
1 Solution
I would say the "safest" way to do this is to create a PHP file that has a form and a button on it. When they click the button, the PHP script simply creates a file in /tmp called "restart_teamspeak.flag", like this:

   echo "Starting the restart process. This may take up to a minute.";
  echo "<form action='".basename(__FILE__)."' method='post'><input type='submit' value='Restart Teamspeak'></form>";

Open in new window

...then create a shell script that checks for the existence of the file and simply runs those commands if it finds /tmp/restart_teamspeak.flag and then deletes the file after it's done.

Finally, create a cron job that runs that shell script every minute.

This should give you a safe way to kick off that process via a web server.

You CAN alternatively set up a web server with enough permissions to run the commands directly, but this typically means that it will have enough permissions to do other things, as well, which creates a huge vulnerability.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now