Skip to content

Instantly share code, notes, and snippets.

@johnrnelson
Created February 12, 2017 01:36
Show Gist options
  • Save johnrnelson/d6beb72a77e3359641e83dda893b7cb7 to your computer and use it in GitHub Desktop.
Save johnrnelson/d6beb72a77e3359641e83dda893b7cb7 to your computer and use it in GitHub Desktop.
#!/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