From 4f2d7949f03e1c198bc888f2d05f421d35c57e21 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Mon, 9 Oct 2017 18:53:29 +0100 Subject: reinit the tree, so we can have metadata --- www-misc/shellinabox/files/shellinaboxd.init | 63 ++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 www-misc/shellinabox/files/shellinaboxd.init (limited to 'www-misc/shellinabox/files/shellinaboxd.init') diff --git a/www-misc/shellinabox/files/shellinaboxd.init b/www-misc/shellinabox/files/shellinaboxd.init new file mode 100644 index 000000000000..657a137a5c6b --- /dev/null +++ b/www-misc/shellinabox/files/shellinaboxd.init @@ -0,0 +1,63 @@ +#!/sbin/openrc-run +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +my_daemon="shellinaboxd" +pidfile="/var/run/${my_daemon}.pid" +command="/usr/sbin/${my_daemon}" +command_args="${SIAB_OPTS}" + +depend() { + use net +} + +start_pre() { + function my_join() { local IFS="${1}"; shift; echo "$*"; } + + if [[ -n ${SIAB_CSS_DIR} ]]; then + # This code searches SIAB_CSS_DIR for CSS files + # and formats the --user-css option accordingly. + local CSS_FILES=( "${SIAB_CSS_DIR}"/*.css ) + local SIAB_CSS_FILES=() + + # Try to keep environment pollution low. + local _CSS _BASE _NAME + + for _CSS in "${CSS_FILES[@]}"; do + _BASE="$(basename ${_CSS})" + _NAME="${_BASE%%\.css}" + _NAME="${_NAME//-/_}" + _NAME="${_NAME^}" + # These are the default style sheets. Don't load them. + [[ ${_NAME} =~ ^(Print|Styles).*? ]] && continue + SIAB_CSS_FILES+=("\"${_NAME}\":-${_CSS}") + done + + # The 1st one, which the default one, must be turned on using a + sign. + SIAB_CSS_FILES[0]=$(sed 's#:-#:+#' <<< ${SIAB_CSS_FILES[0]}) + + command_args="${command_args} --user-css=$(my_join , "${SIAB_CSS_FILES[@]}")" + fi + + return 0 +} + +start() { + ebegin "Starting ${my_daemon}" + start-stop-daemon \ + --start \ + --background \ + --pidfile ${pidfile} \ + --make-pidfile \ + --exec ${command} \ + -- ${command_args} + eend $? +} + +stop() { + ebegin "Stopping ${my_daemon}" + start-stop-daemon \ + --stop \ + --pidfile ${pidfile} + eend $? +} -- cgit v1.2.3