RegisterRegister    Log inLog in    SearchSearch   

Post new topic   Reply to topic
 
View previous topic :: View next topic  
Author Message
RS.Pat



PostPosted: Thu Jan 14, 2010 7:06 pm    Post subject: Setting supw AND starting mumble Reply with quote

Hello, I've run into a tough problem.
I create mumble servers automatically for my clients on linux hosts, so I need gamecreate to do 2 things :
start murmur with supw command (which doesn't launch the server, it just starts, sets it's database and dies).
Code:
./murmur.x86 -ini port%server:port%.ini -supw %server:supassword%

AND after that (or before for that matters) start the server itself
Code:
./murmur.x86 -ini port%server:port%.ini


I've noticed that gamecreate only allows one command, so I wrote a wrapper script that I renamed as murmur.x86
The big problems come here :
Gamecreate seems to be monitoring the script it launches. That means, I can't just launch my commands and let my wrapper die or else gamecreate will restart it endlessly and create many useless clone servers.
So, I need my wrapper to run as long as the mumble server runs.
I first thought the wait command would do the trick, but no :
when you launch mumble, it launches another process and dies itself. So the REAL mumble server, the one we want to check is not using the pid of the ./murmur.x86 we just launched
I've found a way to get past this one : you use this command :
Code:
strace -q -e '' -s 0 -p $pid && echo 'finished!'

To get the $pid you have to add the following line to your script :
Code:
pid=`cat murmur$2.pid`;

$2 being the second argument I call my wrapper script with, the server port
To get mumble to create this .pid file, you have to edit your ini and add the following line :
Code:
pidfile=/home/gamecreate/mumble/murmur%server:port%.pid

Normally it's blank or something.

So basically I can make my wrapper run and wait for mumble to die.
BUT there still is a problem : while gamecreate is able to launch the server and set the password, it cannot kill the server. Gamecreate kills my wrapper, but not the real mumble server.
I've tried the trap command, which allows your script to catch the signal you want (e.g. SIGTERM which is sent when you do a CTRL + C to kill the running script). Here's one :
Code:
function byebye()
{
 echo "ENDING";
 kill -5 $pid;
 exit;
}
trap "byebye" 5;

This means when you send a kill (normally it sends the signal 5) to my wrapper, It'll kill the mumble server using pid (which we got earlier in a variable)

I've added many trap with different signals, it works when YOU launch the wrapper yourself and kill it with CTRL+C but it doesn't when GC starts it and kills it.
I'll post my complete script so you guys can check what's wrong.

Code:
#!/bin/bash

./murmur_orig.x86 -ini port$2.ini -supw $1 && ./murmur_orig.x86 -fg -v -ini por$
pid=`cat murmur$2.pid`;

function byebye()
{
 echo "ENDING";
 kill -5 $pid;
 exit;
}
#It's a trap !
trap "byebye" 1;
trap "byebye" 2;
trap "byebye" 3;
trap "byebye" 5;
trap "byebye" 6;
trap "byebye" 9;
trap "byebye" 14;
trap "byebye" 15;

strace -q -e '' -s 0 -p $pid && echo 'finished!'

So this wrapper script is supposed to be called with two arguments :
$1 is the supassword and $2 is the port number
Since gamecreate calls murmur.x86 I've had to rename the REAL murmur into murmur_orig.x86, and rename this script as murmur.x86

So, what in the world is wrong with my script ? does gamecreate use a signal that I'm unaware of to kill a program ?
I'd really appreciate your help here, I've been searching for this for days now.
Thanks in advance
Back to top
View user's profile Send private message
adbot



PostPosted: Thu Mar 31, 2011 3:57 am 

mamiefurax



PostPosted: Fri Jan 15, 2010 3:50 am    Post subject: Reply with quote

Hello,

I think I found the solution, but it only run on gamecreate as root.

you might run this script with 3 arguments
1st : the super user password (in gamecreate %supassword%)
2nd : the server id (in gamecreate %server:id%)
3rd : the user which have rights on the murmur files

here the code :
Code:


#!/bin/bash

echo "./murmur_orig.x86 -ini port$2.ini && ./murmur_orig.x86 -ini port$2.ini -supw $1" | su $3

pid=`cat murmur$2.pid`;

trap "kill -15 $pid; exit 0" 0 1 2 3 5 6 9 14 15 17 19 20;

while :
do
sleep 1;
done;



I hope this will useful !

PS : Sorry for my bad english Sad
Back to top
View user's profile Send private message
Kybber



PostPosted: Fri Jan 15, 2010 6:16 pm    Post subject: Reply with quote

Have you checked the owner of the mumble files? I suppose that if the file
which stores the password is owned by root, you may not be able to change
it unless you run mumble as root.
Back to top
View user's profile Send private message
Andrew
Mammoth


PostPosted: Wed Feb 17, 2010 4:12 pm    Post subject: Re: Setting supw AND starting mumble Reply with quote

"Gamecreate seems to be monitoring the script it launches. That means, I can't just launch my commands and let my wrapper die or else gamecreate will restart it endlessly and create many useless clone servers. "

A work-around for this is to tick 'Require a screen' under Game Configuration.

This will make GameCreate start a screen session before starting your wrapper script.

Then the wrapper script may exit; as GameCreate will now monitor the screen itself - not what's running inside it.

The command line issue is a known bug in GameCreate client for Linux, I've jotted it down as a problem and I will see if there is some time to try and fix this - no guarantees at the moment though, sorry.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum powered by phpBB © 2001, 2005 phpBB Group
GameCreate Service Terms | Privacy Policy | © Copyright Mammoth Media 2001-2007
GameCreate™ is a trademark of Mammoth Media Pty Ltd. GameCreate® is a registered trademark in Australia.