I'm trying to get a Bukkit server to run inside a screen as a service, started from an LSB script but I cant get it to stop correctly. What I essentially want it to do is reattach the screen and send a 'stop' command to the server console so it saves everything instead of just being killed, but 'sudo service bukkit stop' doesn't seem to do anything with my script.
It still seems to stop if I reattach the screen in a terminal and type 'stop' to the Bukkit console.
Anyone know what the problem is? My init.d script is below...
#!/bin/bash ### BEGIN INIT INFO # Provides: scriptname # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start daemon at boot time # Description: Enable service provided by daemon. ### END INIT INFO cd /etc/minecraftbukkit case $1 in start) # Checked the PID file exists and check the actual status of process if [ -e $PIDFILE ]; then status_of_proc -p $PIDFILE $DAEMON "$NAME process" && status="0" || status="$?" # If the status is SUCCESS then don't need to start again. if [ $status = "0" ]; then exit # Exit fi fi # Start the daemon. screen -d -A -m -S "Bukkit152" sh ./bukkitrunner.sh ;; stop) # Stop the daemon. screen -d -r "Bukkit152" sleep 2 stop ;; *) esac
screenthe shell loses control so yourstopdoesn't get sent to screen. You could try redirection, but screen is a pain to automate.tmuxmight be easier.