summaryrefslogtreecommitdiffstats
path: root/dvswitch-avahi/debian/dvswitch-avahi.init
diff options
context:
space:
mode:
Diffstat (limited to 'dvswitch-avahi/debian/dvswitch-avahi.init')
-rwxr-xr-xdvswitch-avahi/debian/dvswitch-avahi.init57
1 files changed, 57 insertions, 0 deletions
diff --git a/dvswitch-avahi/debian/dvswitch-avahi.init b/dvswitch-avahi/debian/dvswitch-avahi.init
new file mode 100755
index 0000000..83f74a2
--- /dev/null
+++ b/dvswitch-avahi/debian/dvswitch-avahi.init
@@ -0,0 +1,57 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: dvswitch-avahi
+# Required-Start: $remote_fs
+# Required-Stop: $remote_fs
+# Should-Start: avahi
+# Should-Stop: avahi
+# Default-Start: 2 3 4 5
+# Default-Stop: 1
+# Short-Description: Start dvswitch related scripts at boot time.
+# Description: To enable this, set the appropriate boot argument
+# on the kernel command line.
+### END INIT INFO
+
+ENABLED=false
+
+. /lib/init/vars.sh # for $VERBOSE
+
+if grep -qw dvswitch /proc/cmdline ; then
+ ENABLED=true
+fi
+
+if [ -f /etc/default/dvswitch ] ; then
+ . /etc/default/dvswitch
+fi
+
+xsession() {
+ xterm -e bash -c "/usr/bin/dvswitch-avahi ; bash" &
+ sleep 5
+ twm
+}
+
+case "$1" in
+ start)
+ if [ true = "$ENABLED" ]; then
+ startx $0 xsession -- :0 &
+ # Wait for 5 seconds for the avahi announcement, to make sure dvsources started after this script
+ # will find the server
+ for f in 1 2 3 4 5 ; do
+ found=$(avahi-browse -tr -v _dvswitch._tcp 2>&1 | awk '/address = / { print $3 }')
+ if [ "$found" ] ; then
+ sleep 5 # Give dvswitch process a chance to start too
+ break
+ fi
+ done
+ fi
+ ;;
+ stop)
+ ;;
+ restart)
+ ;;
+ force-reload)
+ ;;
+ xsession)
+ xsession
+ ;;
+esac