Hello, thanks for the script. It did not work for me initially. I noticed that the PID file contained the wrong process ID. It had a '1' appended to the correct value.
I think the grep command you want is 'grep -w [0-9]*.$SCREEN' in the mc_start command. In other words, you should limit the grep match to a word boundary to avoid grabbing the superfluous '1' introduced by the subsequent output in screen. This fix works for me in Debian 7.
Here is the complete code block (ignore my debugging 'log' routines)
mc_start() {
log "mc_start: Attempting to Start the Service ..."
servicejar=$MCPATH/$SERVICE
log "mc_start: servicejar=${servicejar}"
if [ ! -f "$servicejar" ]
then
log "mc_start: Failed to start: Can't find the specified Minecraft jar under $servicejar. Please check your config!" "5"
exit 1
fi
pidfile=${MCPATH}/${SCREEN}.pid
log "pidfile=${pidfile}"
check_permissions
as_user "cd $MCPATH && screen -dmS $SCREEN $INVOCATION"
as_user "screen -list | grep -w [0-9]*"\.$SCREEN" | cut -f1 -d'.' | tr -d -c 0-9 > $pidfile"
#
# Waiting for the server to start
#
seconds=0
until is_running
do
sleep 1
seconds=$seconds+1
if [[ $seconds -eq 5 ]]
then
log "Still not running, waiting a while longer..." '5'
fi
if [[ $seconds -ge 120 ]]
then
log "Failed to start, aborting." '3'
exit 1
fi
done
echo "$SERVICE is running."
}
Hello, thanks for the script. It did not work for me initially. I noticed that the PID file contained the wrong process ID. It had a '1' appended to the correct value.
I think the grep command you want is 'grep -w [0-9]*.$SCREEN' in the mc_start command. In other words, you should limit the grep match to a word boundary to avoid grabbing the superfluous '1' introduced by the subsequent output in screen. This fix works for me in Debian 7.
Here is the complete code block (ignore my debugging 'log' routines)