From ba8f61c8a5932476f945273bfdb0d66a73aa05f9 Mon Sep 17 00:00:00 2001 From: echicken Date: Wed, 25 Jul 2018 00:49:17 -0400 Subject: [PATCH] Fixed bug in last commit (url_suffix 'master') Crappy argument parsing. Command line parameters are now: -release=sbbs317 -defaults If -release omitted, 'master' archive will be fetched. If -defaults specified, installation will proceed without prompts and all default values will be accepted. --- mods/webv4-installer.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/mods/webv4-installer.js b/mods/webv4-installer.js index 38f9bf3..2224686 100644 --- a/mods/webv4-installer.js +++ b/mods/webv4-installer.js @@ -1,3 +1,11 @@ +const named_parameters = {}; +if (argv.length > 0) { + argv.forEach(function (e) { + const m = /-?((\w+)(?:=("[^"]+"|[^\s"]+))?)(?:\s+|$)/.exec(e); + named_parameters[m[2]] = (m[3] ? m[3] : null); + }); +} + load('http.js'); function download(url, target) { @@ -66,16 +74,19 @@ function set_service_ini(section, obj) { } function get_setting(text, value) { - const i = prompt(text + ' [' + value + ']'); - return (i == '' ? value : i); + if (typeof named_parameters.defaults != 'undefined') return value; + const i = prompt(text + ' [' + value + ']'); + return (i == '' ? value : i); } function confirm_setting(text, value) { - if (!value) { - return !deny(text + ' [' + value + ']'); - } else { - return confirm(text + ' [' + value + ']'); - } + if (typeof named_parameters.defaults != 'undefined') { + return value; + } else if (!value) { + return !deny(text + ' [' + value + ']'); + } else { + return confirm(text + ' [' + value + ']'); + } } function copy_dir_contents(src, dest, overwrite) { @@ -116,7 +127,7 @@ function remove_dir(dir) { rmdir(dir); } -const url_suffix = argc > 0 ? argv[0] : master; +const url_suffix = named_parameters.release ? named_parameters.release : 'master'; const zip_url = 'https://codeload.github.com/echicken/synchronet-web-v4/zip/' + url_suffix; const download_target = system.temp_dir + 'webv4.zip'; const extract_dir = fullpath(system.temp_dir); @@ -135,7 +146,7 @@ if (!modopts_web) { minimum_password_length : 6, maximum_telegram_length : 800, web_directory : install_dir, - ftelnet : true, + ftelnet : true, ftelnet_splash : '../text/synch.ans', keyboard_navigation : false, vote_functions : true, @@ -179,7 +190,7 @@ if (system.version_num < 31700) { write('\r\nIt is strongly recommended that you back up your BBS before proceeding.\r\n'); write('\r\nIf this is a new intallation, you must also shut down your BBS now.\r\n\r\n'); -if (deny('Proceed with installation/update')) { +if (typeof named_parameters.defaults == 'undefined' && deny('Proceed with installation/update')) { writeln('Install/update aborted. Exiting.'); exit(); }