summaryrefslogtreecommitdiffstats
path: root/system/install-service.sh.in
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2023-03-14 11:40:24 -0400
committerGitHub <noreply@github.com>2023-03-14 11:40:24 -0400
commit2597f4f0354d8b7b746c8095dbf1c0a6e9c7b872 (patch)
tree7da54236c6e35c75259906d6e817aaca04819f8e /system/install-service.sh.in
parent48572591975d3cbd6cf81e9876ee671ceb93e1b1 (diff)
Add experimental support for running under runit. (#13841)
* Add basic runit service script for Netdata. * Integrate runit handling in install-service script. * Add new runit script to .gitignore. * Fix service file installation. We need to ensure the service directory actually gets created, and thus need to use `-D` with the `install` command. * Sync with system restructure. * Fix botched update to Makefile.am.
Diffstat (limited to 'system/install-service.sh.in')
-rwxr-xr-xsystem/install-service.sh.in58
1 files changed, 49 insertions, 9 deletions
diff --git a/system/install-service.sh.in b/system/install-service.sh.in
index 3784cd1fd9..9a37528c54 100755
--- a/system/install-service.sh.in
+++ b/system/install-service.sh.in
@@ -87,7 +87,7 @@ get_os_key() {
valid_types() {
case "${PLATFORM}" in
Linux)
- echo "detect systemd openrc lsb initd"
+ echo "detect ${LINUX_INIT_TYPES}"
;;
FreeBSD)
echo "detect freebsd"
@@ -475,8 +475,6 @@ initd_cmds() {
# =====================================================================
# runit support functions
-#
-# Currently not supported, this exists to provide useful error messages.
_check_runit() {
# if there is no runsvdir command, then it's not runit
@@ -503,19 +501,61 @@ check_runit() {
}
install_runit_service() {
- error "Detected runit, which we do not currently support."
- exit 3
+ if [ -d /etc/sv ]; then
+ svc_dir="/etc/sv/netdata"
+ elif [ -d /etc/runit/sv ]; then
+ svc_dir="/etc/runit/sv/netdata"
+ else
+ error "Failed to locate service directory"
+ exit 4
+ fi
+
+ if [ -d /service ]; then
+ live_svc_dir="/service"
+ elif [ -d /var/service ]; then
+ live_svc_dir="/var/service"
+ elif [ -d /run/runit/service ]; then
+ live_svc_dir="/run/runit/service"
+ elif [ -d /etc/runit/runsvdir/default ]; then
+ live_svc_dir="/etc/runit/runsvdir/default"
+ else
+ error "Failed to locate live service directory"
+ exit 4
+ fi
+
+ svc_file="${svc_dir}/run"
+
+ info "Installing runit service file."
+ if [ ! -f "${svc_file}" ] && [ "${ENABLE}" = "auto" ]; then
+ ENABLE="enable"
+ fi
+
+ if ! install -D -p -m 0755 -o 0 -g 0 "${SVC_SOURCE}/runit/run" "${svc_file}"; then
+ error "Failed to install service file."
+ exit 4
+ fi
+
+ case ${ENABLE} in
+ enable)
+ if ! ln -s "${svc_dir}" "${live_svc_dir}"; then
+ warning "Failed to enable the Netdata service."
+ fi
+ ;;
+ disable)
+ if ! rm "${live_svc_dir}/netdata"; then
+ warning "Failed to disable the Netdata service."
+ fi
+ ;;
+ esac
}
runit_cmds() {
- error "Detected runit, which we do not currently support."
- exit 3
+ NETDATA_START_CMD="sv start netdata"
+ NETDATA_STOP_CMD="sv stop netdata"
}
# =====================================================================
# WSL support functions
-#
-# Cannot be supported, this exists to provide useful error messages.
_check_wsl() {
# If uname -r contains the string WSL, then it's WSL.