Results 1 to 5 of 5

Thread: Startup screen

  1. #1
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts

    Startup screen

    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 :/
    PHP Code:
    screen --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

  2. #2
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    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?1...ll=1#post10190

    Edit: Also remove their map rotation.
    %HOME_PATH% >> %HOME_PATH%.callofduty2/
    http://sourceforge.net/p/hldstart/sv...nfigs/cod2.xml
    Last edited by Mitch; 30th January 2015 at 13:42.

  3. #3
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    I dont have root access, so I cant install it

  4. #4
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Ni3ls View Post
    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.

  5. #5
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    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).

    Code:
    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
    PHP Code:
    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 ! [ -./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) = ]; 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 --r $i -X quitdone
        
    echo "Service stopped!"
    }
    service_status()
    {
        
    path=~
        
    script=server.sh
        
    if [ ! -"$path/$script]; then
            
    echo "Service not configured!"
            
    return 0
        fi

        
    if [ $(count_services) = ]; 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:

    Code:
    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!
    timescale 0.01

  6. The Following User Says Thank You to kung foo man For This Useful Post:

    Ni3ls (31st January 2015)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •