Advertisement
bastafidli

/etc/init.d/pulseaudio - 3 way multiseat - Pulseaudio

Sep 5th, 2012
409
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Provides: pulseaudio esound
  4. # Required-Start: $remote_fs $syslog
  5. # Required-Stop: $remote_fs $syslog
  6. # Should-Start: udev NetworkManager
  7. # Should-Stop: udev NetworkManager
  8. # Default-Start: 2 3 4 5
  9. # Default-Stop: 1
  10. # Short-Description: Start the PulseAudio sound server
  11. # Description: System mode startup script for
  12. # the PulseAudio sound server.
  13. ### END INIT INFO
  14.  
  15. DAEMON=/usr/bin/pulseaudio
  16. PIDDIR=/var/run/pulse
  17. PIDFILE=$PIDDIR/pid
  18. DAEMONUSER=pulse
  19. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  20.  
  21. test -x $DAEMON || exit 0
  22.  
  23. . /lib/lsb/init-functions
  24.  
  25. # Multiseat:
  26. PULSEAUDIO_SYSTEM_START=1
  27. ##PULSEAUDIO_SYSTEM_START=0
  28.  
  29. DISALLOW_MODULE_LOADING=1
  30. test -f /etc/default/pulseaudio && . /etc/default/pulseaudio
  31. if [ "$PULSEAUDIO_SYSTEM_START" != "1" ]; then
  32. log_warning_msg "PulseAudio configured for per-user sessions"
  33. exit 0
  34. fi
  35.  
  36. pulseaudio_start () {
  37. log_daemon_msg "Starting system PulseAudio Daemon"
  38. if [ ! -d $PIDDIR ]; then
  39. mkdir -p $PIDDIR
  40. chown $DAEMONUSER:$DAEMONUSER $PIDDIR
  41. fi
  42. start-stop-daemon -x $DAEMON -p $PIDFILE --start -- -vv --system --daemonize --high-priority --log-target=syslog --disallow-module-loading=$DISALLOW_MODULE_LOADING
  43. status=$?
  44. if [ -e /var/run/pulse/.esd_auth ]; then
  45. chown pulse:pulse-access /var/run/pulse/.esd_auth
  46. chmod 640 /var/run/pulse/.esd_auth
  47. fi
  48. if [ -e /var/run/pulse/.pulse-cookie ]; then
  49. chown pulse:pulse-access /var/run/pulse/.pulse-cookie
  50. chmod 640 /var/run/pulse/.pulse-cookie
  51. fi
  52. log_end_msg ${status}
  53. }
  54.  
  55. pulseaudio_stop () {
  56. log_daemon_msg "Stopping system PulseAudio Daemon"
  57. start-stop-daemon -p $PIDFILE --stop --retry 5 || echo -n "...which is not running"
  58. log_end_msg $?
  59. }
  60.  
  61. case "$1" in
  62. start|stop)
  63. pulseaudio_${1}
  64. ;;
  65. restart|reload|force-reload)
  66. if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1; then
  67. pulseaudio_stop
  68. pulseaudio_start
  69. fi
  70. ;;
  71. force-stop)
  72. pulseaudio_stop
  73. killall pulseaudio || true
  74. sleep 2
  75. killall -9 pulseaudio || true
  76. ;;
  77. status)
  78. status_of_proc -p $PIDFILE "$DAEMON" "system-wide PulseAudio" && exit 0 || exit $?
  79. ;;
  80. *)
  81. echo "Usage: /etc/init.d/pulseaudio {start|stop|force-stop|restart|reload|force-reload|status}"
  82. exit 1
  83. ;;
  84. esac
  85.  
  86. exit 0
Advertisement
RAW Paste Data Copied
Advertisement