Skip to main content
Topic: autossh and supervise-daemon (Read 766 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

autossh and supervise-daemon

I cobbled together a service script to start autossh, with the help of what I found on the net.
Code: [Select]
#!/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:
Code: [Select]
#!/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
Quote
.
.
.
[ ok ]
 * Executing: /usr/lib/openrc/sh/openrc-run.sh /usr/lib/openrc/sh/openrc-run.sh /etc/init.d/autossh-sup start
 * Starting autossh-sup ...
 * supervise-daemon: fopen `/var/run/supervise-autossh-sup.pid': No such file or directory
 * Detaching to start `/usr/bin/autossh'
 [ ok ]
 * Executing: /usr/lib/openrc/sh/openrc-run.sh /usr/lib/openrc/sh/openrc-run.sh /etc/init.d/cronie start
 * Starting cronie ...
 * supervise-daemon: fopen `/var/run/supervise-cronie.pid': No such file or directory
 * Detaching to start `/usr/bin/crond'
 [ ok ]
.
.
.

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 ?