Merge pull request #1821 from TDT-AG/pr/20180521-protocols-remove-aiccu
[project/luci.git] / applications / luci-app-openvpn / luasrc / model / cbi / openvpn.lua
index d5e0019eb7af959f37ee7f7adb8b8a3d4ad662ee..a6b0e1dd902f0c953483326dcc5a4e02a194762c 100644 (file)
@@ -26,9 +26,9 @@ uci:foreach( "openvpn_recipes", "openvpn_recipe",
 )
 
 function s.getPID(section) -- Universal function which returns valid pid # or nil
-       local pid = sys.exec("%s | grep -w %s | grep openvpn | grep -v grep | awk '{print $1}'" % { psstring,section} )
-       if pid and #pid > 0 and tonumber(pid) ~= nil then
-               return tonumber(pid)
+       local pid = sys.exec("%s | grep -w '[o]penvpn(%s)'" % { psstring, section })
+       if pid and #pid > 0 then
+               return tonumber(pid:match("^%s*(%d+)"))
        else
                return nil
        end
@@ -125,5 +125,8 @@ function proto.cfgvalue(self, section)
        return val or "udp"
 end
 
+function m.on_after_commit(self,map)
+       require("luci.sys").call('/etc/init.d/openvpn reload')
+end
 
 return m