Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. #!/bin/bash -e
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides: rivendell caed ripcd rdcatchd
  5. # Required-Start: $remote_fs $syslog
  6. # Required-Stop: $remote_fs $syslog
  7. # Should-Start: mysql jackd gpio asihpi
  8. # Default-Start: 2 3 4 5
  9. # Default-Stop: 0 1 6
  10. # Short-Description: Start Rivendell daemons
  11. # Description: Provides caed rdcatchd and ripcd daemons
  12. ### END INIT INFO
  13.  
  14. DAEMONS="caed ripcd rdcatchd"
  15. PIDDIR=/var/run/rivendell
  16. NAME=rivendell
  17. LABEL="Rivendell daemons"
  18.  
  19. # Defaults
  20. RUN_MODE="init.d"
  21.  
  22. # Read config file (will override defaults above)
  23. [ -r /etc/default/rivendell ] && . /etc/default/rivendell
  24.  
  25. if [ ! -f "/etc/rd.conf" ]; then
  26. echo "No /etc/rd.conf found. See documentation and /usr/share/doc/rivendell/examples/." >&2
  27. exit 0
  28. fi
  29.  
  30. DAEMON_USER=`sed -n 's/^AudioOwner=\(.*\)$/\1/p' /etc/rd.conf`
  31.  
  32. # For Ubuntu, create run directory to store pid files.
  33. AUDIOGROUP=`sed -n 's/^AudioGroup=\(.*\)$/\1/p' /etc/rd.conf`
  34. if [ ! -d /var/run/rivendell ]; then
  35. install --directory --mode 02775 --owner="$DAEMON_USER" --group="$AUDIOGROUP" /var/run/rivendell
  36. fi
  37.  
  38. # Check if Rivendell daemons are started by init scripts or pam_rd.
  39. if [ "$RUN_MODE" != "init.d" ]; then
  40. exit 0
  41. fi
  42.  
  43. for daemon in $DAEMONS; do
  44. test -x /usr/bin/$daemon || exit 0
  45. done
  46.  
  47. # Create run directory to store pid files .
  48. if [ ! -d $PIDDIR ]; then
  49. install --directory --mode 02775 --owner="$DAEMON_USER" --group="$AUDIOGROUP" $PIDDIR
  50. fi
  51.  
  52. function start() {
  53. echo -n "Starting $LABEL:"
  54. for daemon in $DAEMONS; do
  55. start-stop-daemon --start --oknodo --chuid $DAEMON_USER --exec "/usr/bin/$daemon" --quiet
  56. echo -n " $daemon"
  57. done
  58. echo "."
  59. }
  60.  
  61. function stop() {
  62. echo -n "Stopping $LABEL:"
  63. for daemon in $DAEMONS; do
  64. start-stop-daemon --stop --pidfile "$PIDDIR/$daemon.pid" --oknodo --user $DAEMON_USER --exec "/usr/bin/$daemon" --quiet
  65. echo -n " $daemon"
  66. done
  67. echo "."
  68.  
  69. # caed forgets sometimes the shared memory 0x5005
  70. ipcrm -M 0x5005 2> /dev/null || true
  71. }
  72.  
  73. case "$1" in
  74. start)
  75. if ! /usr/bin/rdadmin --check-db; then
  76. echo "No database available, check that MySQL is running" >&2;
  77. exit 0;
  78. fi
  79.  
  80. start
  81. ;;
  82. stop)
  83. stop
  84. ;;
  85. restart)
  86. stop
  87. start
  88. ;;
  89. *)
  90. echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}"
  91. exit 1
  92. ;;
  93. esac
  94.  
  95. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement