私はTeamspeak Serverを自動起動するための標準的なbash-startupスクリプトを使用しました。これで、JTS3 Server Modの問題は解決しました。問題はjarファイルであり、起動しません。 jar/startscriptを手動で実行すると、うまく動作します。起動時にjarファイルを実行します。
ここではそれが更新-rc.dのjts3servermodデフォルトでランレベル・フォルダにリンクされて当然の/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
にスクリプトがあります。
servermodのstartscript(jts3servermod_startscript.sh)は次のとおりです。
#!/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
私はまた、唯一のjarファイルを起動するとPIDをキャッチし、それをファイルに書き込むため独自の簡単なスクリプトを記述してみました。 これらのスクリプトのいずれも、起動時に.jarファイルを開始しないようにしました。
ご覧のとおり、最初のスクリプトは、起動時にTeamspeak Serverを起動するためのテンプレートです。私はいくつかのものを私のServer Modのパスとスクリプトで置き換え、/etc/init.d/に入れました(chmod 755はもちろん実行されました)。
多分、あなたの中には、その奇妙な状況を解決するための他のアプローチがあります。事前にお手数をおかけしていただきありがとうございます。
敬具、 Tw1x
はあなたのcronを見上げると考えたことがありますか? – TuxForLife
cronを検索するとどういう意味ですか? crontab -eの出力?これは、両方のユーザーrootとts(スクリプトを開始するユーザー)には空です。 – Tw1x