#!/sbin/openrc-run # Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 my_daemon="shellinaboxd" pidfile="/run/$my_daemon.pid" command="/usr/sbin/$my_daemon" command_args="$SIAB_OPTS" depend() { use net } start_pre() { local css label [ -z "$SIAB_CSS_DIR" ] && return # This code searches SIAB_CSS_DIR for CSS files # and formats the --user-css option accordingly. set -- for css in "$SIAB_CSS_DIR"/*.css; do test -e "$css" || continue label=${css##*/} label=${label%.css} case $label in # These are the default style sheets. Don't load them. print-styles|styles) ;; *) label=$( printf %s "$label" \ | awk '{ gsub("[:+,-]", "_"); print toupper(substr($0, 1, 1)) substr($0, 2); }' ) if [ $# -eq 0 ]; then set -- "$label:+$css" else set -- "$@" "$label:-$css" fi esac done if [ $# -gt 0 ]; then command_args="$command_args --user-css=\"$(IFS=,; printf %s "$*")\"" fi } start() { ebegin "Starting $my_daemon" printf %s "$command_args" \ | xargs -E '' start-stop-daemon \ --start \ --background \ --pidfile "$pidfile" \ --make-pidfile \ --exec "$command" \ -1 "$SIAB_LOGFILE" -2 "$SIAB_LOGFILE" \ -- eend $? } stop() { ebegin "Stopping $my_daemon" start-stop-daemon \ --stop \ --pidfile "$pidfile" eend $? }