Config and scripts to support two instances of sshd, one using automount
[pl_sshd.git] / pl_sshd.sh
1 #!/bin/sh
2 #
3 # this wrapper runs sshd on an alternate port with a different argv[0]
4 # and PID file (rather annoyingly, the latter has to be specified
5 # explicitly even if argv[0] is changed).
6 #
7 # the alternate port is necessary so we can have two instances of sshd
8 # running, the different name and PID file are required so that stopping
9 # the standard sshd won't affect this one.
10 #
11 # we use port 806 unless there is a '-p' argument specifying a different
12 # port.  we also have to specify a different PID file so that one sshd
13 # doesn't clobber the other's PID file.
14 #
15 # XXX - unfortunately the standard init.d/sshd script is fairly brutal
16 # when stopping sshd processes - it will stop anything that looks
17 # remotely like sshd.  the measures taken here still don't prevent that
18 # but i have decided that restarting/stopping sshd should be sufficiently
19 # rare that it's not worth worrying about to any greater extent.
20 #
21 name=pl_sshd
22 echo "$@" | grep -q -- '-p[ 0-9]' || port='-p 806'
23
24 exec -a $name /usr/sbin/sshd -o "PidFile /var/run/$name.pid" $port "$@"