Commit 8fa830ad authored by Aral Balkan's avatar Aral Balkan
Browse files

Disable command now also disables managed Owncast service

parent e4128d53
......@@ -8,6 +8,7 @@
//////////////////////////////////////////////////////////////////////
const fs = require('fs')
const path = require('path')
const childProcess = require('child_process')
const status = require('../lib/status')
const Site = require('../../')
......@@ -28,6 +29,9 @@ function disable () {
throwError('Site.js server is not enabled. Nothing to disable.')
}
const systemdServicesDirectory = path.join('/', 'etc', 'systemd', 'system')
const owncastServiceFilePath = path.join(systemdServicesDirectory, 'owncast.service')
try {
// Disable and stop the web server.
childProcess.execSync('sudo systemctl disable site.js', {env: process.env, stdio: 'pipe'})
......@@ -38,6 +42,19 @@ function disable () {
} catch (error) {
throwError(`Site.js server disabled but could not delete the systemd service file (${error}).`)
}
// If we’re managing Owncast, disable that also.
if (fs.existsSync(owncastServiceFilePath)) {
console.log(' 💮️ ❨site.js❩ Also disabling Owncast service.')
childProcess.execSync('sudo systemctl disable owncast', {env: process.env, stdio: 'pipe'})
childProcess.execSync('sudo systemctl stop owncast', {env: process.env, stdio: 'pipe'})
try {
// And remove the systemd service file we created.
fs.unlinkSync('/etc/systemd/system/owncast.service')
} catch (error) {
throwError(`Owncast server disabled but could not delete the systemd service file (${error}).`)
}
}
} catch (error) {
throwError(`Could not disable Site.js server (${error}).`)
}
......
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