contrib/bluealsa/bluealsa.rc

41 lines
916 B
Bash
Executable File

#!/bin/sh
#@ bluez-alsa startup script.
#@ Likely requires <- bluetoothd [<- dbus]
RD=/run
PID=${RD}/bluealsa.pid
SSD=/sbin/start-stop-daemon
PROG=/usr/bin/bluealsa
OPTS="-p a2dp-sink -p a2dp-source -c AAC"
case "${1}" in
start)
exec "${SSD}" --start --background --make-pidfile --pidfile "${PID}" \
--exec "${PROG}" -- ${OPTS}
;;
stop)
exec "${SSD}" --stop --remove-pidfile --retry 10 --pidfile "${PID}" \
--exec "${PROG}"
;;
restart)
"${SSD}" --status --pidfile "${PID}" --exec "${PROG}" &&
"${0}" stop
exec "${0}" start
;;
status)
"${SSD}" --status --pidfile "${PID}" --exec "${PROG}"
e=${?}
case ${e} in
0) echo "${PROG} is running with pid $(cat ${PID})";;
1) echo "${PROG} is not running but the pid file ${PID} exists";;
3) echo "${PROG} is not running";;
4) echo "Unable to determine the program status";;
esac
exit ${e}
;;
*)
echo "usage: ${0} start|stop|restart|status"
;;
esac