I've got a web-server with my hardcoded webpanel for Source server management and I've got my VPS on CentOS which doesn't really want to execute sh script when asked from remote server.
Web-server and CentOS Server are not on a same server!!!
I got this SH script:
#! /bin/bash SERVER_PORT="xxxx" SERVER_IP="xxxx" SERVER_MP="xxxx" SERVER_MAP="xxxx" SERVER_GAME="xxxx" # CODE OLDID=`cat pid_file 2> /dev/null` if [ "$OLDID" != "" ]; then screen -X -S $OLDID quit rm -f pid_file sleep 1 fi if [ "$1" != "stop" ]; then PORT_CHECK=`netstat -tuln | grep $SERVER_PORT` if [ "$PORT_CHECK" == "" ]; then UNIQID=`date +%Y%M%d%H%M%S` echo $UNIQID > pid_file screen -A -m -d -S $UNIQID ./srcds_run -console -game $SERVER_GAME -ip $SERVER_IP -port $SERVER_PORT -maxplayers $SERVER_MP +map $SERVER_MAP echo "true" else echo "false" fi fi
And I got this PHP script which executes script above:
include('classes/ssh.class.php'); $ssh = new SSH2($ssh_server, $ssh_port); if (!$ssh->auth($ssh_user, $ssh_password)) die('nologin'); $ssh->exec("sh /home/...../...../za.sh"); echo $ssh->output(); die();
This is what I get on $ssh->output()
No screen session found. true
When script is executing pid_file is not being created, server does not start and nothing exactly works but this silly warning.
What am I doing wrong?
UPD: When I execute this script via SSH console (Putty) everything works: file is being created and server starts in screen session. When I execute the same script via PHP ssh class it doesn't work properly.
UPD2: Both Putty and PHP script are logging in to system as non-root user. The game server has no need in running as root.