aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdmvpn-ca26
1 files changed, 21 insertions, 5 deletions
diff --git a/dmvpn-ca b/dmvpn-ca
index fa4d966..b8800b9 100755
--- a/dmvpn-ca
+++ b/dmvpn-ca
@@ -759,11 +759,9 @@ function print_table(tbl)
end
end
-function confirm(object, action, tbl)
- if not (unistd.isatty(0) and tbl[1]) then return end
-
- io.write('The following '..object..' will be '..action..':\n\n')
- print_table(tbl)
+function simple_confirm(func)
+ if not unistd.isatty(0) then return end
+ func()
io.write('\nContinue (y/n)? ')
io.stdout:flush()
local input = io.read()
@@ -771,6 +769,16 @@ function confirm(object, action, tbl)
io.write('\n')
end
+function confirm(object, action, tbl)
+ if #tbl == 0 then return end
+ simple_confirm(
+ function()
+ io.write('The following '..object..' will be '..action..':\n\n')
+ print_table(tbl)
+ end
+ )
+end
+
output = scan_choice(
scan_choice(
@@ -1021,6 +1029,14 @@ output = scan_choice(
generate=function()
scan_finished()
+ if stat.stat(config.db.file) then
+ simple_confirm(
+ function()
+ io.write('Current configuration and all keys will be lost.\n')
+ end
+ )
+ end
+
os.remove(config.db.file)
for _, statement in ipairs(
{