mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-22 08:53:59 +01:00
added FreeBSD startup (rc.d) script
This commit is contained in:
Executable
+69
@@ -0,0 +1,69 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# PROVIDE: headphones
|
||||||
|
# REQUIRE: sabnzbd
|
||||||
|
# KEYWORD: shutdown
|
||||||
|
#
|
||||||
|
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
|
||||||
|
# to enable this service:
|
||||||
|
#
|
||||||
|
# headphones_enable (bool): Set to NO by default.
|
||||||
|
# Set it to YES to enable it.
|
||||||
|
# headphones_user: The user account Headphones daemon runs as what
|
||||||
|
# you want it to be. It uses '_sabnzbd' user by
|
||||||
|
# default. Do not sets it as empty or it will run
|
||||||
|
# as root.
|
||||||
|
# headphones_dir: Directory where Headphones lives.
|
||||||
|
# Default: /usr/local/headphones
|
||||||
|
# headphones_chdir: Change to this directory before running Headphones.
|
||||||
|
# Default is same as headphones_dir.
|
||||||
|
# headphones_pid: The name of the pidfile to create.
|
||||||
|
# Default is headphones.pid in headphones_dir.
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name="headphones"
|
||||||
|
rcvar=${name}_enable
|
||||||
|
|
||||||
|
load_rc_config ${name}
|
||||||
|
|
||||||
|
: ${headphones_enable:="NO"}
|
||||||
|
: ${headphones_user:="_sabnzbd"}
|
||||||
|
: ${headphones_dir:="/usr/local/headphones"}
|
||||||
|
: ${headphones_chdir:="${headphones_dir}"}
|
||||||
|
: ${headphones_pid:="${headphones_dir}/headphones.pid"}
|
||||||
|
|
||||||
|
status_cmd="${name}_status"
|
||||||
|
stop_cmd="${name}_stop"
|
||||||
|
|
||||||
|
command="/usr/sbin/daemon"
|
||||||
|
command_args="-f -p ${headphones_pid} python ${headphones_dir}/Headphones.py ${headphones_flags} --quiet"
|
||||||
|
|
||||||
|
# Ensure user is root when running this script.
|
||||||
|
if [ `id -u` != "0" ]; then
|
||||||
|
echo "Oops, you should be root before running this!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
verify_headphones_pid() {
|
||||||
|
# Make sure the pid corresponds to the Headphones process.
|
||||||
|
pid=`cat ${headphones_pid} 2>/dev/null`
|
||||||
|
ps -p ${pid} | grep -q "python ${headphones_dir}/Headphones.py"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
# Try to stop Headphones cleanly by calling shutdown over http.
|
||||||
|
headphones_stop() {
|
||||||
|
echo "Stopping $name"
|
||||||
|
verify_headphones_pid
|
||||||
|
if [ -n "${pid}" ]; then
|
||||||
|
wait_for_pids ${pid}
|
||||||
|
echo "Stopped"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
headphones_status() {
|
||||||
|
verify_headphones_pid && echo "$name is running as ${pid}" || echo "$name is not running"
|
||||||
|
}
|
||||||
|
|
||||||
|
run_rc_command "$1"
|
||||||
Reference in New Issue
Block a user