diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2018-09-05 17:07:02 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2018-09-05 17:35:31 +0300 |
commit | 2afbe5d46d11a1c7dd46cd03010f838a705ba967 (patch) | |
tree | 704b10379d8bfa117ea87a2511f2df7df6fb604e | |
parent | fdb317f439fbb0e28ac3b154f13b963fe31facb4 (diff) | |
download | dmvpn-tools-2afbe5d46d11a1c7dd46cd03010f838a705ba967.tar.bz2 dmvpn-tools-2afbe5d46d11a1c7dd46cd03010f838a705ba967.tar.xz |
dmvpn-ca: confirm database overwritev0.6.0
-rwxr-xr-x | dmvpn-ca | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -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( { |