Reply to Thread

Post a reply to the thread: [Linux] CoD4 server on SCREEN - /etc/init.d/startupscript

Your Message

Click here to log in

 
 

You may choose an icon for your message from this list

Additional Options

  • Will turn www.example.com into [URL]http://www.example.com[/URL].

Topic Review (Newest First)

  • 20th March 2017, 08:10 PM
    RoboCop

    [Linux] CoD4 server on SCREEN - /etc/init.d/startupscript

    Code:
    #########################################################
    # STARTSCRIPT FOR cod4 SERVERS #
    #########################################################
    # USE AT YOUR OWN RISK!!!!!!!!!!! #
    # SCREEN must be installed on your server! #
    #########################################################
    # Vars: #
    # G_USER Username #
    # NAME Screen-Name #
    # DESC Server-Description #
    # PARAMS Start-Parameters #
    # DIR HLDS Directory (absolut) #
    # SCRIPT Serverstart-Script #
    # DAEMON Daemon #
    #########################################################
    # OPTIONS: (start|stop|restart|status) #
    #########################################################
    
    
    ################## User ################################
    # Username of the Linux User running the CoD4 server
    # (do NOT use root)
    G_USER=dgc
    ################## Vars #################################
    # Screen NAME
    # Attach Screen : # screen -r NAME
    # Detach Screen : # [CTRL]+[A]; [D]
    # Don't press [CTRL]+[C] it will terminate screen
    NAME=toaster
    IP=87.106.166.40
    PORT=28960
    MAXCL=16
    PB=1
    ################## Server Description ###################
    # Single Word DESC=myserver
    # Multiple Words DESC="This is my Server"
    DESC="DGC cod4 Server"
    ################## Parameter ############################
    # CAN USE: +servercfgfile server.cfg OR +exec server.cfg
    PARAMS="+set dedicated 2 +set sv_punkbuster $PB +set net_ip $IP +set 
    net_port $PORT +set sv_maxclients $MAXCL +exec $NAME.cfg +set g_gametype 
    sd +map mp_vacant"
    ################## Directory ############################
    # Path to the cod4-Directory (absolute)
    DIR=/home/dgc/cod4
    ################## DAEMON ##############################
    # Name of the startup script and binary
    #SCRIPT=cod4_lnxded
    SCRIPT=cod4_lnxded
    BIN=cod4_lnxded-bin
    ########################################################
    #### Do NOT edit anything below this line! ! ! ####
    ########################################################
    
    
    DAEMON=$DIR/$SCRIPT
    
    
    case "$1" in
    start)
    if [[ `su $G_USER -c "screen -ls | grep $NAME"` ]]
    then
    echo "$DESC $NAME is already running!"
    else
    echo "Starting $DESC $NAME "
    su $G_USER -c "cd $DIR; screen -d -m -S $NAME $DAEMON $PARAMS"
    fi
    ;;
    
    
    stop)
    if [[ `su $G_USER -c "screen -ls | grep $NAME"` ]]
    then
    echo -n "Stopping $DESC $NAME "
    kill `ps aux | grep -i screen | grep -i $NAME | awk '{print $2}'`
    echo " ... done."
    else
    echo "No running $DESC $NAME was found!"
    fi
    ;;
    
    
    restart)
    if [[ `su $G_USER -c "screen -ls | grep $NAME"` ]]
    then
    echo -n "Stopping $DESC $NAME "
    kill `ps aux | grep -i screen | grep -i $NAME | awk '{print $2}'`
    echo " ... done."
    else
    echo "No running $DESC $NAME was found!"
    fi
    
    
    echo -n "Starting $DESC $NAME"
    su $G_USER -c "cd $DIR; screen -d -m -S $NAME $DAEMON $PARAMS"
    echo " ... done."
    ;;
    
    
    status)
    ps aux | grep -v grep | grep $BIN | grep $NAME > /dev/null
    CHECK=$?
    [ $CHECK -eq 0 ] && echo "$DESC $NAME is online" || echo "$DESC $NAME is 
    offline"
    ;;
    *)
    
    
    echo "Use: $0 {start|stop|restart|status}"
    exit 1
    ;;
    esac
    
    
    exit 0

    After starting you cod4 server with this script you have to "su" to the linux user which is running the server:
    su dgc -c "screen -r"


    gl Florian
    http://icculus.org/pipermail/cod/200...er/008993.html

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may post attachments
  • You may edit your posts
  •  
DMCA.com Protection Status

https://apg-clan.org tested by Norton Internet Security https://apg-clan.org tested by McAfee Internet Security

Flag Counter