diff options
author | Dirk Brenken <dev@brenken.org> | 2021-07-04 08:42:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-04 08:42:38 +0200 |
commit | 7da84e543f6e41878e78d3d15c7a0a93655be132 (patch) | |
tree | b26ddade9f193ac5db3a4768066f3ffa099c2941 /applications/luci-app-openvpn/luasrc/controller/openvpn.lua | |
parent | 9d15a4e70c10a43911c7f9d48240a01c23eb81b6 (diff) | |
parent | b6f36ca91b74e708cb8866a0299923dab3f5343b (diff) |
Merge pull request #5164 from dibdot/openvpn
luci-app-openvpn: create base directory if not available
Diffstat (limited to 'applications/luci-app-openvpn/luasrc/controller/openvpn.lua')
-rw-r--r-- | applications/luci-app-openvpn/luasrc/controller/openvpn.lua | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/applications/luci-app-openvpn/luasrc/controller/openvpn.lua b/applications/luci-app-openvpn/luasrc/controller/openvpn.lua index 2d57e8d3ad..a30ac81a99 100644 --- a/applications/luci-app-openvpn/luasrc/controller/openvpn.lua +++ b/applications/luci-app-openvpn/luasrc/controller/openvpn.lua @@ -13,13 +13,18 @@ function index() end function ovpn_upload() - local fs = require("nixio.fs") - local http = require("luci.http") - local util = require("luci.util") - local uci = require("luci.model.uci").cursor() - local upload = http.formvalue("ovpn_file") - local name = http.formvalue("instance_name2") - local file = "/etc/openvpn/" ..name.. ".ovpn" + local fs = require("nixio.fs") + local http = require("luci.http") + local util = require("luci.util") + local uci = require("luci.model.uci").cursor() + local upload = http.formvalue("ovpn_file") + local name = http.formvalue("instance_name2") + local basedir = "/etc/openvpn" + local file = basedir.. "/" ..name.. ".ovpn" + + if not fs.stat(basedir) then + fs.mkdir(basedir) + end if name and upload then local fp |