Skrypt

Konfiguracja serwerów, usług, itp.
TheMorgenPL
Posty: 24
Rejestracja: 23 września 2014, 15:12

Skrypt

Post autor: TheMorgenPL »

Witam. Napisałem taki skrypt:
Serwer się lączy. Ale nie uruchamia ani zatrzymuje serwera ;/ a jak wykonam wlasnorecznie 'sh /home/test/ts3server_startscript.sh stop' to dziala ;/
Uprawnienia i pakiety sa OK ;/
echo '<form method="post" action="/?page=server&action=start&id='.$id.'">
<input type="submit" name="uruchom" class="formbutton" value="Uruchom Serwer!">
<input type="submit" name="zatrzymaj" class="formbutton" value="Zatrzymaj Serwer!">
</form>';
}


if(isset($_POST['uruchom'])) {
if($ssh = ssh2_connect('ts3magic.pl', 22)) {
if(ssh2_auth_password($ssh, 'root', 'haslo')) {
ssh2_exec($ssh, 'sh /home/test/ts3server_startscript.sh stop'); // Patrz na to a teraz na to xd
echo 'Polaczylem sie z serwerem i chcialem uruchomic serwer';
}}}




if(isset($_POST['zatrzymaj'])) {
if($ssh = ssh2_connect('ts3magic.pl', 22)) {
if(ssh2_auth_password($ssh, 'root', 'haslo')) {
ssh2_exec($ssh, 'sh /home/test/ts3server_startscript.sh stop');
echo 'Polaczylem sie z serwerem i chcialem zatrzymac serwer';
}}}
Awatar użytkownika
markossx
Beginner
Posty: 489
Rejestracja: 26 maja 2007, 16:01
Lokalizacja: Polska

Post autor: markossx »

Stawiam, że uprawnienia nie są OK. Chcesz aby user www wyłączył serwer?
TheMorgenPL
Posty: 24
Rejestracja: 23 września 2014, 15:12

Post autor: TheMorgenPL »

Tak jasne xd
Awatar użytkownika
markossx
Beginner
Posty: 489
Rejestracja: 26 maja 2007, 16:01
Lokalizacja: Polska

Post autor: markossx »

Jak jasne, to do dzieła!
TheMorgenPL
Posty: 24
Rejestracja: 23 września 2014, 15:12

Post autor: TheMorgenPL »

No to mówisz na czym lezy błąd?
Awatar użytkownika
pawkrol
Moderator
Posty: 939
Rejestracja: 03 kwietnia 2011, 10:25

Post autor: pawkrol »

Tak jak zasugerował markossx, gdy uruchamiasz skrypt przez www (a ma to najprawdopodobniej miejsce w twoim przypadku) , to skrypt uruchamiany jest przez użytkownika www-data i zapewne nie ma on uprawnień do zastopowania serwera. Może również nie mieć uprawnień do katalogu /home/test. Zerknij do logów

Kod: Zaznacz cały

/var/log/apache2/error.log
TheMorgenPL
Posty: 24
Rejestracja: 23 września 2014, 15:12

Post autor: TheMorgenPL »

No kurde :( Raz dziala raz nie xd można zwaryjowac xd i nic nw xd

Jakoś mi się tak wydaje że dziala to co 2min xd

Może macie jeszcze jakies pomysly xd

Awatar użytkownika
dedito
Moderator
Posty: 3518
Rejestracja: 18 listopada 2013, 21:07
Lokalizacja: Gliwice

Post autor: dedito »

Kolega Pawkrol podsunął jeden, ale brak odzewu z twojej strony.
Awatar użytkownika
mati75
Junior Member
Posty: 623
Rejestracja: 30 lipca 2009, 11:19
Lokalizacja: default city

Post autor: mati75 »

Więcej 'xD' na pewno Ci pomoże, uruchamianie usług systemowych przez web to czysta głupota.
TheMorgenPL
Posty: 24
Rejestracja: 23 września 2014, 15:12

Post autor: TheMorgenPL »

E tam głupota ;p
[Sat Jan 17 14:12:11 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:12:11 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:12:28 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:12:28 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:13:25 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:13:25 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:13:31 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:13:31 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:13:32 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:13:32 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:13:33 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:13:33 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:15:05 2015] [notice] caught SIGTERM, shutting down
[Sat Jan 17 14:15:07 2015] [notice] Apache/2.2.22 (Debian) PHP/5.4.36-0+deb7u1 configured -- resuming normal operations
[Sat Jan 17 14:15:15 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25
[Sat Jan 17 14:15:15 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29
[Sat Jan 17 14:15:16 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:15:16 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:17:17 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:17:17 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:19:52 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:19:52 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:19:59 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: report in /var/www/panel/serwery/start.php on line 25, referer: http://rconhost.pl/?page=server&action=start&id=1
[Sat Jan 17 14:19:59 2015] [error] [client 82.177.176.2] PHP Notice: Undefined variable: res in /var/www/panel/serwery/start.php on line 29, referer: http://rconhost.pl/?page=server&action=start&id=1
ODPOWIEDZ