Browse Source

`up kill-all` confirmation prompt added

pull/7/head
Muthu Kumar 7 years ago
parent
commit
5f822feea5
  1. 10
      actions/killALL.js
  2. 23
      actions/killAllConfirm.js
  3. 2
      assets/tlds.txt
  4. 5
      index.js

10
actions/killALL.js

@ -2,6 +2,8 @@
const shell = require('shelljs');
const { EOL } = require('os');
const npath = require('../utils/nginxPath');
const conf = require('../utils/nginxConf');
@ -20,6 +22,12 @@ function killALL () {
shell.ln('-sf', npath.confD() + "default.conf",
npath.enabledSites() + "default.conf");
// Symlink the default.conf file from confD to sites-enabled
console.log("All servers were killed and reverted to default.");
console.log(EOL + [
"A backup of your old servers.up is " +
"saved in /etc/up-serve/servers.bak.up.",
"Check this if you need to."
].join(EOL) + EOL);
}
function noKill () {
@ -27,4 +35,4 @@ function noKill () {
}
module.exports.kill = killALL;
module.exports.noKill = noKill;
module.exports.noKill = noKill;

23
actions/killAllConfirm.js

@ -1,21 +1,18 @@
'use strict';
const readline = require('readline');
const readlineSync = require('readline-sync');
const killALL = require('./killALL').kill;
const noKill = require('./killALL').noKill;
const { noKill } = require('./killALL');
function killAllConfirm() {
console.log("\nThis action will destroy all nginx servers and return to default configuration.\nAre you sure you want to do this?" + "\nConfirm y[es] / n[o]:");
const rl = readline.createInterface({ input: process.stdin });
const line = () => new Promise(resolve => rl.once('line', resolve));
line().then(line => {
line.trim();
if((/^(y(es)?|n(o)?)$/).test(line)) {
line == "y" || "yes" ? killALL() : noKill();
}
});
console.log("\nThis action will destroy all nginx servers and return "
+ "to default configuration.");
if (readlineSync.keyInYN("Are you sure you want to do this?")) {
killALL();
}
else {
noKill();
}
}
module.exports = killAllConfirm;

2
assets/tlds.txt

@ -1,4 +1,4 @@
# Version 2017110701, Last Updated Wed Nov 8 07:07:02 2017 UTC
# Version 2017111900, Last Updated Sun Nov 19 07:07:01 2017 UTC
AAA
AARP
ABARTH

5
index.js

@ -92,11 +92,6 @@ program
.action(function() {
//new Promise(resolve => killed\killAllConfirm();
killAllConfirm();
console.log(EOL + [
"A backup of your old servers.up is " +
"saved in /etc/up-serve/servers.bak.up.",
"Check this if you need to."
].join(EOL) + EOL);
});
program

Loading…
Cancel
Save