From 5a631b4caddad203c5fcaa2182ec40405e74989e Mon Sep 17 00:00:00 2001 From: Morris Zuss Date: May 20 2022 18:33:36 +0000 Subject: openssh-openrc --- diff --git a/nonsystemd/openssh-openrc/PKGBUILD b/nonsystemd/openssh-openrc/PKGBUILD new file mode 100644 index 0000000..97e22c4 --- /dev/null +++ b/nonsystemd/openssh-openrc/PKGBUILD @@ -0,0 +1,23 @@ +# Maintainer: artoo + +pkgname=openssh-openrc +pkgver=20220520 +pkgrel=1 +pkgrel+=.nonsystemd1 +pkgdesc="OpenRC openssh init script" +arch=('any') +url="https://github.com/artix-linux/packages" +license=('GPL2') +depends=('openrc' 'openssh') +optdepends=('bind-openrc: bind initscript') +conflicts=('systemd-sysvcompat') +backup=('etc/conf.d/sshd') +source=("sshd.confd" + "sshd.initd") +sha512sums=('400900b659b7a056e430e130425719db81df5efaa30eac37d4df7c01a21bdad59b74fc8b105607d357554e8647ffbf67fd220049b87af1db78045a9e94abade2' + '142949695f02598a4a0a3fb4bc1b3f4ddbec27e2babea1e895e12cc2d5fe58a30b7ee4b157f85f456f8051dbe22f3d389b0a605c54a34b5e43cb3925f1a4a7b6') + +package() { + install -Dm755 "${srcdir}"/sshd.initd "${pkgdir}"/etc/init.d/sshd + install -Dm644 "${srcdir}"/sshd.confd "${pkgdir}"/etc/conf.d/sshd +} diff --git a/nonsystemd/openssh-openrc/sshd.confd b/nonsystemd/openssh-openrc/sshd.confd new file mode 100644 index 0000000..996ac51 --- /dev/null +++ b/nonsystemd/openssh-openrc/sshd.confd @@ -0,0 +1,33 @@ +# /etc/conf.d/sshd: config file for /etc/init.d/sshd + +# Where is your sshd_config file stored? + +SSHD_CONFDIR="${RC_PREFIX%/}/etc/ssh" + + +# Any random options you want to pass to sshd. +# See the sshd(8) manpage for more info. + +SSHD_OPTS="" + + +# Wait one second (length chosen arbitrarily) to see if sshd actually +# creates a PID file, or if it crashes for some reason like not being +# able to bind to the address in ListenAddress. + +#SSHD_SSD_OPTS="--wait 1000" + + +# Pid file to use (needs to be absolute path). + +#SSHD_PIDFILE="${RC_PREFIX%/}/run/sshd.pid" + + +# Path to the sshd binary (needs to be absolute path). + +#SSHD_BINARY="${RC_PREFIX%/}/usr/bin/sshd" + + +# Path to the ssh-keygen binary (needs to be absolute path). + +#SSHD_KEYGEN_BINARY="${RC_PREFIX%/}/usr/bin/ssh-keygen" diff --git a/nonsystemd/openssh-openrc/sshd.initd b/nonsystemd/openssh-openrc/sshd.initd new file mode 100644 index 0000000..2d179e7 --- /dev/null +++ b/nonsystemd/openssh-openrc/sshd.initd @@ -0,0 +1,94 @@ +#!/usr/bin/openrc-run +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +extra_commands="checkconfig" +extra_started_commands="reload" + +: ${SSHD_CONFDIR:=${RC_PREFIX%/}/etc/ssh} +: ${SSHD_CONFIG:=${SSHD_CONFDIR}/sshd_config} +: ${SSHD_PIDFILE:=${RC_PREFIX%/}/run/${SVCNAME}.pid} +: ${SSHD_BINARY:=${RC_PREFIX%/}/usr/bin/sshd} +: ${SSHD_KEYGEN_BINARY:=${RC_PREFIX%/}/usr/bin/ssh-keygen} + +command="${SSHD_BINARY}" +# pidfile="${SSHD_PIDFILE}" +# command_args="${SSHD_OPTS} -o PidFile=${pidfile} -f ${SSHD_CONFIG}" +#command_args_background="-o PidFile=${pidfile}" +command_args="${SSHD_OPTS} -f ${SSHD_CONFIG}" +command_args_foreground="-D" +supervisor="supervise-daemon" + + +# Wait one second (length chosen arbitrarily) to see if sshd actually +# creates a PID file, or if it crashes for some reason like not being +# able to bind to the address in ListenAddress (bug 617596). +#: ${SSHD_SSD_OPTS:=--wait 1000} +start_stop_daemon_args="${SSHD_SSD_OPTS}" + +depend() { + # Entropy can be used by ssh-keygen, among other things, but + # is not strictly required (bug 470020). + use logger dns entropy + if [ "${rc_need+set}" = "set" ] ; then + : # Do nothing, the user has explicitly set rc_need + else + local x warn_addr + for x in $(awk '/^ListenAddress/{ print $2 }' "$SSHD_CONFIG" 2>/dev/null) ; do + case "${x}" in + 0.0.0.0|0.0.0.0:*) ;; + ::|\[::\]*) ;; + *) warn_addr="${warn_addr} ${x}" ;; + esac + done + if [ -n "${warn_addr}" ] ; then + need net + ewarn "You are binding an interface in ListenAddress statement in your sshd_config!" + ewarn "You must add rc_need=\"net.FOO\" to your ${RC_PREFIX%/}/etc/conf.d/sshd" + ewarn "where FOO is the interface(s) providing the following address(es):" + ewarn "${warn_addr}" + fi + fi +} + +checkconfig() { + checkpath --mode 0755 --directory "${RC_PREFIX%/}/var/empty" + + if [ ! -e "${SSHD_CONFIG}" ] ; then + eerror "You need an ${SSHD_CONFIG} file to run sshd" + eerror "There is a sample file in /usr/share/doc/openssh" + return 1 + fi + + ${SSHD_KEYGEN_BINARY} -A || return 2 + + "${command}" -t ${command_args} || return 3 +} + +start_pre() { + # Make sure that the user's config isn't busted before we try + # to start the daemon (this will produce better error messages + # than if we just try to start it blindly). + # + # We always need to call checkconfig because this function will + # also generate any missing host key and you can start a + # non-running service with "restart" argument. + checkconfig || return $? +} + +stop_pre() { + # If this is a restart, check to make sure the user's config + # isn't busted before we stop the running daemon. + if [ "${RC_CMD}" = "restart" ] ; then + checkconfig || return $? + fi +} + +reload() { + checkconfig || return $? + ebegin "Reloading ${SVCNAME}" + #start-stop-daemon --signal HUP --pidfile "${pidfile}" + ${supervisor} ${SVCNAME} --signal HUP --pidfile "${SSHD_PIDFILE}" + eend $? +} +