autossh and supervise-daemon
I cobbled together a service script to start autossh, with the help of what I found on the net.
#!/sbin/openrc-run
name=$RC_SVCNAME
command="/usr/bin/autossh"
pidfile="/run/${RC_SVCNAME}.pid"
AUTOSSH_LOGFILE="${AUTOSSH_LOGFILE:-/var/log/${RC_SVCNAME}.log}"
start_stop_daemon_args="-e AUTOSSH_PIDFILE=\"${pidfile}\" -e AUTOSSH_LOGFILE=\"${AUTOSSH_LOGFILE}\""
command_args="-f -M0 -N -i /root/.ssh/id_ed25519 -D 8080 root@tunnel"
depend() {
after net
}
This works whether at boot if in default runlevel, or when started and stopped manually.
Then I modified it to use supervise-daemon. The tunnel is basically what I do my web browsing through. So it would be nice if it restarts automatically if ever it goes down.
Came up with:
#!/sbin/openrc-run
name=$RC_SVCNAME
command="/usr/bin/autossh"
supervisor="supervise-daemon"
AUTOSSH_LOGFILE="${AUTOSSH_LOGFILE:-/var/log/${RC_SVCNAME}.log}"
command_args=" -M0 -N -D 8080 root@tunnel"
depend() {
after net
}
This works if starting manually but does not if in default runlevel ?
rc.log does not give anything away
I've tried need net instead of after net. I've tried after local to put it right at the the end.
But no joy. autossh does not appear to start at all. Its log file not added to. Run from the terminal it works fine ?
Anyone know the answer or any ideas ?