PDA

View Full Version : Startup screen



Ni3ls
30th January 2015, 10:43
Hi all,
I want to make a simple startup file to execute. In this file it have to kill the old screen, start a new screen, attach to screen, start server and then detach screen. However, I get managed to start the screen and resume it. But the server only starts if u quit the screen :/

screen -X -S test quit
screen -AmdS test
screen -r test
LD_LIBRARY_PATH=. LD_PRELOAD=libcod2_1_0.so ./cod2_lnxded +set dedicated 2 +set net_ip 46.4.55.66 +set net_port 28961 +set sv_maxclients 52 +exec serversd.cfg + exec pws.cfg +set fs_game test + set sv_cracked 1

This is what I got so far

Mitch
30th January 2015, 12:58
Why not use a solution that is already finished. Like OGP.
You only need to edit their cod2.xml game config. It is needs .callofduty2 after fs_homepath.

http://www.opengamepanel.org/news.php
Also if you want to add libcod to your server. Then follow this post.
http://killtube.org/showthread.php?1971-How-to-use-libcod-with-Open-Game-Panel-(OGP)&p=10190&viewfull=1#post10190

Edit: Also remove their map rotation.
%HOME_PATH% >> %HOME_PATH%.callofduty2/
http://sourceforge.net/p/hldstart/svn/HEAD/tree/trunk/upload/modules/config_games/server_configs/cod2.xml

Ni3ls
30th January 2015, 16:11
I dont have root access, so I cant install it :(

Mitch
30th January 2015, 17:14
I dont have root access, so I cant install it :(

Then look at their agent and see how they start the server. I'm sure there is something useful to learn and use from their project.

kung foo man
31st January 2015, 03:12
Instead of resuming the session to execute the command, you have to send the command with -X and specify the needed window with -p (though I only need to specify a window on my VPS, the root does it automatically, kinda strange).



screen -AmdS foo
screen -S foo -p 0 -X stuff "echo hi
"


(the newline is needed)

Instead of echo hi, you gonna write ./server.sh of course (to encapsulate your LD_PRELOAD env vars, easier/faster testing etc.)

I wrote such a script for my own "PHP hosting", so you could reuse/fit it:

/root/shell/service.sh


count_services()
{
echo $(screen -ls | grep service | wc -l)
}

#are_screens_running
#echo $?
are_screens_running()
{
linesOfScreen="$(screen -ls | wc -l)"
if [ $linesOfScreen != "2" ]; then
echo "screens running"
return 1
fi
echo "NO screens running"
return 0
}

service_start()
{
# prevent multiple services
if [ $(count_services) -ge 1 ]; then
echo "Service already running!"
return 0
fi

if ! [ -a ./server.sh ]; then
echo "Configure Service First!";
return 0
fi

# this way the session will be quitted after crash:
# so i could make a php-daemon which is watching the sessions

# start the session
screen -AmdS service #./server.sh

# this way the session is still open after crash:

screen -S service -p 0 -X stuff "./server.sh
"

echo "Service started!"
}
service_stop()
{
if [ $(count_services) = 0 ]; then
echo "Service already stopped!"
return 0
fi

#screen -r service -X quit

# delete ALL screens named "service"
for i in $(screen -ls | grep service | awk '{print $1}'); do screen -d -r $i -X quit; done
echo "Service stopped!"
}
service_status()
{
path=~
script=server.sh
if [ ! -f "$path/$script" ]; then
echo "Service not configured!"
return 0
fi

if [ $(count_services) = 0 ]; then
echo "Service not running!"
return 0
fi
echo "Service is running!"
return 1;
}
service_restart()
{
service_stop
service_start
}


case $1 in
"start")
service_start
;;

"stop")
service_stop
;;

"status")
service_status
;;

"restart")
service_restart
;;
esac


Example:



k_deathrun@Debian-70-wheezy-64-LAMP:~$ /root/shell/service.sh status
Service not running!
k_deathrun@Debian-70-wheezy-64-LAMP:~$ /root/shell/service.sh start
Service started!
k_deathrun@Debian-70-wheezy-64-LAMP:~$ /root/shell/service.sh status
Service is running!
k_deathrun@Debian-70-wheezy-64-LAMP:~$ /root/shell/service.sh stop
Service stopped!
k_deathrun@Debian-70-wheezy-64-LAMP:~$ /root/shell/service.sh status
Service not running!