make autossh fork properly
This commit is contained in:
parent
50685a8bc7
commit
7b99c89edf
2 changed files with 11 additions and 7 deletions
|
@ -19,13 +19,16 @@ DESC="autossh"
|
||||||
NAME=autossh
|
NAME=autossh
|
||||||
USER=$NAME
|
USER=$NAME
|
||||||
DAEMON=/usr/bin/autossh
|
DAEMON=/usr/bin/autossh
|
||||||
DAEMON_ARGS=""
|
DAEMON_ARGS="-f"
|
||||||
PIDFILE=/var/run/$NAME.pid
|
PIDFILE=/var/run/$NAME.pid
|
||||||
SCRIPTNAME=/etc/init.d/$NAME
|
SCRIPTNAME=/etc/init.d/$NAME
|
||||||
|
|
||||||
# Read configuration variable file if it is present
|
# Read configuration variable file if it is present
|
||||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||||
|
|
||||||
|
AUTOSSH_PIDFILE=$PIDFILE
|
||||||
|
export AUTOSSH_PIDFILE
|
||||||
|
|
||||||
# Exit if the package is not installed
|
# Exit if the package is not installed
|
||||||
[ -x "$DAEMON" ] || exit 0
|
[ -x "$DAEMON" ] || exit 0
|
||||||
|
|
||||||
|
@ -46,9 +49,9 @@ do_start()
|
||||||
# 0 if daemon has been started
|
# 0 if daemon has been started
|
||||||
# 1 if daemon was already running
|
# 1 if daemon was already running
|
||||||
# 2 if daemon could not be started
|
# 2 if daemon could not be started
|
||||||
start-stop-daemon --start --quiet --background --user $USER --pidfile $PIDFILE --makepidfile --exec $DAEMON --test > /dev/null \
|
start-stop-daemon --start --quiet --user $USER --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
||||||
|| return 1
|
|| return 1
|
||||||
start-stop-daemon --start --quiet --background --user $USER --chuid $USER --pidfile $PIDFILE --makepidfile --exec $DAEMON -- \
|
start-stop-daemon --start --quiet --user $USER --chuid $USER --pidfile $PIDFILE --exec $DAEMON -- \
|
||||||
$DAEMON_ARGS \
|
$DAEMON_ARGS \
|
||||||
|| return 2
|
|| return 2
|
||||||
# The above code will not work for interpreted scripts, use the next
|
# The above code will not work for interpreted scripts, use the next
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
class sshd::autossh($host,
|
class sshd::autossh($host,
|
||||||
$port = undef, # this should be a remote->local hash
|
$port = undef, # this should be a remote->local hash
|
||||||
$remote_user = undef,
|
$remote_user = undef,
|
||||||
$user = 'root',
|
$user = 'root',
|
||||||
|
$pidfile = '/var/run/autossh.pid',
|
||||||
) {
|
) {
|
||||||
if $port {
|
if $port {
|
||||||
$port_ensure = $port
|
$port_ensure = $port
|
||||||
|
@ -22,7 +23,7 @@ class sshd::autossh($host,
|
||||||
source => 'puppet:///modules/sshd/autossh.init.d';
|
source => 'puppet:///modules/sshd/autossh.init.d';
|
||||||
'/etc/default/autossh':
|
'/etc/default/autossh':
|
||||||
mode => '0444',
|
mode => '0444',
|
||||||
content => "USER=$user\nDAEMON_ARGS='-o ServerAliveInterval=15 -o ServerAliveCountMax=4 -q -N -R $port_ensure:localhost:22 $remote_user_ensure@$host'\n";
|
content => "USER=$user\nPIDFILE=$pidfile\nDAEMON_ARGS='-f -o ServerAliveInterval=15 -o ServerAliveCountMax=4 -q -N -R $port_ensure:localhost:22 $remote_user_ensure@$host'\n";
|
||||||
}
|
}
|
||||||
package { 'autossh':
|
package { 'autossh':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
|
|
Loading…
Reference in a new issue