From b6f36ca91b74e708cb8866a0299923dab3f5343b Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Fri, 2 Jul 2021 20:14:10 +0200 Subject: [PATCH] luci-app-openvpn: create base directory if not available * trivial fix for never ending ticket #3454 Signed-off-by: Dirk Brenken --- .../luasrc/controller/openvpn.lua | 19 ++++++++++++------- 1 file 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 -- 2.30.2