graphite: restart collectd as well
(cherry picked from commit 0447dce0d6)
This commit is contained in:
+2
-8
@@ -13,9 +13,6 @@ yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/mkdirvolume.sh
|
|||||||
Defaults!/home/yellowtent/box/src/scripts/rmaddondir.sh env_keep="HOME BOX_ENV"
|
Defaults!/home/yellowtent/box/src/scripts/rmaddondir.sh env_keep="HOME BOX_ENV"
|
||||||
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/rmaddondir.sh
|
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/rmaddondir.sh
|
||||||
|
|
||||||
Defaults!/home/yellowtent/box/src/scripts/reloadnginx.sh env_keep="HOME BOX_ENV"
|
|
||||||
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/reloadnginx.sh
|
|
||||||
|
|
||||||
Defaults!/home/yellowtent/box/src/scripts/reboot.sh env_keep="HOME BOX_ENV"
|
Defaults!/home/yellowtent/box/src/scripts/reboot.sh env_keep="HOME BOX_ENV"
|
||||||
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/reboot.sh
|
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/reboot.sh
|
||||||
|
|
||||||
@@ -41,11 +38,8 @@ yellowtent ALL=(root) NOPASSWD:SETENV: /home/yellowtent/box/src/scripts/backupup
|
|||||||
Defaults!/home/yellowtent/box/src/scripts/restart.sh env_keep="HOME BOX_ENV"
|
Defaults!/home/yellowtent/box/src/scripts/restart.sh env_keep="HOME BOX_ENV"
|
||||||
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/restart.sh
|
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/restart.sh
|
||||||
|
|
||||||
Defaults!/home/yellowtent/box/src/scripts/restartdocker.sh env_keep="HOME BOX_ENV"
|
Defaults!/home/yellowtent/box/src/scripts/restartservice.sh env_keep="HOME BOX_ENV"
|
||||||
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/restartdocker.sh
|
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/restartservice.sh
|
||||||
|
|
||||||
Defaults!/home/yellowtent/box/src/scripts/restartunbound.sh env_keep="HOME BOX_ENV"
|
|
||||||
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/restartunbound.sh
|
|
||||||
|
|
||||||
Defaults!/home/yellowtent/box/src/scripts/rmmailbox.sh env_keep="HOME BOX_ENV"
|
Defaults!/home/yellowtent/box/src/scripts/rmmailbox.sh env_keep="HOME BOX_ENV"
|
||||||
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/rmmailbox.sh
|
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/rmmailbox.sh
|
||||||
|
|||||||
+3
-3
@@ -54,8 +54,8 @@ var acme2 = require('./cert/acme2.js'),
|
|||||||
users = require('./users.js'),
|
users = require('./users.js'),
|
||||||
util = require('util');
|
util = require('util');
|
||||||
|
|
||||||
var NGINX_APPCONFIG_EJS = fs.readFileSync(__dirname + '/nginxconfig.ejs', { encoding: 'utf8' }),
|
const NGINX_APPCONFIG_EJS = fs.readFileSync(__dirname + '/nginxconfig.ejs', { encoding: 'utf8' });
|
||||||
RELOAD_NGINX_CMD = path.join(__dirname, 'scripts/reloadnginx.sh');
|
const RESTART_SERVICE_CMD = path.join(__dirname, 'scripts/restartservice.sh');
|
||||||
|
|
||||||
function nginxLocation(s) {
|
function nginxLocation(s) {
|
||||||
if (!s.startsWith('!')) return s;
|
if (!s.startsWith('!')) return s;
|
||||||
@@ -172,7 +172,7 @@ function validateCertificate(location, domainObject, certificate) {
|
|||||||
function reload(callback) {
|
function reload(callback) {
|
||||||
if (constants.TEST) return callback();
|
if (constants.TEST) return callback();
|
||||||
|
|
||||||
shell.sudo('reload', [ RELOAD_NGINX_CMD ], {}, function (error) {
|
shell.sudo('reload', [ RESTART_SERVICE_CMD, 'nginx' ], {}, function (error) {
|
||||||
if (error) return callback(new BoxError(BoxError.NGINX_ERROR, `Error reloading nginx: ${error.message}`));
|
if (error) return callback(new BoxError(BoxError.NGINX_ERROR, `Error reloading nginx: ${error.message}`));
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -eu -o pipefail
|
|
||||||
|
|
||||||
if [[ ${EUID} -ne 0 ]]; then
|
|
||||||
echo "This script should be run as root." > /dev/stderr
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $# == 1 && "$1" == "--check" ]]; then
|
|
||||||
echo "OK"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${BOX_ENV}" == "cloudron" ]]; then
|
|
||||||
nginx -s reload
|
|
||||||
fi
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -eu -o pipefail
|
|
||||||
|
|
||||||
if [[ ${EUID} -ne 0 ]]; then
|
|
||||||
echo "This script should be run as root." > /dev/stderr
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $# == 1 && "$1" == "--check" ]]; then
|
|
||||||
echo "OK"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${BOX_ENV}" == "cloudron" ]]; then
|
|
||||||
systemctl restart docker
|
|
||||||
fi
|
|
||||||
|
|
||||||
Executable
+37
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu -o pipefail
|
||||||
|
|
||||||
|
if [[ ${EUID} -ne 0 ]]; then
|
||||||
|
echo "This script should be run as root." > /dev/stderr
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $# -eq 0 ]]; then
|
||||||
|
echo "No arguments supplied"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" == "--check" ]]; then
|
||||||
|
echo "OK"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ "${BOX_ENV}" != "cloudron" ]] && exit
|
||||||
|
|
||||||
|
service="$1"
|
||||||
|
|
||||||
|
if [[ "${service}" == "unbound" ]]; then
|
||||||
|
unbound-anchor -a /var/lib/unbound/root.key
|
||||||
|
systemctl restart unbound
|
||||||
|
elif [[ "${service}" == "nginx" ]]; then
|
||||||
|
nginx -s reload
|
||||||
|
elif [[ "${service}" == "docker" ]]; then
|
||||||
|
systemctl restart docker
|
||||||
|
elif [[ "${service}" == "collectd" ]]; then
|
||||||
|
systemctl restart collectd
|
||||||
|
else
|
||||||
|
echo "Unknown service ${service}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -eu -o pipefail
|
|
||||||
|
|
||||||
if [[ ${EUID} -ne 0 ]]; then
|
|
||||||
echo "This script should be run as root." > /dev/stderr
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $# == 1 && "$1" == "--check" ]]; then
|
|
||||||
echo "OK"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${BOX_ENV}" == "cloudron" ]]; then
|
|
||||||
unbound-anchor -a /var/lib/unbound/root.key
|
|
||||||
systemctl restart unbound
|
|
||||||
fi
|
|
||||||
|
|
||||||
+16
-4
@@ -63,6 +63,7 @@ var appdb = require('./appdb.js'),
|
|||||||
const NOOP = function (app, options, callback) { return callback(); };
|
const NOOP = function (app, options, callback) { return callback(); };
|
||||||
const NOOP_CALLBACK = function (error) { if (error) debug(error); };
|
const NOOP_CALLBACK = function (error) { if (error) debug(error); };
|
||||||
const RMADDONDIR_CMD = path.join(__dirname, 'scripts/rmaddondir.sh');
|
const RMADDONDIR_CMD = path.join(__dirname, 'scripts/rmaddondir.sh');
|
||||||
|
const RESTART_SERVICE_CMD = path.join(__dirname, 'scripts/restartservice.sh');
|
||||||
|
|
||||||
// setup can be called multiple times for the same app (configure crash restart) and existing data must not be lost
|
// setup can be called multiple times for the same app (configure crash restart) and existing data must not be lost
|
||||||
// teardown is destructive. app data stored with the addon is lost
|
// teardown is destructive. app data stored with the addon is lost
|
||||||
@@ -218,7 +219,7 @@ const SERVICES = {
|
|||||||
},
|
},
|
||||||
graphite: {
|
graphite: {
|
||||||
status: statusGraphite,
|
status: statusGraphite,
|
||||||
restart: docker.restartContainer.bind(null, 'graphite'),
|
restart: restartGraphite,
|
||||||
defaultMemoryLimit: 256 * 1024 * 1024
|
defaultMemoryLimit: 256 * 1024 * 1024
|
||||||
},
|
},
|
||||||
nginx: {
|
nginx: {
|
||||||
@@ -2062,7 +2063,7 @@ function statusDocker(callback) {
|
|||||||
function restartDocker(callback) {
|
function restartDocker(callback) {
|
||||||
assert.strictEqual(typeof callback, 'function');
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|
||||||
shell.sudo('restartdocker', [ path.join(__dirname, 'scripts/restartdocker.sh') ], {}, NOOP_CALLBACK);
|
shell.sudo('restartdocker', [ RESTART_SERVICE_CMD, 'docker' ], {}, NOOP_CALLBACK);
|
||||||
|
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
@@ -2078,7 +2079,7 @@ function statusUnbound(callback) {
|
|||||||
function restartUnbound(callback) {
|
function restartUnbound(callback) {
|
||||||
assert.strictEqual(typeof callback, 'function');
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|
||||||
shell.sudo('restartunbound', [ path.join(__dirname, 'scripts/restartunbound.sh') ], {}, NOOP_CALLBACK);
|
shell.sudo('restartunbound', [ RESTART_SERVICE_CMD, 'unbound' ], {}, NOOP_CALLBACK);
|
||||||
|
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
@@ -2094,7 +2095,7 @@ function statusNginx(callback) {
|
|||||||
function restartNginx(callback) {
|
function restartNginx(callback) {
|
||||||
assert.strictEqual(typeof callback, 'function');
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|
||||||
shell.sudo('reloadnginx', [ path.join(__dirname, 'scripts/reloadnginx.sh') ], {}, NOOP_CALLBACK);
|
shell.sudo('restartnginx', [ RESTART_SERVICE_CMD, 'nginx' ], {}, NOOP_CALLBACK);
|
||||||
|
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
@@ -2146,6 +2147,17 @@ function statusGraphite(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function restartGraphite(callback) {
|
||||||
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|
||||||
|
docker.restartContainer('graphite', callback);
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
// wait for graphite to startup and then restart collectd
|
||||||
|
shell.sudo('restartcollectd', [ RESTART_SERVICE_CMD, 'collectd' ], {}, NOOP_CALLBACK);
|
||||||
|
}, 10000);
|
||||||
|
}
|
||||||
|
|
||||||
function teardownOauth(app, options, callback) {
|
function teardownOauth(app, options, callback) {
|
||||||
assert.strictEqual(typeof app, 'object');
|
assert.strictEqual(typeof app, 'object');
|
||||||
assert.strictEqual(typeof options, 'object');
|
assert.strictEqual(typeof options, 'object');
|
||||||
|
|||||||
@@ -13,11 +13,9 @@ scripts=("${SOURCE_DIR}/src/scripts/clearvolume.sh" \
|
|||||||
"${SOURCE_DIR}/src/scripts/mvvolume.sh" \
|
"${SOURCE_DIR}/src/scripts/mvvolume.sh" \
|
||||||
"${SOURCE_DIR}/src/scripts/mkdirvolume.sh" \
|
"${SOURCE_DIR}/src/scripts/mkdirvolume.sh" \
|
||||||
"${SOURCE_DIR}/src/scripts/rmaddondir.sh" \
|
"${SOURCE_DIR}/src/scripts/rmaddondir.sh" \
|
||||||
"${SOURCE_DIR}/src/scripts/reloadnginx.sh" \
|
|
||||||
"${SOURCE_DIR}/src/scripts/reboot.sh" \
|
"${SOURCE_DIR}/src/scripts/reboot.sh" \
|
||||||
"${SOURCE_DIR}/src/scripts/restart.sh" \
|
"${SOURCE_DIR}/src/scripts/restart.sh" \
|
||||||
"${SOURCE_DIR}/src/scripts/restartdocker.sh" \
|
"${SOURCE_DIR}/src/scripts/restartservice.sh" \
|
||||||
"${SOURCE_DIR}/src/scripts/restartunbound.sh" \
|
|
||||||
"${SOURCE_DIR}/src/scripts/update.sh" \
|
"${SOURCE_DIR}/src/scripts/update.sh" \
|
||||||
"${SOURCE_DIR}/src/scripts/collectlogs.sh" \
|
"${SOURCE_DIR}/src/scripts/collectlogs.sh" \
|
||||||
"${SOURCE_DIR}/src/scripts/configurecollectd.sh" \
|
"${SOURCE_DIR}/src/scripts/configurecollectd.sh" \
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ describe('shell', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can sudo valid program', function (done) {
|
it('can sudo valid program', function (done) {
|
||||||
var RELOAD_NGINX_CMD = path.join(__dirname, '../src/scripts/reloadnginx.sh');
|
var RELOAD_NGINX_CMD = path.join(__dirname, '../src/scripts/restartservice.sh');
|
||||||
shell.sudo('test', [ RELOAD_NGINX_CMD ], {}, function (error) {
|
shell.sudo('test', [ RELOAD_NGINX_CMD, 'nginx' ], {}, function (error) {
|
||||||
expect(error).to.be.ok();
|
expect(error).to.be.ok();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user