From b307b67c223ad233a5212b38d7c527dcd5508bc4 Mon Sep 17 00:00:00 2001 From: Alex Denes Date: Tue, 25 Jun 2024 09:15:20 +0000 Subject: [PATCH] Add disable and fix some paths --- main/nnd-s6-services/APKBUILD | 9 ++-- main/nnd-s6-services/manage.sh | 47 +++++++++++++++++-- .../rc/sysctl.dev-tty-legacy_tiocsti/down | 2 +- .../down | 2 +- .../down | 2 +- .../rc/sysctl.vm-nr_hugepages/down | 2 +- .../rc/sysctl.vm-overcommit_memory/down | 2 +- .../rc/sysctl.vm-overcommit_ratio/down | 2 +- .../rc/sysctl.vm-swappiness/down | 2 +- 9 files changed, 54 insertions(+), 16 deletions(-) diff --git a/main/nnd-s6-services/APKBUILD b/main/nnd-s6-services/APKBUILD index 8b97b0a..45d480d 100644 --- a/main/nnd-s6-services/APKBUILD +++ b/main/nnd-s6-services/APKBUILD @@ -3,7 +3,7 @@ . ../../APKBUILD.template pkgname=nnd-s6-services -pkgver=2.81 +pkgver=2.83 pkgrel=0 pkgdesc="Base services for s6" depends="s6-rc s6-portable-utils s6-linux-utils" @@ -35,9 +35,10 @@ package() { mkdir -p "$pkgdir"/etc/s6/env - mkdir -p "$pkgdir"/etc/s6/rc - mkdir -p "$pkgdir"/etc/s6/rc/default/contents.d - echo bundle > "$pkgdir"/etc/s6/rc/default/type + local RCPFX="/etc/s6/rc" + mkdir -p "$pkgdir"/"$RCPFX" + mkdir -p "$pkgdir"/"$RCPFX"/default/contents.d + echo bundle > "$pkgdir"/"$RCPFX"/default/type } check() { diff --git a/main/nnd-s6-services/manage.sh b/main/nnd-s6-services/manage.sh index a157908..9d47092 100755 --- a/main/nnd-s6-services/manage.sh +++ b/main/nnd-s6-services/manage.sh @@ -11,10 +11,14 @@ alt_ab() { if [ "$1" == "a" ]; then echo "b"; else echo "a"; fi } -: ${S6_PATH:="${XDG_DATA_HOME:="/etc"}/s6"} -: ${S6_DIST_PATH:="${XDG_CONFIG_HOME:="/usr/share"}/nnd/s6/dist"} -: ${S6_LIVE_PATH:="${XDG_RUNTIME_DIR:="/run"}/s6-rc"} -: ${S6_SCANDIR_PATH:="${XDG_RUNTIME_DIR:="/run"}/service"} +: ${XDG_CONFIG_HOME:="/etc"} +: ${XDG_DATA_HOME:="/usr/share"} +: ${XDG_RUNTIME_DIR:="/run"} + +: ${S6_PATH:="${XDG_CONFIG_HOME}/s6"} +: ${S6_DIST_PATH:="${XDG_DATA_HOME}/nnd/s6/dist"} +: ${S6_LIVE_PATH:="${XDG_RUNTIME_DIR}/s6-rc"} +: ${S6_SCANDIR_PATH:="${XDG_RUNTIME_DIR}/service"} : ${S6_RC_PATH:="$S6_PATH/rc"} : ${S6_ENV_PATH:="$S6_PATH/env"} : ${S6_SV_PATH:="$S6_PATH/sv"} @@ -116,6 +120,25 @@ default() { done } +disable() { + for svc in $@; do + local src="$S6_DIST_PATH/$svc" + local target="$S6_PATH/$svc" + + if ! [ -e "$src" ]; then + error "$svc doesn't exist" + return "$?" + fi + + if [ -f "$target" ]; then + error "$svc is already disabled" + return "$?" + fi + + disablefunc || return "$?" + done +} + custom() { for svc in $@; do local src="$S6_DIST_PATH/$svc" @@ -149,6 +172,20 @@ customfunc() { fi } +disablefunc() { + : ${src:?"Missing src in disablefunc"} + : ${target:?"Missing target in disablefunc"} + if ! rm "$target"; then + error "Failed to remove directory $target" + return "$?" + fi + + if ! touch "$target"; then + error "Failed to create empty file $target" + return "$?" + fi +} + defaultfunc() { : ${src:?"Missing src in defaultfunc"} : ${target:?"Missing target in defaultfunc"} @@ -191,7 +228,7 @@ if [ -z "$cmd" ]; then update || return "$?" else case "$cmd" in - generate|swap|update|dist|custom|default|cleanup) eval "$cmd" $@ || return "$?";; + generate|swap|update|dist|custom|disable|default|cleanup) eval "$cmd" $@ || return "$?";; *) error "Invalid command $cmd"; return 1;; esac fi diff --git a/main/nnd-s6-services/rc/sysctl.dev-tty-legacy_tiocsti/down b/main/nnd-s6-services/rc/sysctl.dev-tty-legacy_tiocsti/down index a90448e..ab6aa00 100644 --- a/main/nnd-s6-services/rc/sysctl.dev-tty-legacy_tiocsti/down +++ b/main/nnd-s6-services/rc/sysctl.dev-tty-legacy_tiocsti/down @@ -1,4 +1,4 @@ #!/bin/execlineb -P export VAL 0 export SYSCTL dev/tty/legacy_tiocsti -/usr/libexec/nnd/sysctl +/usr/libexec/nnd/s6/sysctl diff --git a/main/nnd-s6-services/rc/sysctl.kernel-unprivileged_userns_clone/down b/main/nnd-s6-services/rc/sysctl.kernel-unprivileged_userns_clone/down index 3e44b46..cc37124 100644 --- a/main/nnd-s6-services/rc/sysctl.kernel-unprivileged_userns_clone/down +++ b/main/nnd-s6-services/rc/sysctl.kernel-unprivileged_userns_clone/down @@ -1,4 +1,4 @@ #!/bin/execlineb -P export VAL 0 export SYSCTL kernel/unprivileged_userns_clone -/usr/libexec/nnd/sysctl +/usr/libexec/nnd/s6/sysctl diff --git a/main/nnd-s6-services/rc/sysctl.net-ipv4-ip_unprivileged_port_start/down b/main/nnd-s6-services/rc/sysctl.net-ipv4-ip_unprivileged_port_start/down index 2311e6a..21efe0c 100644 --- a/main/nnd-s6-services/rc/sysctl.net-ipv4-ip_unprivileged_port_start/down +++ b/main/nnd-s6-services/rc/sysctl.net-ipv4-ip_unprivileged_port_start/down @@ -1,4 +1,4 @@ #!/bin/execlineb -P export VAL 0 export SYSCTL net/ipv4/ip_unprivileged_port_start -/usr/libexec/nnd/sysctl +/usr/libexec/nnd/s6/sysctl diff --git a/main/nnd-s6-services/rc/sysctl.vm-nr_hugepages/down b/main/nnd-s6-services/rc/sysctl.vm-nr_hugepages/down index c250de5..3e833c0 100644 --- a/main/nnd-s6-services/rc/sysctl.vm-nr_hugepages/down +++ b/main/nnd-s6-services/rc/sysctl.vm-nr_hugepages/down @@ -1,4 +1,4 @@ #!/bin/execlineb -P export VAL 0 export SYSCTL vm/nr_hugepages -/usr/libexec/nnd/sysctl +/usr/libexec/nnd/s6/sysctl diff --git a/main/nnd-s6-services/rc/sysctl.vm-overcommit_memory/down b/main/nnd-s6-services/rc/sysctl.vm-overcommit_memory/down index 1222adf..aec1107 100644 --- a/main/nnd-s6-services/rc/sysctl.vm-overcommit_memory/down +++ b/main/nnd-s6-services/rc/sysctl.vm-overcommit_memory/down @@ -1,4 +1,4 @@ #!/bin/execlineb -P export VAL 0 export SYSCTL vm/overcommit_memory -/usr/libexec/nnd/sysctl +/usr/libexec/nnd/s6/sysctl diff --git a/main/nnd-s6-services/rc/sysctl.vm-overcommit_ratio/down b/main/nnd-s6-services/rc/sysctl.vm-overcommit_ratio/down index 6946129..755561b 100644 --- a/main/nnd-s6-services/rc/sysctl.vm-overcommit_ratio/down +++ b/main/nnd-s6-services/rc/sysctl.vm-overcommit_ratio/down @@ -1,4 +1,4 @@ #!/bin/execlineb -P export VAL 0 export SYSCTL vm/overcommit_ratio -/usr/libexec/nnd/sysctl +/usr/libexec/nnd/s6/sysctl diff --git a/main/nnd-s6-services/rc/sysctl.vm-swappiness/down b/main/nnd-s6-services/rc/sysctl.vm-swappiness/down index 9bdd626..a4e98c2 100644 --- a/main/nnd-s6-services/rc/sysctl.vm-swappiness/down +++ b/main/nnd-s6-services/rc/sysctl.vm-swappiness/down @@ -1,4 +1,4 @@ #!/bin/execlineb -P export VAL 0 export SYSCTL vm/swappiness -/usr/libexec/nnd/sysctl +/usr/libexec/nnd/s6/sysctl