[cod] Output directory redirection

DaesDemon daesdemon at free.fr
Thu Feb 2 21:42:13 EST 2006


The problem is nobody home is /root in my case (probably because he has 
no homedir )  and i don't want give nobody write rights on /root
In fact, what i do in real, is a sudo with the server user from php , 
but sadly, it doesn't change the user $HOME
So i am stuck with that.

This is my shell script: (french messages)
[code]
#! /bin/bash
#
# Author: DaesDemon From {12*S} 12salopards.free.fr
# daesdemon at free.fr
#


SERVER=cod2_lnxded
WHERE=/home/serverAdmin/cod2

case "$1" in
    start)
        if ( pgrep -f $SERVER ); then
            echo "Un $SERVER est deja lance?";
            echo "Utilisez option restart"
            exit 1
        else
            if [ "$UID" = "0" ]; then
                echo ATTENTION ! Pour des raisons de securite , il est 
conseille de NE PAS LANCER LE SERVER EN ROOT
                for c in $(seq 1 10); do
                    echo -n "!"
                    sleep 1
                done
                echo !
            fi
            cd $WHERE
            echo "starting $SERVER"
            if [ -e $SERVER ]; then
                if [ ! -x $SERVER ]; then
                    echo "$SERVER n'est pas executable, tentavive de le 
changer"
                    chmod u+x $SERVER
                fi
                if [ -x $SERVER ]; then
                    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./$SERVER +set 
net_ip xxx.xxx.xxx.xxx +set net_port 28960 +set dedicated 2 +exec 
server.cfg +set fs_basePath $WHERE +set fs_homepath $WHERE +set 
fs_gamepath $WHERE +fs_userpath $WHERE +fs_outputpath $WHERE +map_rotate 
&>/home/serverAdmin/cod2.log &
                else
                    echo "$SERVER n'est pas executable, modifiez le"
                    exit 4
                fi
            else
                echo "$SERVER introuvable"
                exit 5
            fi
        fi
    ;;
    stop)
        if ( pgrep -f $SERVER ); then
            echo "stopping the $SERVER"
            pkill -f $SERVER
        else
            echo "Pas de $SERVER a arreter"
            exit 3
        fi
    ;;
    restart)
        $0 stop && $0 start || exit 1
    ;;
    *)
        echo "Usage: $0 {start|stop|restarts}"
        exit 2
esac
exit 0
[/code]

And this is my php page
[code]
<?php
$server = $_REQUEST['server'];
$act = $_REQUEST['act'];

$output = array(); 
$output[] = $server.' '.$act;

switch($server)
{
    case 'cod2'         : $command = '/home/admin12S/cod2/cod2.sh'; break;
    default : $command = '';
}

switch ($act)
{
    case 'start'    :
    case 'stop'     :
    case 'restart'  : $action = $act; break;
    default : $action='';    
}

if ($command!=''&&$action!='')
{
    $result = exec('sudo -u serverAdmin '.$command.' 
'.$action,$output,$return_val);
}

$value ="";
foreach ($output as $line) $value.=$line."\r\n";

?>
<html>
<head>
</head>
<body>
<h1>Administration Server {12*S}<h2>
<table border="1">
    <tr>
        <td colspan=3>Server COD2</td>
    </tr>
    <tr>
        <td>Start</td>
        <td>Stop</td>
        <td>Restart</td>
    </tr>
    <tr>
        <td><a href="thispage.php?server=cod2&act=start"><img height=48 
src="images/start.gif"></img></a></td>
        <td><a href="thispage.php?server=cod2&act=stop"><img height=48 
src="images/stop.gif"></img></a></td>
        <td><a href="thispage.php?server=cod2&act=restart"><img 
height=48 src="images/reset.gif"></img></a></td>
    </tr>
</table>
<h2>Messages</h2>
<textarea name="message" rows=15 cols=50 id="message" readonly>
<?php echo $value; ?>
</textarea>
</body>
</html>
[/code]


Equipa Comercial wrote:

> Hi,
>
> Why dont you add nobody to the server user group ?
> Then you just need to give group permissions to the home folder.
>
> Can you send me the startup script and http page ?
> I tried to make one earlier but without success.
>
>
> Regards
>
> ----- Original Message ----- From: "DaesDemon" <daesdemon at free.fr>
> To: <cod at icculus.org>
> Sent: Friday, February 03, 2006 2:07 AM
> Subject: [cod] Output directory redirection
>
>
>> Hi cod2 fellows,
>> Thanks for your work.
>>
>> I have a problem in interfacing a linux cod2 server with web.
>> I use httpd user to launch a shell script that launch (or stop)  the 
>> cod2 server.
>>
>> My problem is http user (nobody) doesn't have write rights on his 
>> home directory and i don't find a way to avoid cod2_lnxded trying to 
>> create .callofduty2 directory on it.
>>
>> I had already this problem with a medal of honor server and i manage 
>> it by setting the output path to a correct dir, but i have tried all 
>> that i found for cod2 (fs_game, fs_home,all the fs options) without 
>> success.
>>
>> Is there a way to redirect outputs on another directory than the user 
>> $HOME?
>>
>> Thanks in advance ;)
>>
>
>




More information about the Cod mailing list