From 2afbe5d46d11a1c7dd46cd03010f838a705ba967 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Wed, 5 Sep 2018 17:07:02 +0300 Subject: dmvpn-ca: confirm database overwrite --- dmvpn-ca | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'dmvpn-ca') 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( { -- cgit v1.2.3