summaryrefslogtreecommitdiff
blob: 4d7b43af585b072c36977911ed623eb58bd521e2 (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
49
#!/sbin/openrc-run
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

: ${MOTION_USER:="motion"}
: ${MOTION_GROUP:="motion"}

[ "${MOTION_UMASK}" ] && umask="${MOTION_UMASK}"
[ "${MOTION_CONFIGFILE}" ] && command_args="-c ${MOTION_CONFIGFILE}"
[ "${MOTION_LOGFILE}" ] && command_args="${command_args} -l ${MOTION_LOGFILE}"
[ "${MOTION_LOGTYPE}" ] && command_args="${command_args} -k ${MOTION_LOGTYPE}"
[ "${MOTION_LOGLEVEL}" ] && command_args="${command_args} -d ${MOTION_LOGLEVEL}"

command=/usr/bin/motion
command_user="${MOTION_USER}:${MOTION_GROUP}"
extra_started_commands="reload"
description_reload="Reread the config file"

start_pre() {
  if [ "${MOTION_DIR}" ] ; then
    checkpath -d -o "${MOTION_USER}":"${MOTION_GROUP}" "${MOTION_DIR}"
    directory="${MOTION_DIR}"
  fi
  if [ "${MOTION_LOGFILE}" ] ; then
    checkpath -f -o "${MOTION_USER}":"${MOTION_GROUP}" "${MOTION_LOGFILE}"
  fi
  if [ "${MOTION_PIDFILE}" ] ; then
    pidfile="${MOTION_PIDFILE}"
    command_background=true
  else
    supervisor=supervise-daemon
  fi
}

depend() {
  need localmount
  after bootmisc
  use mysql postgresq
}

reload() {
  ebegin "Reloading ${RC_SVCNAME}"
  if [ "${MOTION_PIDFILE}" ] ; then
    start-stop-daemon --signal SIGHUP --pidfile "${MOTION_PIDFILE}"
  else
    supervise-daemon ${RC_SVCNAME} --signal SIGHUP
  fi
  eend $?
}