diff --git a/README.rst b/README.rst index f591d7b..63c6b95 100644 --- a/README.rst +++ b/README.rst @@ -27,3 +27,8 @@ capability on the resulting binary: setcap 'cap_net_bind_service=+ep' go-sshd +Init script +=========== + +There is an init script for gentoo/alpine (OpenRC) users. SSHD_LISTEN needs to +be set in /etc/conf.d/go-sshd and the init-script goes in /etc/init.d/go-sshd diff --git a/alpine/go-sshd b/alpine/go-sshd new file mode 120000 index 0000000..761b642 --- /dev/null +++ b/alpine/go-sshd @@ -0,0 +1 @@ +gentoo/go-sshd \ No newline at end of file diff --git a/gentoo/go-sshd b/gentoo/go-sshd new file mode 100644 index 0000000..3a717eb --- /dev/null +++ b/gentoo/go-sshd @@ -0,0 +1,39 @@ +#!/sbin/openrc-run +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Go Secure Shell server" +description_reload="Reload configuration" + +extra_started_commands="reload" + +: ${SSHD_PIDFILE:=/run/${SVCNAME}.pid} +: ${SSHD_BINARY:=/usr/local/bin/go-sshd} +: ${SSHD_LISTEN:="-listenaddr :1 -listenport 8822"} +: ${SSHD_LOG:="/var/log/mcs/${SVCNAME}"} + +start() { + ebegin "Starting ${SVCNAME}" + start-stop-daemon --start --exec "${SSHD_BINARY}" \ + --make-pidfile --pidfile "${SSHD_PIDFILE}" \ + --background \ + --user ${SSHD_USER} --group ${SSHD_GROUP} \ + --stderr "${SSHD_LOG}" \ + -- ${SSHD_OPTS} ${SSHD_LISTEN} -hostkey /etc/go-sshd/tunnel \ + -authorisedkeys /etc/go-sshd/authorized_keys + eend $? +} + +stop() { + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --stop --exec "${SSHD_BINARY}" \ + --pidfile "${SSHD_PIDFILE}" --quiet + eend $? +} + +reload() { + ebegin "Reloading ${SVCNAME}" + start-stop-daemon --signal USR1 \ + --exec "${SSHD_BINARY}" --pidfile "${SSHD_PIDFILE}" + eend $? +}