merge r4529 to trunk
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 16 May 2009 17:19:06 +0000 (17:19 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 16 May 2009 17:19:06 +0000 (17:19 +0000)
contrib/package/freifunk-watchdog/Makefile
contrib/package/freifunk-watchdog/files/freifunk-watchdog.init
contrib/package/freifunk-watchdog/src/watchdog.c

index 439e0478c537db4f11e7c3ada747c9da3eefcb9d..e4cb550f6cca7858713ac4352f352a54dc5e4bc8 100644 (file)
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=freifunk-watchdog
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 PKG_BUILD_DEPENDS := uci
index 1cce46b4af324486d1069ab5e8100d285af8ae63..1f87bf744f74b9e1d09d24327efc5f09246b5a95 100755 (executable)
@@ -6,15 +6,20 @@ BIN=/usr/sbin/ffwatchd
 
 boot()
 {
-       if ! grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
-               echo "* * * * * $BIN running || /etc/init.d/freifunk-watchdog restart" >> /etc/crontabs/root
-       fi
+       # If watchdog service is enabled, install cronjob, create device node and start daemon
+       if /etc/init.d/freifunk-watchdog enabled 2>/dev/null; then
+               if ! grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
+                       echo "* * * * * $BIN running || /etc/init.d/freifunk-watchdog restart" >> /etc/crontabs/root
+               fi
 
-       if lsmod | grep -q softdog; then
                mknod /dev/watchdog c 10 130
-       fi
 
-       start
+               start
+               
+       # If service is disabled, find and remove related cronjob
+       elif grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
+               sed -i -e "\\'$BIN'd" /etc/crontabs/root
+       fi
 }
 
 start()
index 7bbb7c7ab1c3c5709164ba98faba2685a99cff13..b5a573d49e15d1a048a3339a6ad9995364068e4a 100644 (file)
@@ -205,44 +205,48 @@ static void load_wifi_uci_add_iface(const char *section, struct uci_itr_ctx *itr
        const char *ucitmp;
        int val = 0;
 
-       if( (t = (wifi_tuple_t *)malloc(sizeof(wifi_tuple_t))) != NULL )
+       ucitmp = ucix_get_option(itr->ctx, "wireless", section, "mode");
+       if( ucitmp && !strncmp(ucitmp, "adhoc", 5) )
        {
-               ucitmp = ucix_get_option(itr->ctx, "wireless", section, "ifname");
-               if(ucitmp)
+               if( (t = (wifi_tuple_t *)malloc(sizeof(wifi_tuple_t))) != NULL )
                {
-                       strncpy(t->ifname, ucitmp, sizeof(t->ifname));
-                       val++;
-               }
-
-               ucitmp = ucix_get_option(itr->ctx, "wireless", section, "bssid");
-               if(ucitmp)
-               {
-                       strncpy(t->bssid, ucitmp, sizeof(t->bssid));
-                       val++;
-               }
+                       ucitmp = ucix_get_option(itr->ctx, "wireless", section, "ifname");
+                       if(ucitmp)
+                       {
+                               strncpy(t->ifname, ucitmp, sizeof(t->ifname));
+                               val++;
+                       }
 
-               ucitmp = ucix_get_option(itr->ctx, "wireless", section, "device");
-               if(ucitmp)
-               {
-                       ucitmp = ucix_get_option(itr->ctx, "wireless", ucitmp, "channel");
+                       ucitmp = ucix_get_option(itr->ctx, "wireless", section, "bssid");
                        if(ucitmp)
                        {
-                               t->channel = atoi(ucitmp);
+                               strncpy(t->bssid, ucitmp, sizeof(t->bssid));
                                val++;
                        }
-               }
 
-               if( val == 3 )
-               {
-                       syslog(LOG_INFO, "Monitoring %s: bssid=%s channel=%d",
-                               t->ifname, t->bssid, t->channel);
+                       ucitmp = ucix_get_option(itr->ctx, "wireless", section, "device");
+                       if(ucitmp)
+                       {
+                               ucitmp = ucix_get_option(itr->ctx, "wireless", ucitmp, "channel");
+                               if(ucitmp)
+                               {
+                                       t->channel = atoi(ucitmp);
+                                       val++;
+                               }
+                       }
 
-                       t->next = itr->list;
-                       itr->list = t;
-               }
-               else
-               {
-                       free(t);
+                       if( val == 3 )
+                       {
+                               syslog(LOG_INFO, "Monitoring %s: bssid=%s channel=%d",
+                                       t->ifname, t->bssid, t->channel);
+
+                               t->next = itr->list;
+                               itr->list = t;
+                       }
+                       else
+                       {
+                               free(t);
+                       }
                }
        }
 }