#! /bin/sh ### BEGIN INIT INFO # Provides: bluetooth # Required-Start: $local_fs $syslog $remote_fs dbus # Required-Stop: $local_fs $syslog $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start bluetooth daemons ### END INIT INFO # # bluez Bluetooth subsystem starting and stopping # # originally from bluez's scripts/bluetooth.init # # Edd Dumbill # LSB 3.0 compilance and enhancements by Filippo Giunchedi # # Updated for bluez 4.7 by Mario Limonciello # Updated for bluez 5.5 by Nobuhiro Iwamatsu # # Note: older daemons like dund pand hidd are now shipped inside the # bluez-compat package global PATH := '/sbin:/bin:/usr/sbin:/usr/bin' global DESC := 'bluetooth' global DAEMON := '/usr/sbin/bluetoothd' global HCIATTACH := '/usr/bin/hciattach' global BLUETOOTH_ENABLED := '0' global HID2HCI_ENABLED := '1' global HID2HCI_UNDO := '1' global SDPTOOL := '/usr/bin/sdptool' # If you want to be ignore error of "org.freedesktop.hostname1", # please enable NOPLUGIN_OPTION. # NOPLUGIN_OPTION="--noplugin=hostname" global NOPLUGIN_OPTION := ''"" global SSD_OPTIONS := ""--oknodo --quiet --exec $DAEMON -- $NOPLUGIN_OPTION"" test -f $DAEMON || exit 0 # FIXME: any of the sourced files may fail if/with syntax errors test -f /etc/default/bluetooth && source /etc/default/bluetooth test -f /etc/default/rcS && source /etc/default/rcS source /lib/lsb/init-functions set -e # FIXME: this function is possibly a no-op proc run_sdptool { # declaring IFS local in this function, removes the need to # save/restore it var IFS = '', o = '' test -x $SDPTOOL || return 1 # FIXME: where does SDPTOOL_OPTIONS come from? if ! test -z $SDPTOOL_OPTIONS { IFS := '";'" for o in [$SDPTOOL_OPTIONS] { #echo "execing $SDPTOOL $o" IFS := '" '" if test $VERBOSE != no { $SDPTOOL $o } else { $SDPTOOL $o >/dev/null !2 > !1 } } } } proc hci_input { log_progress_msg "switching to HID/HCI no longer done in init script, see /usr/share/doc/bluez/NEWS.Debian.gz" || : } alias enable_hci_input=hci_input alias disable_hci_input=hci_input matchstr $1 { start { log_daemon_msg "Starting $DESC" if test $BLUETOOTH_ENABLED = 0 { log_progress_msg "disabled. see /etc/default/bluetooth" log_end_msg 0 exit 0 } start-stop-daemon --start --background $SSD_OPTIONS log_progress_msg $(DAEMON##*/) run_sdptool || : if test $HID2HCI_ENABLED = 1 { enable_hci_input } log_end_msg 0 } stop { log_daemon_msg "Stopping $DESC" if test $BLUETOOTH_ENABLED = 0 { log_progress_msg "disabled." log_end_msg 0 exit 0 } if test $HID2HCI_UNDO = 1 { disable_hci_input } start-stop-daemon --stop $SSD_OPTIONS log_progress_msg $(DAEMON) log_end_msg 0 } restart|force-reload { $0 stop sleep 1 $0 start } status { status_of_proc $DAEMON $DESC && exit 0 || exit $Status } * { global N := '/etc/init.d/bluetooth' echo "Usage: $N {start|stop|restart|force-reload|status}" > !2 exit 1 } } exit 0 # vim:noet (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PATH) op: Equal rhs: {(/sbin) (Lit_Other ":") (/bin) (Lit_Other ":") (/usr/sbin) (Lit_Other ":") (/usr/bin)} spids: [67] ) ] spids: [67] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DESC) op:Equal rhs:{(bluetooth)} spids:[76])] spids: [76] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DAEMON) op: Equal rhs: {(/usr/sbin/bluetoothd)} spids: [80] ) ] spids: [80] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HCIATTACH) op: Equal rhs: {(/usr/bin/hciattach)} spids: [83] ) ] spids: [83] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:BLUETOOTH_ENABLED) op:Equal rhs:{(0)} spids:[87])] spids: [87] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:HID2HCI_ENABLED) op:Equal rhs:{(1)} spids:[90])] spids: [90] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:HID2HCI_UNDO) op:Equal rhs:{(1)} spids:[93])] spids: [93] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:SDPTOOL) op:Equal rhs:{(/usr/bin/sdptool)} spids:[97])] spids: [97] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:NOPLUGIN_OPTION) op:Equal rhs:{(DQ )} spids:[110])] spids: [110] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SSD_OPTIONS) op: Equal rhs: { (DQ ("--oknodo --quiet --exec ") ($ VSub_Name "$DAEMON") (" -- ") ($ VSub_Name "$NOPLUGIN_OPTION") ) } spids: [114] ) ] spids: [114] ) (AndOr children: [(C {(test)} {(-f)} {($ VSub_Name "$DAEMON")}) (C {(exit)} {(0)})] op_id: Op_DPipe ) (AndOr children: [(C {(test)} {(-f)} {(/etc/default/bluetooth)}) (C {(.)} {(/etc/default/bluetooth)})] op_id: Op_DAmp ) (AndOr children: [(C {(test)} {(-f)} {(/etc/default/rcS)}) (C {(.)} {(/etc/default/rcS)})] op_id: Op_DAmp ) (C {(.)} {(/lib/lsb/init-functions)}) (C {(set)} {(-e)}) (FuncDef name: run_sdptool body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs:(LhsName name:IFS) op:Equal spids:[194]) (assign_pair lhs:(LhsName name:o) op:Equal spids:[196]) ] spids: [192] ) (AndOr children: [ (C {(test)} {(-x)} {($ VSub_Name "$SDPTOOL")}) (ControlFlow token: arg_word:{(1)}) ] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [(C {(test)} {(-z)} {(DQ ($ VSub_Name "$SDPTOOL_OPTIONS"))})] negated: True ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:IFS) op: Equal rhs: {(DQ (";"))} spids: [234] ) ] spids: [234] ) (ForEach iter_name: o iter_words: [{($ VSub_Name "$SDPTOOL_OPTIONS")}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:IFS) op: Equal rhs: {(DQ (" "))} spids: [257] ) ] spids: [257] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(KW_Bang "!") (Lit_Other "=")} {(no)} {(Lit_Other "]")} ) terminator: ) ] action: [(C {($ VSub_Name "$SDPTOOL")} {($ VSub_Name "$o")})] spids: [-1 279] ) ] else_action: [ (SimpleCommand words: [{($ VSub_Name "$SDPTOOL")} {($ VSub_Name "$o")}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [294] ) (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [297] ) ] ) ] spids: [287 301] ) ] spids: [250 304] ) spids: [245 248] ) ] spids: [-1 231] ) ] spids: [-1 307] ) ] spids: [181] ) spids: [177 180] ) (FuncDef name: hci_input body: (BraceGroup children: [ (AndOr children: [ (C {(log_progress_msg)} { (DQ ( "switching to HID/HCI no longer done in init script, see /usr/share/doc/bluez/NEWS.Debian.gz" ) ) } ) (C {(Lit_Other ":")}) ] op_id: Op_DPipe ) ] spids: [316] ) spids: [312 315] ) (C {(alias)} {(Lit_VarLike "enable_hci_input=") (hci_input)}) (C {(alias)} {(Lit_VarLike "disable_hci_input=") (hci_input)}) (Case to_match: {($ VSub_Number "$1")} arms: [ (case_arm pat_list: [{(start)}] action: [ (C {(log_daemon_msg)} {(DQ ("Starting ") ($ VSub_Name "$DESC"))}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(DQ ($ VSub_Name "$BLUETOOTH_ENABLED"))} {(Lit_Other "=")} {(0)}) terminator: ) ] action: [ (C {(log_progress_msg)} {(DQ ("disabled. see /etc/default/bluetooth"))}) (C {(log_end_msg)} {(0)}) (C {(exit)} {(0)}) ] spids: [-1 375] ) ] spids: [-1 395] ) (C {(start-stop-daemon)} {(--start)} {(--background)} {($ VSub_Name "$SSD_OPTIONS")}) (C {(log_progress_msg)} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_DPound arg_word:{("*") (Lit_Slash /)}) spids: [411 416] ) ) } ) (AndOr children:[(C {(run_sdptool)})(C {(Lit_Other ":")})] op_id:Op_DPipe) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(DQ ($ VSub_Name "$HID2HCI_ENABLED"))} {(Lit_Other "=")} {(1)}) terminator: ) ] action: [(C {(enable_hci_input)})] spids: [-1 442] ) ] spids: [-1 448] ) (C {(log_end_msg)} {(0)}) ] spids: [349 350 457 -1] ) (case_arm pat_list: [{(stop)}] action: [ (C {(log_daemon_msg)} {(DQ ("Stopping ") ($ VSub_Name "$DESC"))}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(DQ ($ VSub_Name "$BLUETOOTH_ENABLED"))} {(Lit_Other "=")} {(0)}) terminator: ) ] action: [ (C {(log_progress_msg)} {(DQ (disabled.))}) (C {(log_end_msg)} {(0)}) (C {(exit)} {(0)}) ] spids: [-1 485] ) ] spids: [-1 505] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(DQ ($ VSub_Name "$HID2HCI_UNDO"))} {(Lit_Other "=")} {(1)}) terminator: ) ] action: [(C {(disable_hci_input)})] spids: [-1 521] ) ] spids: [-1 527] ) (C {(start-stop-daemon)} {(--stop)} {($ VSub_Name "$SSD_OPTIONS")}) (C {(log_progress_msg)} {(DQ (${ VSub_Name DAEMON))}) (C {(log_end_msg)} {(0)}) ] spids: [460 461 551 -1] ) (case_arm pat_list: [{(restart)} {(force-reload)}] action: [ (C {($ VSub_Number "$0")} {(stop)}) (C {(sleep)} {(1)}) (C {($ VSub_Number "$0")} {(start)}) ] spids: [554 557 575 -1] ) (case_arm pat_list: [{(status)}] action: [ (AndOr children: [ (C {(status_of_proc)} {(DQ ($ VSub_Name "$DAEMON"))} {(DQ ($ VSub_Name "$DESC"))}) (AndOr children: [(C {(exit)} {(0)}) (C {(exit)} {($ VSub_QMark "$?")})] op_id: Op_DPipe ) ] op_id: Op_DAmp ) ] spids: [578 579 605 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:N) op: Equal rhs: {(/etc/init.d/bluetooth)} spids: [612] ) ] spids: [612] ) (SimpleCommand words: [ {(echo)} {(DQ ("Usage: ") ($ VSub_Name "$N") (" {start|stop|restart|force-reload|status}"))} ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[624])] ) (C {(exit)} {(1)}) ] spids: [608 609 633 -1] ) ] spids: [342 346 635] ) (C {(exit)} {(0)}) ] )