Daemonize program into screen

Aim is to have program running inside screen restored on each machine reboot.

/etc/init.d/ctf
#! /bin/sh
### BEGIN INIT INFO
# Provides:          ctf
# Required-Start:    $local_fs $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Start warzone virtual
# Description:       start warzone virtual
### END INIT INFO
 
NAME=ctf
PIDFILE=/var/run/$NAME.pid
 
case "$1" in
  start)
        logger poustim warzone rc skript
        start-stop-daemon --start -v -b  --pidfile $PIDFILE -x /bin/su \
           -m --chdir /home/ctf -- - ctf \
           -c "/usr/bin/screen -L -dmS ctf -c /home/ctf/.screenrc-ctf" \
                || return 2
 
        ;;
  stop|restart|force-reload)
        # No-op
        ;;
  status)
        # No-op
        ;;
  *)
        echo "Usage: $NAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac
update-rc.d ctf defaults
update-rc.d ctf enable
/home/ctf/.screenrc-ctf
autodetach on
startup_message off
 
screen -t ctf 0 sh -c 'cd /home/ctf; ./run2'
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki