summarylogtreecommitdiffstats
path: root/initscript_openrc
blob: 666d6fe88fe7ac904df358f8d304a60bf9aae7b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/openrc-run
# OpenRC wwwoffle script

## The controlling environment variable should be set within /etc/conf.d/wwwoffle!

_DAEMON="/usr/sbin/wwwoffled"
_DAEMON_ARGS=(
              -c "${WWWOFFLE_CONFIG_FILE}"
              ${WWWOFFLED_EXTRA_ARGS}
             )

extra_started_commands="reload status"

depend() {
  use logger dns
}

_check_conf_file_var() {
  if [ -z "${WWWOFFLE_CONFIG_FILE}" ]; then
    eerror "Variable 'WWWOFFLE_CONFIG_FILE' not set or empty in '/etc/conf.d/wwwoffle'".
    eerror "This variable needs to be set to the configuration file to use."
    return 1
  fi
}

start() {
  ebegin "Starting $(basename "${_DAEMON}"): Executing ${_DAEMON} ${_DAEMON_ARGS[@]}"
  _check_conf_file_var && start-stop-daemon --start --exec "${_DAEMON}" -- "${_DAEMON_ARGS[@]}"
  eend "$?"
}

stop() {
  ebegin "Stopping $(basename "${_DAEMON}")"
  start-stop-daemon --stop --exec "${_DAEMON}"
  eend "$?"
}

reload() {
  ebegin "Re-reading configuration file for $(basename "${_DAEMON}")"
  _check_conf_file_var && wwwoffle -c "${WWWOFFLE_CONFIG_FILE}" -config
  eend "$?"
}

status() {
  ebegin "Querying status of $(basename "${_DAEMON}")"
  _check_conf_file_var && wwwoffle -c "${WWWOFFLE_CONFIG_FILE}" -status
  eend "$?"
}