Verified Commit 2abdc3c8 authored by Aral Balkan's avatar Aral Balkan
Browse files

Disable command now stops the server

parent 103add5f
......@@ -126,6 +126,7 @@ switch (true) {
case command.isDisable:
try {
childProcess.execSync('sudo systemctl disable web-server', {env: process.env})
childProcess.execSync('sudo systemctl stop web-server', {env: process.env})
} catch (error) {
console.error(error, '\n 👿 Error: Could not disable web server.\n')
process.exit(1)
......@@ -174,6 +175,8 @@ switch (true) {
// Launch as startup daemon.
//
ensureRoot('enable')
// Ensure systemd exists.
try {
childProcess.execSync('which systemctl', {env: process.env})
......@@ -262,3 +265,13 @@ switch (true) {
function clr (text, color) {
return process.stdout.isTTY ? ansi.format(text, color) : text
}
// Ensure we have root privileges and exit if we don’t.
function ensureRoot (commandName) {
if (process.getuid() !== 0) {
const nodeSyntax = `sudo node bin/webserver.js ${commandName}`
const binarySyntax = `sudo web-server ${commandName}`
console.log(`\n 👿 Error: Requires root. Please try again with ${runtime.isNode ? nodeSyntax : binarySyntax}\n`)
process.exit(1)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment