Screen process

Od HLDS.pl
Skocz do: nawigacji, wyszukiwania

Beszczelnie zajebalem kod Anubisa, z malymi przerobkami, nie testowany ;)

#! /bin/bash
# Copyright (c) 2009 Anubis, http://g4g.pl
 
NAME=Game_Server_1
EXECUTABLE=./game_server
PARAMS="+set dedicated 2 +set net_ip 192.168.1. +set net_port 27733 +set sv_punkbuster 1 +set fs_homepath /path/to/server/ +exec server.cfg +map_rotate"
DIR=/path/to/server/
 
 
case "$1" in
    start)
        if [[ `screen -ls |grep $NAME` ]]
        then
            echo "Error: $NAME is already running, use '$0 stop' to stop it"
        else
            cd $DIR
            screen -dmS $NAME $EXECUTABLE $PARAMS
            echo "$NAME was started."
        fi
    ;;
    stop)
        if [[ `screen -ls |grep $NAME` ]]
        then
            kill `screen -ls |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
            echo "$NAME was stopped"
        else
            echo "Error: $NAME isn't currently running"
        fi
    ;;
    restart)
        if [[ `screen -ls |grep $NAME` ]]
        then
            kill `screen -ls |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
        fi
        cd $DIR
        screen -dmS $NAME $EXECUTABLE $PARAMS
        echo "$NAME was restarted"
    ;;    
    status)
        if [[ `screen -ls |grep $NAME` ]]
        then
            echo "$NAME is currently running"
        else
            echo "$NAME is NOT running"
        fi
    ;;
    *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
esac
exit 0
Osobiste
Przestrzenie nazw
Warianty
Działania
HLDS.pl - Menu:
Inne
IRC
Inne sekcje:
Znajomi:
Narzędzia