Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -e
- ### BEGIN INIT INFO
- # Provides: rivendell caed ripcd rdcatchd
- # Required-Start: $remote_fs $syslog
- # Required-Stop: $remote_fs $syslog
- # Should-Start: mysql jackd gpio asihpi
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Start Rivendell daemons
- # Description: Provides caed rdcatchd and ripcd daemons
- ### END INIT INFO
- DAEMONS="caed ripcd rdcatchd"
- PIDDIR=/var/run/rivendell
- NAME=rivendell
- LABEL="Rivendell daemons"
- # Defaults
- RUN_MODE="init.d"
- # Read config file (will override defaults above)
- [ -r /etc/default/rivendell ] && . /etc/default/rivendell
- if [ ! -f "/etc/rd.conf" ]; then
- echo "No /etc/rd.conf found. See documentation and /usr/share/doc/rivendell/examples/." >&2
- exit 0
- fi
- DAEMON_USER=`sed -n 's/^AudioOwner=\(.*\)$/\1/p' /etc/rd.conf`
- # For Ubuntu, create run directory to store pid files.
- AUDIOGROUP=`sed -n 's/^AudioGroup=\(.*\)$/\1/p' /etc/rd.conf`
- if [ ! -d /var/run/rivendell ]; then
- install --directory --mode 02775 --owner="$DAEMON_USER" --group="$AUDIOGROUP" /var/run/rivendell
- fi
- # Check if Rivendell daemons are started by init scripts or pam_rd.
- if [ "$RUN_MODE" != "init.d" ]; then
- exit 0
- fi
- for daemon in $DAEMONS; do
- test -x /usr/bin/$daemon || exit 0
- done
- # Create run directory to store pid files .
- if [ ! -d $PIDDIR ]; then
- install --directory --mode 02775 --owner="$DAEMON_USER" --group="$AUDIOGROUP" $PIDDIR
- fi
- function start() {
- echo -n "Starting $LABEL:"
- for daemon in $DAEMONS; do
- start-stop-daemon --start --oknodo --chuid $DAEMON_USER --exec "/usr/bin/$daemon" --quiet
- echo -n " $daemon"
- done
- echo "."
- }
- function stop() {
- echo -n "Stopping $LABEL:"
- for daemon in $DAEMONS; do
- start-stop-daemon --stop --pidfile "$PIDDIR/$daemon.pid" --oknodo --user $DAEMON_USER --exec "/usr/bin/$daemon" --quiet
- echo -n " $daemon"
- done
- echo "."
- # caed forgets sometimes the shared memory 0x5005
- ipcrm -M 0x5005 2> /dev/null || true
- }
- case "$1" in
- start)
- if ! /usr/bin/rdadmin --check-db; then
- echo "No database available, check that MySQL is running" >&2;
- exit 0;
- fi
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}"
- exit 1
- ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement