#!/bin/sh ### BEGIN INIT INFO # Provides: dbus # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: D-Bus systemwide message bus # Description: D-Bus is a simple interprocess messaging system, used # for sending messages between applications. ### END INIT INFO # -*- coding: utf-8 -*- # Debian init.d script for D-BUS # Copyright © 2003 Colin Walters # Copyright © 2005 Sjoerd Simons set -e global DAEMON := '/usr/bin/dbus-daemon' global UUIDGEN := '/usr/bin/dbus-uuidgen' global UUIDGEN_OPTS := '--ensure' global NAME := 'dbus' global DAEMONUSER := 'messagebus' global PIDDIR := '/var/run/dbus' global PIDFILE := "$PIDDIR/pid" global DESC := '"system message bus'" test -x $DAEMON || exit 0 source /lib/lsb/init-functions # Source defaults file; edit that file to configure this script. global PARAMS := ''"" if test -e /etc/default/dbus { source /etc/default/dbus } proc create_machineid { # Create machine-id file if test -x $UUIDGEN { $UUIDGEN $UUIDGEN_OPTS } } proc start_it_up { if test ! -d $PIDDIR { mkdir -p $PIDDIR chown $DAEMONUSER $PIDDIR chgrp $DAEMONUSER $PIDDIR } if ! mountpoint -q /proc/ { log_failure_msg "Can't start $DESC - /proc is not mounted" return } if test -e $PIDFILE { if $0 status > /dev/null { log_success_msg "$DESC already started; not starting." return } else { log_success_msg "Removing stale PID file $PIDFILE." rm -f $PIDFILE } } create_machineid log_daemon_msg "Starting $DESC" $NAME start-stop-daemon --start --quiet --pidfile $PIDFILE \ --exec $DAEMON -- --system $PARAMS log_end_msg $Status } proc shut_it_down { log_daemon_msg "Stopping $DESC" $NAME start-stop-daemon --stop --retry 5 --quiet --oknodo --pidfile $PIDFILE \ --user $DAEMONUSER # We no longer include these arguments so that start-stop-daemon # can do its job even given that we may have been upgraded. # We rely on the pidfile being sanely managed # --exec $DAEMON -- --system $PARAMS log_end_msg $Status rm -f $PIDFILE } proc reload_it { create_machineid log_action_begin_msg "Reloading $DESC config" dbus-send --print-reply --system --type=method_call \ --dest=org.freedesktop.DBus \ / org.freedesktop.DBus.ReloadConfig > /dev/null # hopefully this is enough time for dbus to reload it's config file. log_action_end_msg $Status } matchstr $1 { start { start_it_up } stop { shut_it_down } reload|force-reload { reload_it } restart { shut_it_down start_it_up } status { status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $Status } * { echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload|status}" > !2 exit 2 } } (CommandList children: [ (C {(set)} {(-e)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DAEMON) op: Equal rhs: {(/usr/bin/dbus-daemon)} spids: [51] ) ] spids: [51] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:UUIDGEN) op: Equal rhs: {(/usr/bin/dbus-uuidgen)} spids: [54] ) ] spids: [54] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:UUIDGEN_OPTS) op:Equal rhs:{(--ensure)} spids:[57])] spids: [57] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:NAME) op:Equal rhs:{(dbus)} spids:[60])] spids: [60] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DAEMONUSER) op:Equal rhs:{(messagebus)} spids:[63])] spids: [63] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:PIDDIR) op:Equal rhs:{(/var/run/dbus)} spids:[66])] spids: [66] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PIDFILE) op: Equal rhs: {($ VSub_Name "$PIDDIR") (/pid)} spids: [69] ) ] spids: [69] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DESC) op: Equal rhs: {(DQ ("system message bus"))} spids: [73] ) ] spids: [73] ) (AndOr children: [(C {(test)} {(-x)} {($ VSub_Name "$DAEMON")}) (C {(exit)} {(0)})] op_id: Op_DPipe ) (C {(.)} {(/lib/lsb/init-functions)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:PARAMS) op:Equal rhs:{(DQ )} spids:[100])] spids: [100] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-e)} {(/etc/default/dbus)} {(Lit_Other "]")}) terminator: ) ] action: [(C {(.)} {(/etc/default/dbus)})] spids: [-1 115] ) ] spids: [-1 122] ) (FuncDef name: create_machineid body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-x)} {($ VSub_Name "$UUIDGEN")} {(Lit_Other "]")}) terminator: ) ] action: [(C {($ VSub_Name "$UUIDGEN")} {($ VSub_Name "$UUIDGEN_OPTS")})] spids: [-1 147] ) ] spids: [-1 155] ) ] spids: [129] ) spids: [125 128] ) (FuncDef name: start_it_up body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-d)} {($ VSub_Name "$PIDDIR")} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(mkdir)} {(-p)} {($ VSub_Name "$PIDDIR")}) (C {(chown)} {($ VSub_Name "$DAEMONUSER")} {($ VSub_Name "$PIDDIR")}) (C {(chgrp)} {($ VSub_Name "$DAEMONUSER")} {($ VSub_Name "$PIDDIR")}) ] spids: [-1 180] ) ] spids: [-1 204] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children:[(C {(mountpoint)} {(-q)} {(/proc/)})] negated:True) terminator: ) ] action: [ (C {(log_failure_msg)} {(DQ ("Can't start ") ($ VSub_Name "$DESC") (" - /proc is not mounted"))} ) (ControlFlow token:) ] spids: [-1 220] ) ] spids: [-1 235] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-e)} {($ VSub_Name "$PIDFILE")} {(Lit_Other "]")}) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (SimpleCommand words: [{($ VSub_Number "$0")} {(status)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [259] ) ] ) terminator: ) ] action: [ (C {(log_success_msg)} {(DQ ($ VSub_Name "$DESC") (" already started; not starting."))} ) (ControlFlow token: ) ] spids: [-1 265] ) ] else_action: [ (C {(log_success_msg)} {(DQ ("Removing stale PID file ") ($ VSub_Name "$PIDFILE") (.))} ) (C {(rm)} {(-f)} {($ VSub_Name "$PIDFILE")}) ] spids: [279 298] ) ] spids: [-1 250] ) ] spids: [-1 301] ) (C {(create_machineid)}) (C {(log_daemon_msg)} {(DQ ("Starting ") ($ VSub_Name "$DESC"))} {(DQ ($ VSub_Name "$NAME"))}) (C {(start-stop-daemon)} {(--start)} {(--quiet)} {(--pidfile)} {($ VSub_Name "$PIDFILE")} {(--exec)} {($ VSub_Name "$DAEMON")} {(--)} {(--system)} {($ VSub_Name "$PARAMS")} ) (C {(log_end_msg)} {($ VSub_QMark "$?")}) ] spids: [164] ) spids: [160 163] ) (FuncDef name: shut_it_down body: (BraceGroup children: [ (C {(log_daemon_msg)} {(DQ ("Stopping ") ($ VSub_Name "$DESC"))} {(DQ ($ VSub_Name "$NAME"))}) (C {(start-stop-daemon)} {(--stop)} {(--retry)} {(5)} {(--quiet)} {(--oknodo)} {(--pidfile)} {($ VSub_Name "$PIDFILE")} {(--user)} {($ VSub_Name "$DAEMONUSER")} ) (C {(log_end_msg)} {($ VSub_QMark "$?")}) (C {(rm)} {(-f)} {($ VSub_Name "$PIDFILE")}) ] spids: [355] ) spids: [351 354] ) (FuncDef name: reload_it body: (BraceGroup children: [ (C {(create_machineid)}) (C {(log_action_begin_msg)} {(DQ ("Reloading ") ($ VSub_Name "$DESC") (" config"))}) (SimpleCommand words: [ {(dbus-send)} {(--print-reply)} {(--system)} {(--type) (Lit_Other "=") (method_call)} {(--dest) (Lit_Other "=") (org.freedesktop.DBus)} {(/)} {(org.freedesktop.DBus.ReloadConfig)} ] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[464])] ) (C {(log_action_end_msg)} {($ VSub_QMark "$?")}) ] spids: [427] ) spids: [423 426] ) (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list:[{(start)}] action:[(C {(start_it_up)})] spids:[489490496-1]) (case_arm pat_list:[{(stop)}] action:[(C {(shut_it_down)})] spids:[499500506-1]) (case_arm pat_list: [{(reload)} {(force-reload)}] action: [(C {(reload_it)})] spids: [509 512 518 -1] ) (case_arm pat_list: [{(restart)}] action: [(C {(shut_it_down)}) (C {(start_it_up)})] spids: [521 522 531 -1] ) (case_arm pat_list: [{(status)}] action: [ (AndOr children: [ (C {(status_of_proc)} {(-p)} {($ VSub_Name "$PIDFILE")} {($ VSub_Name "$DAEMON")} {($ VSub_Name "$NAME")} ) (AndOr children: [(C {(exit)} {(0)}) (C {(exit)} {($ VSub_QMark "$?")})] op_id: Op_DPipe ) ] op_id: Op_DAmp ) ] spids: [534 535 561 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Usage: /etc/init.d/") ($ VSub_Name "$NAME") (" {start|stop|reload|restart|force-reload|status}") ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[576])] ) (C {(exit)} {(2)}) ] spids: [564 565 585 -1] ) ] spids: [480 486 587] ) ] )