Ich habe ein Standard Bash-Startup-Skript zum Autostart meines Teamspeak Servers verwendet - was perfekt funktioniert. Nun habe ich das selbe für den JTS3 Server Mod gemacht, Problem: Es ist eine jar-Datei und startet nicht. Wenn ich das jar/startscript manuell ausführe, funktioniert es gut.jar-Datei beim Start ausführen linux
Hier ist das Skript in /etc/init.d/
#!/bin/bash
### BEGIN INIT INFO
# Provides: jts3servermod
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: JTS3 Server Mod
### END INIT INFO
# INIT Script by www.SysADMINsLife.com
######################################
# Customize values for your needs: "User"; "DIR"
USER="ts"
DIR="/home/ts/JTS3ServerMod"
###### Teamspeak 3 server start/stop script ######
case "$1" in
start)
su $USER -c "${DIR}/jts3servermod_startscript.sh start"
;;
stop)
su $USER -c "${DIR}/jts3servermod_startscript.sh stop"
;;
restart)
su $USER -c "${DIR}/jts3servermod_startscript.sh restart"
;;
status)
su $USER -c "${DIR}/jts3servermod_startscript.sh status"
;;
*)
echo "Usage: {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0
natürlich ist es in den Runlevel-Ordner mit update-rc.d JTS3ServerMod Vorgaben verknüpft ist.
die servermod Startscript (jts3servermod_startscript.sh) ist:
#!/bin/sh
# JTS3ServerMod Linux start script
# Created by Stefan "Stefan1200" Martens
# The author of this script is not responsible for any damage or data loss!
JAVA_COMMANDLINE_PARAMETERS="-mx30M" # You can add java arguments here, like the -mx30M argument!
JTS3SERVERMOD_COMMANDLINE_PARAMETERS="" # You can add JTS3ServerMod arguments here, like the -config and -log argument!
BINARYPATH="$(pwd)" # This have to point to the JTS3ServerMod directory!
# Don't change the lines below, if you are not a sh script expert!
cd "${BINARYPATH}"
BINARYNAME="JTS3ServerMod.jar"
ROOTUID="0"
case "$1" in
java)
if which java >/dev/null 2>&1 ; then
echo "Java is already installed:"
java -version
else
if [ "$(id -u)" -ne "$ROOTUID" ] ; then
echo "Start this script as root to start the automatic installation of the Java runtime environment."
echo "You can also read the system requirements of the JTS3ServerMod in the readme.txt file for a manual installation of the Java runtime environment."
exit 6
else
read -p "Do you wish to install the Java runtime environment? (y/n) " yn
case $yn in
[Yy]*) installJava; break;;
*) echo "Aborted!"; exit 6;;
esac
fi
fi
;;
start)
if ! which java >/dev/null 2>&1 ; then
echo "The JTS3ServerMod needs the Java runtime environment installed to run!"
echo "Start this script with the java argument as root to start the automatic installation of the Java runtime environment:"
echo "$0 java"
echo "You can also read the system requirements of the JTS3ServerMod in the readme.txt file for a manual installation of the Java runtime environment."
exit 6
fi
if [ "$(id -u)" -eq "$ROOTUID" ] ; then
echo "For security reasons it is prefered not to run the JTS3ServerMod as root!"
fi
if [ -e jts3servermod.pid ]; then
if (kill -0 $(cat jts3servermod.pid) 2> /dev/null); then
echo "The JTS3ServerMod is already running, try restart or stop!"
exit 1
else
echo "jts3servermod.pid found, but no JTS3ServerMod running. Possibly your previously started JTS3ServerMod crashed!"
echo "Please view the logfile for details."
rm -f jts3servermod.pid
fi
fi
echo "Starting the JTS3ServerMod..."
if [ -e "$BINARYNAME" ]; then
java ${JAVA_COMMANDLINE_PARAMETERS} -jar ${BINARYNAME} ${JTS3SERVERMOD_COMMANDLINE_PARAMETERS} > /dev/null &
PID=$!
ps -p ${PID} > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "JTS3ServerMod could not start!"
else
echo $PID > jts3servermod.pid
echo "JTS3ServerMod started, for details please view the log file!"
fi
else
echo "Could not find the file $BINARYNAME, aborting!"
exit 5
fi
;;
stop)
if [ -e jts3servermod.pid ]; then
echo -n "Stopping the JTS3ServerMod.."
if (kill -TERM $(cat jts3servermod.pid) 2> /dev/null); then
c=1
while [ "$c" -le 120 ]; do
if (kill -0 $(cat jts3servermod.pid) 2> /dev/null); then
echo -n "."
sleep 1
else
break
fi
c=$(($c+1))
done
fi
if (kill -0 $(cat jts3servermod.pid) 2> /dev/null); then
echo "JTS3ServerMod is not shutting down cleanly - killing!"
kill -KILL $(cat jts3servermod.pid)
else
echo "done"
fi
rm -f jts3servermod.pid
else
echo "No JTS3ServerMod running (jts3servermod.pid is missing)!"
exit 7
fi
;;
restart)
$0 stop && $0 start || exit 1
;;
status)
if [ -e jts3servermod.pid ]; then
if (kill -0 $(cat jts3servermod.pid) 2> /dev/null); then
echo "JTS3ServerMod is running!"
else
echo "JTS3ServerMod seems to have died!"
fi
else
echo "No JTS3ServerMod running (jts3servermod.pid is missing)!"
fi
;;
*)
echo "Usage: ${0} {start|stop|restart|status|java}"
exit 2
esac
exit 0
Ich habe versucht, auch für ein eigenes einfaches Skript schreiben nur das Glas beginnt und die pid fangen und in eine Datei schreiben. Keines dieser Skripts wollte meine .jar-Datei während des Startvorgangs starten.
Wie Sie sehen, ist das erste Skript eine Vorlage zum Starten von Teamspeak Servern während des Bootens. Ich habe nur ein paar Sachen durch meine Server Mod Pfade und Skripte ersetzt und in /etc/init.d/ abgelegt (chmod 755 wurde natürlich ausgeführt).
Vielleicht haben einige von Ihnen andere Ansätze, um diese seltsamen Umstände zu lösen. Vielen Dank für Ihre Hilfe im Voraus!
Mit freundlichen Grüßen, Tw1x
Haben Sie cron aufzublicken in Betracht gezogen? – TuxForLife
Was meinst du mit Cron nachschlagen? Die Ausgabe von Crontab -e? Es ist leer, sowohl bei Benutzern als auch bei root und ts (der Benutzer, der das Skript startet). – Tw1x