aboutsummaryrefslogtreecommitdiffstats
path: root/community/tinyssh/tinyssh.initd
diff options
context:
space:
mode:
authorStuart Cardall <developer@it-offshore.co.uk>2017-07-02 02:08:04 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2017-07-13 23:30:55 +0000
commit0719889eb4798c3fd096ab991e38d125b2e77347 (patch)
treed3abc5138377c33c91da3f46ae745dcc7acf890c /community/tinyssh/tinyssh.initd
parent1a437ad05a75197edcbdc57bf1b03ffbd1c3d326 (diff)
downloadaports-0719889eb4798c3fd096ab991e38d125b2e77347.tar.bz2
aports-0719889eb4798c3fd096ab991e38d125b2e77347.tar.xz
community/tinyssh: modernise initd / use supervise-daemon
Diffstat (limited to 'community/tinyssh/tinyssh.initd')
-rw-r--r--community/tinyssh/tinyssh.initd58
1 files changed, 33 insertions, 25 deletions
diff --git a/community/tinyssh/tinyssh.initd b/community/tinyssh/tinyssh.initd
index 364ffb21c5..5671855176 100644
--- a/community/tinyssh/tinyssh.initd
+++ b/community/tinyssh/tinyssh.initd
@@ -1,43 +1,51 @@
#!/sbin/openrc-run
# Alpine Linux init.d for TinySSH
-# Copyright 2015 Stuart Cardall (developer@it-offshore.co.uk)
+# Copyright 2017 Stuart Cardall (https://github.com/itoffshore)
# Distributed under the terms of the GNU General Public License, v2 or later #
-name=tinysshd
-daemon=/usr/sbin/$name
+supervisor=supervise-daemon
+description="Small SSH server using NaCl (no dependency on OpenSSL)"
+
+nice="0"
+pidfile="/run/tinysshd.sd.pid"
+supervise_daemon_args=""
+
+daemon=/usr/sbin/tinysshd
keygen=$daemon-makekey
+
CONFDIR=${CONFDIR:-/etc/tinyssh}
keydir=${CONFDIR}/sshkeys
OPTIONS=${OPTIONS:-\-v -l}
PORT=${PORT:-22}
-pidfile=/var/run/$name.pid
-server_opts="-HRDl0 0.0.0.0 ${PORT} $daemon ${OPTIONS} $keydir"
+IP=${IP:-0.0.0.0}
+
+command="tcpserver"
+command_args="-HRDl0 ${IP} ${PORT} $daemon ${OPTIONS} $keydir"
+proxy_env=/etc/profile.d/proxy.sh
depend() {
- use net
- after logger firewall
+ use net
+ after logger firewall
+}
+
+in_contr() {
+ grep "container=" /proc/1/environ
}
-checkconfig() {
+start_pre() {
checkpath --directory ${CONFDIR}
eval $keygen $keydir 2>/dev/null
- # tinyssh also runs from inetd without tcpserver
- if [ ! -f /usr/bin/tcpserver ]; then
- apk add --quiet ucspi-tcp
- fi
-}
-start() {
- checkconfig
- ebegin "Starting ${name}"
- start-stop-daemon --start --make-pidfile --background --pidfile $pidfile \
- --exec tcpserver -- $server_opts
- eend $?
-}
+ if [ -z "$(in_contr)" ]; then
+ supervise_daemon_args="$supervise_daemon_args -N $nice"
+ fi
-stop() {
- ebegin "Stopping ${name}"
- start-stop-daemon --stop --quiet \
- --pidfile $pidfile
- eend $?
+ # tinyssh also runs from inetd without tcpserver
+ if [ ! -x /usr/bin/tcpserver ]; then
+ # openrc does not use proxy environment by default
+ if [ -f "$proxy_env" ]; then
+ . $proxy_env
+ fi
+ apk add ucspi-tcp6
+ fi
}