Differences

This shows you the differences between two versions of the page.

Link to this comparison view

kb:daemonize_screen [2012/09/15 00:38] (current)
ruza created
Line 1: Line 1:
 +====== Daemonize program into screen ======
 +
 +Aim is to have program running inside screen restored on each machine reboot.
 +
 +<file bash /​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
 +</​file>​
 +
 +<code bash>
 +update-rc.d ctf defaults
 +update-rc.d ctf enable
 +</​code>​
 +
 +<file bash /​home/​ctf/​.screenrc-ctf>​
 +autodetach on
 +startup_message off
 +
 +screen -t ctf 0 sh -c 'cd /home/ctf; ./​run2'​
 +</​file>​
 +
  
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki