From: Dirk Brenken Date: Fri, 2 Jul 2021 18:14:10 +0000 (+0200) Subject: luci-app-openvpn: create base directory if not available X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d9430378f92a378b66f7e5f26bb82d7ccfd49230;p=project%2Fluci.git luci-app-openvpn: create base directory if not available * trivial fix for never ending ticket #3454 Signed-off-by: Dirk Brenken (cherry picked from commit b6f36ca91b74e708cb8866a0299923dab3f5343b) --- 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