diff options
author | Dirk Brenken <dev@brenken.org> | 2021-07-02 20:14:10 +0200 |
---|---|---|
committer | Dirk Brenken <dev@brenken.org> | 2021-07-02 20:14:10 +0200 |
commit | b6f36ca91b74e708cb8866a0299923dab3f5343b (patch) | |
tree | ff9fc4c64d8a4e8890ab1eea2e5ef357ea2cd5e4 /applications/luci-app-openvpn/luasrc | |
parent | 81c26a8eb38a0a8f78d0d51e4b5705d0c65a0114 (diff) |
luci-app-openvpn: create base directory if not available
* trivial fix for never ending ticket #3454
Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'applications/luci-app-openvpn/luasrc')
-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 |