Jump to content

[Linux]-[MTA-SA start/stop script]


Guest raging_bull

Recommended Posts

I made a start/stop/restart script for mta server for linux only! You will need package screen for this script!! apt-get install screen

mta_sa

#!/bin/sh
# MTA San Andreas Script by Raging_Bull-NL
# 27/01/2006 pwnt

PATH=/bin:/usr/bin:/sbin:/usr/sbin

# Edit if you like 
DESC="MTA San Andreas Dedicated Server" # Description
DIR="/home/cstrike/mta_sa/" # Install directory of mta_sa.
NAME="mtasa" # name used for screen running the server
PARAMS="" # parameters (maybe usefull for future 
DAEMON="$DIR/startserver" # Daemon
# Stop editing right now!

case "$1" in
start)
  echo "Starting $DESC: $NAME"
  if [ -e $DIR ];
  then
   cd $DIR
   screen -d -m -S $NAME $DAEMON $PARAMS
  else echo "No such directory: $DIR!"
  fi
  ;;

stop)
  if [[ `screen -ls |grep $NAME` ]]
  then
      echo -n "Stopping $DESC: $NAME"
      kill `screen -ls |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
      echo " ... done."
  else
      echo "Coulnd't find a running $DESC"
  fi
  ;;

restart)
  $0 stop
  $0 start
  ;;

 *)
  echo "Usage: $0 {start|stop|restart}"
  exit 1
  ;;
esac

exit

You may need to change

DAEMON="$DIR/startserver" # Daemon

because on some servers you don´t need the startserver script.

startserver

#!/bin/bash

export LD_LIBRARY_PATH=/usr/local/lib
./mta_server

Well here is the fun part! You don´t need anymore to switch to another console by ctrl-alt-F1/4. Just do screen -x mtasa in you console and the server screen will popup. Ohw yea, you can start your server by doing /etc/init.d/mta_sa start

Ohw, and don´t forget to edit the paramters in the script!

Edited by Guest
Link to comment
Nice one, someone should sticky this or put it somewhere prominent (providing it works of course)

Yea, sticky would be nice.. and it works offcourse! I use it myself!

Link to comment
DIR="/home/cstrike/mta_sa/" # Install directory of srcds.

You ripped it from the srcds startscript didn't you? I did the same for mine, except I also have a script which checks every 10 seconds if the server is running, and if not, it starts it up again ;)

Link to comment
DIR="/home/cstrike/mta_sa/" # Install directory of srcds.

You ripped it from the srcds startscript didn't you? I did the same for mine, except I also have a script which checks every 10 seconds if the server is running, and if not, it starts it up again ;)

Yea, i did... But so what? It is working! :P

Link to comment
  • 2 months later...
Just do screen -x mtasa in you console and the server screen will popup.

Awesome! now, how do I get out of it, without closing down the server?

Anyways,wouldn't it be easier if they just added a -d switch for deamon mode??

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...