Created
February 12, 2017 01:36
-
-
Save johnrnelson/d6beb72a77e3359641e83dda893b7cb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
"use strict"; | |
/* | |
Easy script to bounce a box after updating it. | |
Make sure this file is executable and run it as root... | |
*/ | |
var exec = require('child_process').execFileSync; | |
if (process.env.USER != 'root') { | |
console.log("\r\nYou must be logged in as 'root' to use this utility. Type 'sudo' before the command.\r\n"); | |
process.exit(0); | |
} | |
else { | |
ExecProc('apt-get', ['update']); | |
ExecProc('apt-get', ['upgrade', '-y']); | |
ExecProc('wall', ['\r\n__________________\r\nThe system is going down right now by order of ROOT!!!']); | |
ExecProc('reboot', ['now']); | |
process.exit(0); | |
} | |
function ExecProc(proc, parms) { | |
try { | |
console.log(exec(proc, parms).toString()) | |
} | |
catch (errProc) { | |
console.log('Process Error:' + proc, parms); | |
process.exit(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment