| 1 | #!/sbin/openrc-run |
| 2 | # Copyright 1999-2017 Gentoo Foundation |
| 3 | # Distributed under the terms of the GNU General Public License v2 |
| 4 | |
| 5 | extra_started_commands="reload" |
| 6 | |
| 7 | checkconfig() { |
| 8 | export MOTION_RUN_DIR="${MOTION_RUN_DIR:-/var/run/motion}" |
| 9 | checkpath -d -m 750 -o "${MOTION_USER:-motion}:${MOTION_GROUP:-video}" "${MOTION_RUN_DIR}" |
| 10 | export MOTION_LIB_DIR="${MOTION_LIB_DIR:-/var/lib/motion}" |
| 11 | checkpath -d -m 750 -o "${MOTION_USER:-motion}:${MOTION_GROUP:-video}" "${MOTION_LIB_DIR}" |
| 12 | return 0 |
| 13 | } |
| 14 | |
| 15 | start() { |
| 16 | checkconfig || return 1 |
| 17 | |
| 18 | ebegin "Starting motion detection" |
| 19 | start-stop-daemon --start -u "${MOTION_USER}" -g "${MOTION_GROUP}" -d "${MOTION_LIB_DIR}" --quiet --exec /usr/bin/motion -- -b -p "${MOTION_RUN_DIR}/motion.pid" |
| 20 | eend $? |
| 21 | } |
| 22 | |
| 23 | stop() { |
| 24 | checkconfig || return 1 |
| 25 | |
| 26 | ebegin "Stopping motion detection" |
| 27 | start-stop-daemon --stop --quiet --exec /usr/bin/motion --pidfile "${MOTION_RUN_DIR}/motion.pid" |
| 28 | eend $? |
| 29 | } |
| 30 | |
| 31 | reload() { |
| 32 | checkconfig || return 1 |
| 33 | |
| 34 | ebegin "Reloading motion detection configuration" |
| 35 | start-stop-daemon --stop --signal HUP --exec /usr/bin/motion --pidfile "${MOTION_RUN_DIR}/motion.pid" |
| 36 | eend $? |
| 37 | } |