Ich habe mal für Linux ein GTA Startscript geschrieben man benutzt es so
./start.sh {start|stop|restart|status}
je nachdem was man dann mit dem Server machen will.
Falls jemand einen Fehler findet bitte diesen mir mitteilen, werde diesen dann umgehend beheben, bis jetzt funktioniert das Script ganz anständig
Code
COMMANDLINE_PARAMETERS=""
BINARYPATH="."
cd "${BINARYPATH}"
LIBRARYPATH="$(pwd)"
BINARYNAME="samp03svr"
case "$1" in
start)
if [ -e gtaserver.pid ]; then
if ( kill -0 $(cat gtaserver.pid) 2> /dev/null ); then
echo "The server is already running, try restart or stop"
exit 1
else
echo "gtaserver.pid found, but no server running. Possibly your previously started server crashed"
echo "Please view the logfile for details."
rm gtaserver.pid
fi
fi
if [ "${UID}" = "0" ]; then
echo WARNING ! For security reasons we advise: DO NOT RUN THE SERVER AS ROOT
for c in $(seq 1 10); do
echo -n "!"
sleep 1
done
echo "!"
fi
echo "Starting the GTA server"
if [ -e "$BINARYNAME" ]; then
if [ ! -x "$BINARYNAME" ]; then
echo "${BINARYNAME} is not executable, trying to set it"
chmod u+x "${BINARYNAME}"
fi
if [ -x "$BINARYNAME" ]; then
export LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}"
"./${BINARYNAME}" ${COMMANDLINE_PARAMETERS} > /dev/null &
echo $! > gtaserver.pid
echo "GTA server started, for details please view the log file"
else
echo "${BINARNAME} is not exectuable, cannot start GTA server"
fi
else
echo "Could not find binaryname (samp03svr, aborting"
exit 5
fi
;;
stop)
if [ -e gtaserver.pid ]; then
echo -n "Stopping the GTA server"
if ( kill -TERM $(cat gtaserver.pid) 2> /dev/null ); then
for c in $(seq 1 300); do
if ( kill -0 $(cat gtaserver.pid) 2> /dev/null ); then
echo -n "."
sleep 1
else
break
fi
done
fi
if ( kill -0 $(cat gtaserver.pid) 2> /dev/null ); then
echo "Server is not shutting down cleanly - killing"
kill -KILL $(cat gtaserver.pid)
else
echo "done"
fi
rm gtaserver.pid
else
echo "No server runing (gtaserver.pid is missing)"
exit 7
fi
;;
restart)
$0 stop && $0 start || exit 1
;;
status)
if [ -e gtaserver.pid ]; then
if ( kill -0 $(cat gtaserver.pid) 2> /dev/null ); then
echo "Server is running"
else
echo "Server seems to have died"
fi
else
echo "No server running (gtaserver.pid is missing)"
fi
;;
*)
echo "Usage: ${0} {start|stop|restart|status}"
exit 2
esac
exit 0
Alles anzeigen