home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / dbus < prev    next >
Encoding:
Text File  |  2007-03-08  |  2.7 KB  |  121 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          dbus
  4. # Required-Start:    $local_fs $syslog
  5. # Required-Stop:     $local_fs $syslog
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      S 0 1 6
  8. ### END INIT INFO
  9. # -*- coding: utf-8 -*-
  10. # Debian init.d script for D-BUS
  11. # Copyright ┬⌐ 2003 Colin Walters <walters@debian.org>
  12. # Copyright ┬⌐ 2005 Sjoerd Simons <sjoerd@debian.org>
  13.  
  14. set -e
  15.  
  16. DAEMON=/usr/bin/dbus-daemon
  17. UUIDGEN=/usr/bin/dbus-uuidgen
  18. UUIDGEN_OPTS=--ensure
  19. NAME=dbus
  20. DAEMONUSER=messagebus
  21. PIDDIR=/var/run/dbus
  22. PIDFILE=$PIDDIR/pid
  23. DESC="system message bus"
  24. EVENTDIR=/etc/dbus-1/event.d
  25.  
  26. test -x $DAEMON || exit 0
  27.  
  28. . /lib/lsb/init-functions
  29.  
  30. # Source defaults file; edit that file to configure this script.
  31. ENABLED=1
  32. PARAMS=""
  33. if [ -e /etc/default/dbus ]; then
  34.   . /etc/default/dbus
  35. fi
  36.  
  37. test "$ENABLED" != "0" || exit 0
  38.  
  39. create_machineid() {
  40.   # Create machine-id file
  41.   if [ -x $UUIDGEN ]; then
  42.     $UUIDGEN $UUIDGEN_OPTS
  43.   fi
  44. }
  45.  
  46. start_it_up()
  47. {
  48.   if [ ! -d $PIDDIR ]; then
  49.     mkdir -p $PIDDIR
  50.     chown $DAEMONUSER $PIDDIR
  51.     chgrp $DAEMONUSER $PIDDIR
  52.   fi
  53.   if [ -e $PIDFILE ]; then
  54.     PIDDIR=/proc/$(cat $PIDFILE)
  55.     if [ -d ${PIDDIR} -a  "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then 
  56.       log_success_msg "$DESC already started; not starting."
  57.     else
  58.       log_success_msg "Removing stale PID file $PIDFILE."
  59.       rm -f $PIDFILE
  60.     fi
  61.   fi
  62.   create_machineid
  63.  
  64.   log_daemon_msg "Starting $DESC" "$NAME"
  65.   start-stop-daemon --start --quiet --pidfile $PIDFILE \
  66.     --user $DAEMONUSER --exec $DAEMON -- --system $PARAMS
  67.   log_end_msg $?
  68.   if [ -d $EVENTDIR ]; then
  69.       run-parts --arg=start $EVENTDIR || true
  70.   fi
  71. }
  72.  
  73. shut_it_down()
  74. {
  75.   if [ -d $EVENTDIR ]; then
  76.       run-parts --reverse --arg=stop $EVENTDIR || true
  77.   fi
  78.   log_daemon_msg "Stopping $DESC" "$NAME"
  79.   start-stop-daemon --stop --retry 60 --quiet --oknodo --pidfile $PIDFILE \
  80.     --user $DAEMONUSER
  81.   # We no longer include these arguments so that start-stop-daemon
  82.   # can do its job even given that we may have been upgraded.
  83.   # We rely on the pidfile being sanely managed
  84.   # --exec $DAEMON -- --system $PARAMS
  85.   log_end_msg $?
  86.   rm -f $PIDFILE
  87. }
  88.  
  89. reload_it()
  90. {
  91.   create_machineid
  92.   log_action_begin_msg "Reloading $DESC config"
  93.   dbus-send --print-reply --system --type=method_call \
  94.             --dest=org.freedesktop.DBus \
  95.             / org.freedesktop.DBus.ReloadConfig > /dev/null
  96.   # hopefully this is enough time for dbus to reload it's config file.
  97.   log_action_end_msg $?
  98. }
  99.  
  100. case "$1" in
  101.   start)
  102.     start_it_up
  103.   ;;
  104.   stop)
  105.     shut_it_down
  106.   ;;
  107.   reload|force-reload)
  108.     reload_it
  109.   ;;
  110.   restart)
  111.     shut_it_down
  112.     start_it_up
  113.   ;;
  114.   *)
  115.     echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload}" >&2
  116.     exit 2
  117.   ;;
  118. esac
  119.  
  120. exit 0
  121.