gamecp

Discutii despre tot ce nu se incadreaza in celelalte categorii.

Moderators: Moderatori ajutatori, Moderatori

Clint
Membru, skill +2
Membru, skill +2
Posts: 550
Joined: 31 Mar 2013, 15:18
Detinator Steam: Da
Has thanked: 35 times
Been thanked: 21 times

01 Jan 2014, 21:32

Adauga user cu comanda:

Code: Select all

adduser username
* Unde username este numele de la user.

Te loghezi ca user dupa care creezi un script ex: script.sh

Code: Select all

nano script.sh
* Poti folosi acest script, sa faci unele modificari dupa datele tale.
script | Afiseaza codul
#!/bin/sh

# Server configuration
GAME='CS16 Server'
HRUN='hlds_run'
RUN='hlds_run -console +servercfgfile server.cfg -game cstrike -debug +maxplayers 32 +map de_dust2 +port 27015' #Start command
CMD='hlds_i686'

start()
{
    if pgrep -u $USER -f $CMD > /dev/null;then
     echo "[ WARNING! ] Server is currently running!"
     sleep 1
     echo "[ info ] Use: {stop|restart|status}"
     else
     cd $HOME
     echo "Starting the $GAME Server..."
     taskset -c 0 screen -A -m -d -S $USER ./$RUN
     sleep 6
fi
}

stop()
{
    if pgrep -u $USER -f $CMD > /dev/null;then
     echo "Stopping $GAME Server..."
     kill $(pgrep -u $USER -f $HRUN)
     sleep 3
     echo "Done. Service stop!"
     else
     echo "[ WARNING! ] Server is not running!"
  fi
}

status()
{
    if pgrep -u $USER -f $CMD > /dev/null;then
      echo "[ Online ] Server is currently running!"
      else
      echo "[ Offline ] Server seems to have died"
     fi
}

console()
{
    if pgrep -u $USER -f $HRUN > /dev/null;clear
       then
       echo "$USER Connecting to $HOSTNAME"
       echo " For exit from console press Ctrl + A,D"
       echo " Dont press Ctrl+C"
       echo " Please wait..."
       sleep 3
       while true; do
       read -p "Please press [Y/n]: to connect console (y=yes,n=no): " yn
       case $yn in
       [Yy]* ) screen -d -r $(pgrep -u $USER -f "SCREEN -A -m -d -S $USER ./$HRUN");echo "Exit success, screen";exit;;
       [Nn]* ) echo "Abort.";exit;;
       * ) echo "Please answer yes or no!";;
       esac
       done
       else
       echo "[ Offline ] Server seems to have died"
   fi
}

case "$1" in
     start)
      start
        ;;
      stop)
      stop
        ;;
      restart)
      stop
      sleep 1
      start
        ;;
      status)
      status
        ;;
      console)
      console
        ;;
        *)
        echo "[ info ] Use: {start|stop|restart|status|console}"
        ;;
     esac
Il faci executabil:

Code: Select all

chmod 777 script.sh
Pentru comenzi folosesti ./script.sh start (pentru start)

Have fun :)>-
Stay chill.
RoyalServer 2
User avatar
pcpalex
Membru, skill 0
Membru, skill 0
Posts: 39
Joined: 12 Aug 2011, 18:31
Detinator Steam: Da
CS Status: Help the Needy
Detinator server CS: Da
Been thanked: 4 times
Contact:

02 Jan 2014, 03:11

Te ajut eu contra cost bineinteles, daca esti interesat,pm.
Post Reply

Return to “Discutii generale”

  • Information