SRCDS Steam group


Remote Reboot / Shut Down Scripts
#15
Something simple using php and guessing you are on linux

Change the $path variable and $exec
PHP Code:
<?php

/*
Simple SRCDS startup script
¦ Jean-Philippe Caissy
¦ Game servers by gamers, for gamers
¦ Offering CS and CS:S Servers at a great low price
¦ www.puppyservers.com

2009/04/24
*/

$path "/home/jp/server"//Path to srcds_run
$exec "srcds_amd"//Either srcds_amd or srcds_i686 or srcds_i486

switch($_GET['action']) {
    case 
"start":
        
exec("cd ".$path." && export LD_LIBRARY_PATH=\".:bin:\$LD_LIBRARY_PATH\" && nice -20 ./".$exec." -game cstrike +maxplayers 22 +ip 10.1.0.5 -port 27015 +sys_ticrate 100 -pingboost 2 +map de_dust2 -autoupdate -pidfile hlds_run.pid  2>&1 &");
    break;
    case 
"stop":
        
exec("kill `cat ".$path."/hlds_run.pid`");
        
exec("rm ".$path."/hlds_run.pid");
    break;
    case 
"forcestart":
        
exec("kill -9 `cat ".$path."/hlds_run.pid`");
        
exec("rm ".$path."/hlds_run.pid");
    break;    
    case 
"status":
        if(!
file_exists($path."/hlds_run.pid")) {
                return 
0;
            } else {
                
exec("ps -p `cat ".$path."/hlds_run.pid`"$output);
                if(
count($output) > 2)
                    return 
"An unknown error has occured, we got more than 2 process!";
                if(
count($output) === 1)
                    return 
0;
                else
                    return 
1;
            }
            
//returns 1 if server is running
    
break;    
}

?>

Usage:
file.php?action=start or file.php?action=stop or file.php?action=forcestop
file.php?action=status returns 1 if running
Jean-Philippe | Puppy Servers
Game servers by gamers, for gamers
Offering CS and CS:S Servers at a great low price
www.puppyservers.com
Reply


Messages In This Thread
RE: Remote Reboot / Shut Down Scripts - jpcaissy - 04-25-2009, 12:32 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)