TS3 Script - start/stop/restart server via web

Ch4ch4rR4t0

Active Member
Aug 19, 2016
77
7
83
Hi, I need for my project script Start / Stop and Restart, this is used for users panel for your servers created.
My panel is 78% and need only this script.
I tried to extract from ts3wi but could not.

Thnak you for help :}
 

X-Ecutioner

Contributor
Sep 16, 2015
183
121
175
Hi, I need for my project script Start / Stop and Restart, this is used for users panel for your servers created.
My panel is 78% and need only this script.
I tried to extract from ts3wi but could not.

Thnak you for help :}
This ?
Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides: teamspeak3
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Teamspeak 3 Server
### END INIT INFO
######################################
# Customize values for your needs: "User"; "DIR"
USER="teamspeak3"
DIR="/usr/local/teamspeak3/teamspeak3-server_linux-amd64"
###### Teamspeak 3 server start/stop script ######
case "$1" in
start)
su $USER -c "${DIR}/ts3server_startscript.sh start"
;;
stop)
su $USER -c "${DIR}/ts3server_startscript.sh stop"
;;
restart)
su $USER -c "${DIR}/ts3server_startscript.sh restart"
;;
status)
su $USER -c "${DIR}/ts3server_startscript.sh status"
;;
*)
echo "Usage: {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0
 

Ch4ch4rR4t0

Active Member
Aug 19, 2016
77
7
83
This ?
Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides: teamspeak3
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Teamspeak 3 Server
### END INIT INFO
######################################
# Customize values for your needs: "User"; "DIR"
USER="teamspeak3"
DIR="/usr/local/teamspeak3/teamspeak3-server_linux-amd64"
###### Teamspeak 3 server start/stop script ######
case "$1" in
start)
su $USER -c "${DIR}/ts3server_startscript.sh start"
;;
stop)
su $USER -c "${DIR}/ts3server_startscript.sh stop"
;;
restart)
su $USER -c "${DIR}/ts3server_startscript.sh restart"
;;
status)
su $USER -c "${DIR}/ts3server_startscript.sh status"
;;
*)
echo "Usage: {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0
this is for cron friend, i need to php code
 

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
It's not that hard to understand its documentation but I created a script for you.
PHP:
<?PHP
/*-------SETTINGS-------*/
$ts3_ip = '127.0.0.1';
$ts3_queryport = 10011;
$ts3_user = 'serveradmin';
$ts3_pass = 'password';
$ts3_sid = 1;
/*----------------------*/

require("ts3admin.class.php");

$tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);

if($tsAdmin->getElement('success', $tsAdmin->connect())) {
    $tsAdmin->login($ts3_user, $ts3_pass);
  
    $tsAdmin->serverStop($ts3_sid); //stop server
    $tsAdmin->serverStop($ts3_sid); //start server

}else{
    echo 'Connection could not be established.';
}
?>
 

Ch4ch4rR4t0

Active Member
Aug 19, 2016
77
7
83
It's not that hard to understand its documentation but I created a script for you.
PHP:
<?PHP
/*-------SETTINGS-------*/
$ts3_ip = '127.0.0.1';
$ts3_queryport = 10011;
$ts3_user = 'serveradmin';
$ts3_pass = 'password';
$ts3_sid = 1;
/*----------------------*/

require("ts3admin.class.php");

$tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);

if($tsAdmin->getElement('success', $tsAdmin->connect())) {
    $tsAdmin->login($ts3_user, $ts3_pass);
 
    $tsAdmin->serverStop($ts3_sid); //stop server
    $tsAdmin->serverStop($ts3_sid); //start server

}else{
    echo 'Connection could not be established.';
}
?>
thank you, if possible tell me where the +rep button.
I am very grateful generosity
 

Ch4ch4rR4t0

Active Member
Aug 19, 2016
77
7
83
It's not that hard to understand its documentation but I created a script for you.
PHP:
<?PHP
/*-------SETTINGS-------*/
$ts3_ip = '127.0.0.1';
$ts3_queryport = 10011;
$ts3_user = 'serveradmin';
$ts3_pass = 'password';
$ts3_sid = 1;
/*----------------------*/

require("ts3admin.class.php");

$tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);

if($tsAdmin->getElement('success', $tsAdmin->connect())) {
    $tsAdmin->login($ts3_user, $ts3_pass);
 
    $tsAdmin->serverStop($ts3_sid); //stop server
    $tsAdmin->serverStop($ts3_sid); //start server

}else{
    echo 'Connection could not be established.';
}
?>
Worked 100% bro, very thanks

<?PHP
/*-------SETTINGS-------*/
$ts3_ip = 'localhost;
$ts3_queryport = 10011;
$ts3_user = 'serveradmin';
$ts3_pass = '123456';
$ts3_sid = 8;
/*----------------------*/

require("ts3admin.class.php");

$tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);

if (isset($_POST['mbutton']) and ! empty($_POST['mbutton'])) {
if (isset($_POST['s_status'])) {
$answer = $_POST['s_status'];

if ($answer == "Offline") {
echo 'Stauts: '.$answer.'';
echo '<br /><br />';

if($tsAdmin->getElement('success', $tsAdmin->connect())) {
$tsAdmin->login($ts3_user, $ts3_pass);

$tsAdmin->serverStop($ts3_sid); //stop server

}else{
echo 'Falha na conexão\\';
}
} else {
echo 'Stauts: '.$answer.'';
echo '<br /><br />';

if($tsAdmin->getElement('success', $tsAdmin->connect())) {
$tsAdmin->login($ts3_user, $ts3_pass);

$tsAdmin->serverStart($ts3_sid); //stop server

}else{
echo 'Falha na conexão\\';
}
}

}
} else {
echo 'Status do Servidor';
}

?>


<form action="" method="post">

<hr>

<input type="radio" name="s_status" value="Offline">Desligar</option>
<input type="radio" name="s_status" value="Online">Ligar</option>
<br />
<input type="submit" name="mbutton" value="Salvar">

</form>
 
  • Like
Reactions: ptR

ptR

Member
Nov 15, 2015
47
0
38
formatting abuse
Can you make it with buttons and not a radio buttons please? Solved
 
Last edited:
Top