diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
commit | 4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch) | |
tree | ba5f07bf3f9d22d82e54a462313f5d244036c768 /www-misc/shellinabox/files/shellinaboxd.init |
reinit the tree, so we can have metadata
Diffstat (limited to 'www-misc/shellinabox/files/shellinaboxd.init')
-rw-r--r-- | www-misc/shellinabox/files/shellinaboxd.init | 63 |
1 files changed, 63 insertions, 0 deletions
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 $? +} |