#!/sbin/openrc-run # Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 SOCKD_OPT="" [ "${SOCKD_FORKDEPTH:-1}" -gt 1 ] && SOCKD_OPT="${SOCKD_OPT} -N ${SOCKD_FORKDEPTH}" [ "${SOCKD_DEBUG:-0}" -eq 1 ] && SOCKD_OPT="${SOCKD_OPT} -d" [ "${SOCKD_DISABLE_KEEPALIVE:-0}" -eq 1 ] && SOCKD_OPT="${SOCKD_OPT} -n" SOCKDIR=/var/lock/dante-sockd/ pidfile=/var/run/dante-sockd/sockd.pid command=/usr/sbin/sockd command_args="-D -p \"${pidfile}\" ${SOCKD_OPT}" extra_commands="configtest" extra_started_commands="reload" depend() { need net } configtest() { # first check that it exists if [ ! -f /etc/socks/sockd.conf ] ; then eerror "You need to setup /etc/socks/sockd.conf first" eerror "Examples are in /usr/share/doc/dante[version]/example" eerror "for more info, see: man sockd.conf" return 1 fi /usr/sbin/sockd -V >/tmp/dante-sockd.checkconf 2>&1 if [ $? -ne 0 ]; then cat /tmp/dante-sockd.checkconf eerror "Something is wrong with your configuration file" eerror "for more info, see: man sockd.conf" return 1 fi rm /tmp/dante-sockd.checkconf return 0 } checkworkdir() { DAEMON_UID=`sed -e '/^[ \t]*user[.]unprivileged[ \t]*:/{s/.*:[ \t]*//;q};d' /etc/socks/sockd.conf` if [ -n "$DAEMON_UID" ]; then checkpath -d -o "${DAEMON_UID}" "${SOCKDIR}" checkpath -f "${SOCKDIR}/.keep" checkpath -d -o "${DAEMON_UID}" "$(dirname "${pidfile}")" fi } start_pre() { configtest || return 1 checkworkdir export TMPDIR="${SOCKDIR}" } reload() { configtest || return 1 ebegin "Reloading ${SVCNAME}" start-stop-daemon --signal SIGHUP --pidfile "${pidfile}" eend $? "Failed to reload ${SVCNAME}" }