File: 01-init-script-lsb-headers.patch

package info (click to toggle)
connman 1.45-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,056 kB
  • sloc: ansic: 101,490; sh: 4,985; python: 2,256; makefile: 488
file content (73 lines) | stat: -rw-r--r-- 1,722 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From: Petter Reinholdtsen <pere@hungry.com>
Subject: connman: Missing LSB header in init.d script
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=543869
Forwarded: not needed

---
--- a/scripts/connman.in
+++ b/scripts/connman.in
@@ -1,8 +1,18 @@
 #!/bin/sh
 
+### BEGIN INIT INFO
+# Provides:       connman
+# Required-Start: $remote_fs $syslog dbus
+# Required-Stop:  $remote_fs $syslog dbus
+# Default-Start:  2 3 4 5
+# Default-Stop:   0 1 6
+# Short-Description: Connection Manager
+### END INIT INFO
+
+
 DAEMON=@sbindir@/connmand
 DESC="Connection Manager"
-
+NAME=connmand
 . /lib/lsb/init-functions
 
 if [ -f @sysconfdir@/default/connman ] ; then
@@ -14,8 +24,6 @@
     ln -sf @runstatedir@/connman/resolv.conf /etc/
 fi
 
-set -e
-
 do_start() {
 	start-stop-daemon --start --oknodo --exec $DAEMON -- $DAEMON_OPTS
 }
@@ -24,6 +32,15 @@
 	start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
 }
 
+get_pid() {
+	[ -n "$1" ] || return 0
+	[ -S /run/dbus/system_bus_socket ] || return 0
+
+	dbus-send --system --dest=org.freedesktop.DBus --print-reply \
+		/org/freedesktop/DBus org.freedesktop.DBus.GetConnectionUnixProcessID \
+		string:$1 2>/dev/null | awk '/uint32/ {print $2}'
+}
+
 case "$1" in
   start)
 	log_daemon_msg "Starting $DESC"
@@ -42,8 +59,18 @@
 	do_start
 	log_end_msg $?
 	;;
+  status)
+	pid=$(get_pid net.connman)
+	if [ -n "$pid" ]; then
+		log_success_msg "$NAME is running"
+		return 0
+	else
+		log_failure_msg "$NAME is not running"
+		return 3 # LSB exit code for "program is not running"
+	fi
+	;;
   *)
-	log_success_msg "Usage: $0 {start|stop|restart|force-reload}" >&2
+	log_success_msg "Usage: $0 {start|stop|status|restart|force-reload}" >&2
 	exit 1
 	;;
 esac