Add basic init script
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 22 Feb 2008 04:36:19 +0000 (05:36 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 22 Feb 2008 04:36:19 +0000 (05:36 +0100)
.gitignore
configure.in
scripts/Makefile.am
scripts/connman.in [new file with mode: 0644]

index f29ae7f..d242967 100644 (file)
@@ -23,4 +23,5 @@ autom4te.cache
 
 include/connman
 src/connmand
+scripts/connman
 scripts/dhclient-script
index 9ecec4d..0c61409 100644 (file)
@@ -62,4 +62,4 @@ AC_SUBST(HAL_CFLAGS)
 AC_SUBST(HAL_LIBS)
 
 AC_OUTPUT(Makefile include/Makefile src/Makefile doc/Makefile test/Makefile
-                                       plugins/Makefile scripts/Makefile)
+                       plugins/Makefile scripts/Makefile scripts/connman)
index bb79358..1247398 100644 (file)
@@ -1,4 +1,10 @@
 
+initdir = $(sysconfdir)/init.d
+
+init_SCRIPTS = connman
+
+DISTCLEANFILES = $(init_SCRIPTS)
+
 scriptdir = $(libdir)/connman/scripts
 
 script_DATA = dhclient.conf
diff --git a/scripts/connman.in b/scripts/connman.in
new file mode 100644 (file)
index 0000000..a67f667
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+DAEMON=@prefix@/sbin/connmand
+PIDFILE=@localstatedir@/run/connmand.pid
+DESC="Connection Manager"
+
+. /lib/lsb/init-functions
+
+if [ -f @sysconfdir@/default/connman ] ; then
+       . @sysconfdir@/default/connman
+fi
+
+set -e
+
+do_start() {
+       start-stop-daemon --start --oknodo \
+               --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
+}
+
+do_stop() {
+       start-stop-daemon --stop --oknodo --quiet \
+               --pidfile $PIDFILE --exec $DAEMON
+}
+
+case "$1" in
+  start)
+       log_daemon_msg "Starting $DESC"
+       do_start
+       log_end_msg $?
+       ;;
+  stop)
+       log_daemon_msg "Stopping $DESC"
+       do_stop
+       log_end_msg $?
+       ;;
+  restart|force-reload)
+       log_daemon_msg "Restarting $DESC"
+       do_stop
+       sleep 1
+       do_start
+       log_end_msg $?
+       ;;
+  *)
+       log_success_msg "Usage: $0 {start|stop|restart|force-reload}" >&2
+       exit 1
+       ;;
+esac
+
+exit 0