irda-utils: instead of assuming that /dev/ttyS1 is the IrDA port, get the
authorMatt Reimer <mattjreimer@gmail.com>
Mon, 30 Jan 2006 22:06:02 +0000 (22:06 +0000)
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>
Mon, 30 Jan 2006 22:06:02 +0000 (22:06 +0000)
port and attendant arguments from /etc/sysconfig/irda.

packages/irda-utils/files/init
packages/irda-utils/irda-utils_0.9.16.bb

index f644e59..f1594aa 100755 (executable)
@@ -1,21 +1,35 @@
 #! /bin/sh
 
-DESC=irattach
+# Source IrDA networking configuration.
+. /etc/sysconfig/irda
+
+# Check that irda is up.
+[ ${IRDA} = "no" ] && exit 0
+
+[ -f /usr/sbin/irattach ] || exit 0
+
+ARGS=
+if [ $DONGLE ]; then
+       ARGS="$ARGS -d $DONGLE"
+fi
+if [ "$DISCOVERY" = "yes" ];then
+       ARGS="$ARGS -s"
+fi
 
 case "$1" in
   start)
-        echo -n "Starting $DESC: "
-               irattach /dev/ttyS1 > /dev/null 2>&1 &
+        echo -n "Starting IrDA: "
+               irattach ${DEVICE} ${ARGS} > /dev/null 2>&1 &
         echo "$NAME."
         ;;
   stop)
-        echo -n "Stopping $DESC: "
+        echo -n "Stopping IrDA: "
                killall irattach > /dev/null 2>&1
         echo "$NAME."
         ;;
   restart|force-reload)
-        echo -n "Restarting $DESC: "
-               irattach /dev/ttyS1 > /dev/null 2>&1 &
+        echo -n "Restarting IrDA: "
+               irattach ${DEVICE} ${ARGS} > /dev/null 2>&1 &
         sleep 1
                killall irattach > /dev/null 2>&1
         echo "$NAME."
index 2e09edd..48f43cc 100644 (file)
@@ -3,7 +3,7 @@ IrDA allows communication over Infrared with other devices \
 such as phones and laptops."
 SECTION = "base"
 LICENSE = "GPL"
-PR = "r2"
+PR = "r3"
 
 SRC_URI = "${SOURCEFORGE_MIRROR}/irda/irda-utils-${PV}.tar.gz \
           file://configure.patch;patch=1 \
@@ -30,3 +30,36 @@ do_install () {
        install -d ${D}${sysconfdir}/init.d
        install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/irattach
 }
+
+pkg_postinst () {
+#!/bin/sh
+
+module_id() {
+    awk 'BEGIN { FS=": " } /Hardware/ { print $2 } ' </proc/cpuinfo
+ }
+
+if [ ! -f /etc/sysconfig/irda ]; then
+
+  case `module_id` in
+    "HP iPAQ H2200")
+       IRDA=yes
+       DEVICE=/dev/tts/2
+       DONGLE=
+       DISCOVERY=
+       ;;
+    *)
+       IRDA=yes
+       DEVICE=/dev/ttyS1
+       DONGLE=
+       DISCOVERY=
+        ;;
+  esac
+
+  echo "IRDA=$IRDA" > /etc/sysconfig/irda
+  if [ $IRDA = "yes" ]; then
+    echo "DEVICE=$DEVICE" >> /etc/sysconfig/irda
+    echo "DONGLE=$DONGLE" >> /etc/sysconfig/irda
+    echo "DISCOVERY=$DISCOVERY" >> /etc/sysconfig/irda
+  fi
+fi
+}