Fwknop: add flexibility to uci support 1244/head
authorJonathan Bennett <JBennett@incomsystems.biz>
Sat, 9 May 2015 18:10:08 +0000 (13:10 -0500)
committerJonathan Bennett <JBennett@incomsystems.biz>
Sun, 10 May 2015 06:04:46 +0000 (01:04 -0500)
Styling cleanups
signed-off-by: Jonathan Bennett <jbennett@incomsystems.biz>

net/fwknop/Makefile
net/fwknop/files/fwknopd [new file with mode: 0644]
net/fwknop/files/fwknopd.init

index 62d85e675b2cd93be63893c9b280ffe8f634ab1e..829b31c0c8dbe804eadb15a976f48b9b6398e58b 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fwknop
 PKG_VERSION:=2.6.6
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=http://www.cipherdyne.org/fwknop/download
@@ -102,6 +102,8 @@ define Build/InstallDev
 endef
 
 define Package/fwknopd/install
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_CONF) ./files/fwknopd $(1)/etc/config/fwknopd
        $(INSTALL_DIR) $(1)/etc/fwknop
        $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/fwknop/{access,fwknopd}.conf \
                $(1)/etc/fwknop/
@@ -111,6 +113,10 @@ define Package/fwknopd/install
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/fwknopd $(1)/usr/sbin/
 endef
 
+define Package/fwknopd/conffiles
+       /etc/config/fwknopd
+endef
+
 define Package/fwknop/install
        $(INSTALL_DIR) $(1)/usr/bin
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/fwknop $(1)/usr/bin/
diff --git a/net/fwknop/files/fwknopd b/net/fwknop/files/fwknopd
new file mode 100644 (file)
index 0000000..0874ee4
--- /dev/null
@@ -0,0 +1,9 @@
+config global
+#      option uci_enabled '1'
+
+config access
+       option SOURCE 'ANY'
+       option HMAC_KEY 'CHANGEME'
+       option KEY 'CHANGEME'
+
+config config
index 294258f82a439132bcc6b3e9654d2bc7ee944d6c..6aa41607ddd9b7498c8b48c953c7bda91fd365a7 100644 (file)
@@ -30,60 +30,59 @@ restart()
 
 reload()
 {
+       gen_confs
         $FWKNOPD_BIN -R
 }
 
 gen_confs()
 {
-
-
-config_cb() {
-
-       local type="$1"
-       local name="$2"
-       if [ "$type" = "global" ]
-       then
-               option_cb() { 
-                       local option="$1"                                
-                       local value="$2"   
-                       if [ "$option" = "uci_enabled" ] && [ "$value" -eq 1 ] ; then
-                               > /etc/fwknop/fwknopd.conf
-                               > /etc/fwknop/access.conf
-                               UCI_ENABLED=1
+       [ -f /tmp/access.conf.tmp ] && rm /tmp/access.conf.tmp
+       config_cb() {
+               local type="$1"
+               local name="$2"
+               if [ "$type" = "global" ]; then
+                       option_cb() {
+                               local option="$1"
+                               local value="$2"
+                               if [ "$option" = "uci_enabled" ] && [ "$value" -eq 1 ] ; then
+                                       > /etc/fwknop/fwknopd.conf
+                                       > /etc/fwknop/access.conf
+                                       UCI_ENABLED=1
+                               fi
+                       }
+               elif [ "$type" = "config" ]; then
+                       option_cb() {
+                               local option="$1"
+                               local value="$2"
+                               if [ $UCI_ENABLED ]; then
+                                       echo "$option $value" >> /etc/fwknop/fwknopd.conf  #writing each option to fwknopd.conf
+                               fi
+                       }
+               elif [ "$type" = "access" ]
+               then
+                       if [ -f /tmp/access.conf.tmp ] ; then
+                               cat /tmp/access.conf.tmp >> /etc/fwknop/access.conf
+                               rm /tmp/access.conf.tmp
                        fi
-               }
-       elif [ "$type" = "config" ]
-       then
-               option_cb() { 
-                       local option="$1"                                
-                       local value="$2"   
-                       if [ $UCI_ENABLED ]; then 
-                               echo "${option//_/-} $value" >> /etc/fwknop/fwknopd.conf  #writing each option to fwknopd.conf
-                       fi
-               }
-       elif [ "$type" = "SOURCE" ]
-       then
-               echo "${type//_/-} $name" >> /etc/fwknop/access.conf  #writing each option to access.conf
-               option_cb() { 
-                       local option="$1"                                
-                       local value="$2"   
-                       if [ $UCI_ENABLED ]; then 
-                               echo "${option//_/-} $value" >> /etc/fwknop/access.conf  #writing each option to access.conf
-                       fi
-               }
-       fi       
-
-
-
-
-}
-
-
-if [ -f /etc/config/fwknopd ]; then
-
-       config_load fwknopd
-
-
-fi
+                       option_cb() {
+                               local option="$1"
+                               local value="$2"
+                               if [ $UCI_ENABLED ] && [ $option = "SOURCE" ]; then
+                                       echo "$option $value" >> /etc/fwknop/access.conf  #writing each option to access.conf
+                               fi
+                               if [ $UCI_ENABLED ] && [ $option != "SOURCE" ]; then
+                                       echo "$option $value" >> /tmp/access.conf.tmp  #writing each option to access.conf
+                               fi
+                       }
+               fi
+       }
+
+       if [ -f /etc/config/fwknopd ]; then
+               config_load fwknopd
+               if [ -f /tmp/access.conf.tmp ] ; then
+                       cat /tmp/access.conf.tmp >> /etc/fwknop/access.conf
+                       rm /tmp/access.conf.tmp
+               fi
+       fi
 
 }