Pages: [1]
  Print  
Author Topic: Auto start dedicated server  (Read 16818 times)
opdonder
Nub


Cakes 0
Posts: 22


« on: August 19, 2008, 11:26:27 AM »

So i have a dedicated server and it all just works fine, the only thing is i always log in with putty from this computer to the server to start the server
but i just want openarena to run by itself cause when i close this computer the server closes also! no i have made a script in rc6.d and it's called K99openarena
and i should load from the startup to start my server, but it just doesn't so i place the script here so maybe anyone can help me with it..

I've used a other script for a other program and just edited it (with big help from some family)
but he had little time so im still wondering what to do..
help would be grateful
----------------------------------
Script
----------------------------------

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          Openarena
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop Operarena
### END INIT INFO
#
# openarena      This init.d script is used to start openarena.
#         It basically just calls oa_ded.i386.

# Stupid hack to keep lintian happy. (Warrk! Stupidhack!).
case $1 in
   start)
      log_daemon_msg "Starting game" "openarena"
      cd openarena
      ./oa_ded.i386 +map aggressor > /dev/null 2>&1 &
      log_end_msg 0
   ;;
   stop)
      # Just kill the process
      # will do that another time
      log_daemon_msg "Stopping game" "openarena"
      log_end_msg 0
   ;;
   reload | force-reload)
      # bad luck no such option
      log_end_msg 0
   ;;
   restart)
      # bad luck no such option
      log_end_msg 0
   ;;
   start-htcacheclean)
      # bad luck no such option
      log_end_msg 0
   ;;
   stop-htcacheclean)
      # bad luck no such option
      log_end_msg 0
   ;;
   *)
      log_success_msg "Usage: /etc/init.d/openarena {start|stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean}"
      exit 1
   ;;
esac
Logged
sago007
Posts a lot
*

Cakes 62
Posts: 1664


Open Arena Developer


WWW
« Reply #1 on: August 19, 2008, 12:37:53 PM »

You can start the program or script with "nohup" (nohup ./script start) so that it will not close with the session (closing putty). Or you can start it in a screen that keeps its own separate session. Screen is normally only needed if you want to reconnect to the program and this is not necessary for OA unless you like to read the output (and based on your script I assume you aren't).


Then you want to close the server again you use the kill command if it was started with nohup or reconnect to the screen if started with a screen.
Logged

There are nothing offending in my posts.
opdonder
Nub


Cakes 0
Posts: 22


« Reply #2 on: August 19, 2008, 05:31:58 PM »

when i use nohup i receive this "error":
nohup: ignoring input and appending output to 'nohup.out'
so i've tried the nohup --help command but didn't understand much of it
Logged
sago007
Posts a lot
*

Cakes 62
Posts: 1664


Open Arena Developer


WWW
« Reply #3 on: August 20, 2008, 06:32:00 AM »

That is not an error. That is information telling you that the program has been started and that you no longer can give any input and that you can't receive any output either. If you use 'top' or 'ps aux' you will notice that it is running.

If it still does not work you can look in nohup.txt for the actual error message.
Logged

There are nothing offending in my posts.
rm
Nub


Cakes 1
Posts: 19


WWW
« Reply #4 on: August 20, 2008, 04:43:36 PM »

With regard to your script, you might want to look at the directory spec at the
> cd openarena
...line. I mean, cd where exactly, and from where? Smiley
Relative path most likely won't work here, because "cd openarena" is relative to the current directory of the init process, which could be anywhere. The proper line should look like cd /usr/local/openarena, i.e. the full path of the folder where you have the game installed.

As for me, I wouldn't bother with an init-script, I'd just add the launch command to /etc/rc.local (Debian/Ubuntu) or similar (your distro's "misc startup things" file), something like the following:
sudo -H -u user_to_run_OA_under bash -c "cd /usr/local/openarena && ./oa_ded.i386 +map aggressor" >/dev/null 2>&1 &

Note the user part, you should perhaps create a separate user to run OA under, as that's much better from the security point of view, than running the game server as root.
« Last Edit: August 20, 2008, 04:51:25 PM by rm » Logged
opdonder
Nub


Cakes 0
Posts: 22


« Reply #5 on: August 26, 2008, 06:17:41 AM »

Ah tnx finnaly a answer i understand and i can do something with!
i can finnaly continue my work to make this server work ^^
Logged
SlippJigg
Nub


Cakes 0
Posts: 39


« Reply #6 on: September 05, 2008, 10:46:20 AM »

I run my Urban Terror and Open arena servers from a bash scipt from console logon on my linux server box.  there are examples of this script in the Urban Terror Manual on their website.  Should not take to much effort to mod it to work in OA.
Logged
ncore
THIS ONE POST HERE SHOULD DO IT.


Cakes 0
Posts: 1


« Reply #7 on: January 28, 2009, 08:15:48 PM »

i have made this small script to run my openarena ded. servers it uses threee variables : game version , configname (stored in .openarena/baseoa/ directory)  , start,stop,restart switch there is:
<code>
#!/bin/sh
# first parameter : servertype (7,8) for 7.1 and 8.1 version
# second parameter : config name
# third parameter : start|stop|restart
# username : user for running oa servers ,usergroup ...
username=<user>
usergroup=<users>
if [ -f /home/$username/.openarena/baseoa/q3config.cfg ] ; then
echo "ok user $username cann run oaserver"
else
        echo "$username cannot run openarena server hint: try run server
executable logged in as $username without parameters because /home/$username/.openarena/baseoa/q3config.cfg must exist"
        exit 0
fi
cd /home/$username/
case "$3" in
 start)
   case "$1" in
      7)
start-stop-daemon --start --background --chuid "$username" --chdir /home/"$username" --pidfile "$2".pid --make-pidfile "$2".pid --exec openarena-0.7.0/ioq3ded.i386 +set dedicated 2 +set ttycon 0 +exec "$2".cfg
echo " starting openarena server version $1.1 name:$2 started by $username"
chown $username:$usergroup "$2".pid
      exit 1
      ;;
       8)
start-stop-daemon --start --background --chuid $username --chdir /home/$username --pidfile "$2".pid --make-pidfile "$2".pid --exec openarena-0.8.1/oa_ded.i386 +set dedicated 2 +set ttycon 0 +exec "$2".cfg
echo " starting openarena server version $1.1 name:$2 started by $username"
chown $username:$usergroup /home/$username/"$2".pid
      exit 1
      ;;
      *)   
echo "RTFM or make with himself something"
      exit 0
      ;;
   esac
exit 1
;;
 stop)
start-stop-daemon --stop --chuid $username --chdir /home/$username --pidfile "$2".pid
echo "stopping $2 server.."
rm /home/$username/"$2".pid
exit 1
;;

 restart)
   if [ -f "$2".pid ]; then
start-stop-daemon --stop --pidfile "$2".pid
   ./oasrv "$1" "$2" start
        echo "server $2 restarted"
   exit 1
   else
   echo "nothing like $2 seems to be running probing to start $2 server"
   ./oasrv "$1" "$2" start
   exit 1
   fi
exit 1
;;
 *)
echo "usage: version_nr. 7/8 configname without .cfg start|stop|restart"
;;

esac

exit 0
</code>
« Last Edit: January 28, 2009, 08:17:43 PM by ncore » Logged
Pages: [1]
  Print  
 
Jump to: