Improve logic for default, custom, disable and remove libvirt.stopall, already being handled by shutdown and causes undesired vm stops
This commit is contained in:
parent
ac6fb3b6aa
commit
1efe2874c3
@ -3,7 +3,7 @@
|
||||
. ../../APKBUILD.template
|
||||
|
||||
pkgname=nnd-s6-services
|
||||
pkgver=3.29
|
||||
pkgver=3.30
|
||||
pkgrel=0
|
||||
pkgdesc="Base services for s6"
|
||||
depends="
|
||||
|
@ -113,71 +113,37 @@ cleanup() {
|
||||
done
|
||||
}
|
||||
|
||||
default() {
|
||||
custom() {
|
||||
for svc in $@; do
|
||||
local src="$S6_DIST_RC_PATH/$svc"
|
||||
local target="$S6_RC_PATH/$svc"
|
||||
|
||||
if ! [ -e "$src" ]; then
|
||||
error "$svc doesn't exist"
|
||||
return "$?"
|
||||
fi
|
||||
|
||||
if [ -h "$target" ]; then
|
||||
error "$svc is already a default instance"
|
||||
return "$?"
|
||||
fi
|
||||
|
||||
defaultfunc || return "$?"
|
||||
customfunc || return "$?"
|
||||
done
|
||||
}
|
||||
|
||||
disable() {
|
||||
for svc in $@; do
|
||||
local src="$S6_DIST_RC_PATH/$svc"
|
||||
local target="$S6_RC_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() {
|
||||
default() {
|
||||
for svc in $@; do
|
||||
local src="$S6_DIST_RC_PATH/$svc"
|
||||
local target="$S6_RC_PATH/$svc"
|
||||
|
||||
if ! [ -e "$src" ]; then
|
||||
# Fallback to local rc dir
|
||||
src="$S6_RC_PATH/$svc"
|
||||
if ! [ -e "$src" ]; then
|
||||
error "$svc doesn't exist"
|
||||
return "$?"
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [ -h "$target" ]; then
|
||||
error "$svc is already a custom instance"
|
||||
return "$?"
|
||||
fi
|
||||
|
||||
customfunc || return "$?"
|
||||
defaultfunc || return "$?"
|
||||
done
|
||||
}
|
||||
|
||||
customfunc() {
|
||||
: ${src:?"Missing src in customfunc"}
|
||||
: ${target:?"Missing target in customfunc"}
|
||||
if ! cp -Lr "$src" "$target".tmp; then
|
||||
if ! [ -h "$target" ]; then
|
||||
error "$svc is already a custom instance"
|
||||
return "$?"
|
||||
fi
|
||||
|
||||
if ! cp -Lr "$(readlink "$target")" "$target".tmp; then
|
||||
error "Failed to initialise custom directory $target"
|
||||
return "$?"
|
||||
fi
|
||||
@ -190,9 +156,19 @@ customfunc() {
|
||||
}
|
||||
|
||||
disablefunc() {
|
||||
: ${src:?"Missing src in disablefunc"}
|
||||
: ${target:?"Missing target in disablefunc"}
|
||||
if ! rm "$target"; then
|
||||
|
||||
if ! [ -e "$target" ]; then
|
||||
error "$svc doesn't exist"
|
||||
return "$?"
|
||||
fi
|
||||
|
||||
if [ -f "$target" ]; then
|
||||
error "$svc is already disabled"
|
||||
return "$?"
|
||||
fi
|
||||
|
||||
if ! rm -rv "$target"; then
|
||||
error "Failed to remove directory $target"
|
||||
return "$?"
|
||||
fi
|
||||
@ -206,6 +182,17 @@ disablefunc() {
|
||||
defaultfunc() {
|
||||
: ${src:?"Missing src in defaultfunc"}
|
||||
: ${target:?"Missing target in defaultfunc"}
|
||||
|
||||
if [ -h "$target" ]; then
|
||||
error "$svc is already a default instance"
|
||||
return "$?"
|
||||
fi
|
||||
|
||||
if ! [ -e "$src" ]; then
|
||||
error "$svc doesn't exist"
|
||||
return "$?"
|
||||
fi
|
||||
|
||||
if ! rm -rf "$target"; then
|
||||
error "Failed to remove custom directory $target"
|
||||
return "$?"
|
||||
@ -282,12 +269,11 @@ makeusertree() {
|
||||
echo "oneshot" > "$S6_RC_PATH"/usertree."$UID".kickstart/type
|
||||
|
||||
# Usertree
|
||||
# TODO: own by user
|
||||
install -Dm400 <(echo "$RUNTIME_DIR") "$USRHOME/.config/s6/env/global/XDG_RUNTIME_DIR"
|
||||
install -Dm400 <(echo "$USRHOME/.cache") "$USRHOME/.config/s6/env/global/XDG_CACHE_HOME"
|
||||
install -Dm400 <(echo "$USRHOME/.config") "$USRHOME/.config/s6/env/global/XDG_CONFIG_HOME"
|
||||
install -Dm400 <(echo "$USRHOME/.local/share") "$USRHOME/.config/s6/env/global/XDG_DATA_HOME"
|
||||
install -Dm400 <(echo "$USRHOME/.local/state") "$USRHOME/.config/s6/env/global/XDG_STATE_HOME"
|
||||
install -o "$USR" -Dm400 <(echo "$RUNTIME_DIR") "$USRHOME/.config/s6/env/global/XDG_RUNTIME_DIR"
|
||||
install -o "$USR" -Dm400 <(echo "$USRHOME/.cache") "$USRHOME/.config/s6/env/global/XDG_CACHE_HOME"
|
||||
install -o "$USR" -Dm400 <(echo "$USRHOME/.config") "$USRHOME/.config/s6/env/global/XDG_CONFIG_HOME"
|
||||
install -o "$USR" -Dm400 <(echo "$USRHOME/.local/share") "$USRHOME/.config/s6/env/global/XDG_DATA_HOME"
|
||||
install -o "$USR" -Dm400 <(echo "$USRHOME/.local/state") "$USRHOME/.config/s6/env/global/XDG_STATE_HOME"
|
||||
|
||||
s6-usertree-maker \
|
||||
-d "$RUNTIME_DIR"/service \
|
||||
@ -302,6 +288,9 @@ makeusertree() {
|
||||
mkdir -vp "$S6_RC_PATH"/usertree."$UID"/dependencies.d
|
||||
touch "$S6_RC_PATH"/usertree."$UID"/dependencies.d/dir.run-user-"$UID"-service
|
||||
|
||||
mkdir -vp "$S6_RC_PATH"/logger.usertree."$UID"/dependencies.d
|
||||
touch "$S6_RC_PATH"/logger.usertree."$UID"/dependencies.d/dir.run-user-"$UID"
|
||||
|
||||
# Bundle for usertree
|
||||
mkdir -vp "$S6_RC_PATH"/bundle.usertree."$UID"/contents.d
|
||||
touch "$S6_RC_PATH"/bundle.usertree."$UID"/contents.d/usertree."$UID".kickstart
|
||||
@ -311,8 +300,7 @@ makeusertree() {
|
||||
# Service dirs
|
||||
mkdir -vp "$USR_S6_RC_PATH"/default/contents.d/
|
||||
echo "bundle" > "$USR_S6_RC_PATH"/default/type
|
||||
|
||||
chown -Rv "$USR" "$USRHOME"/.config/s6
|
||||
chown -Rv "$USR" "$USR_S6_RC_PATH"/default
|
||||
}
|
||||
|
||||
rename() {
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/execlineb -P
|
||||
pipeline { virsh list --name --all --state-running --state-paused --state-other }
|
||||
forstdin -E -C -p DOMAIN virsh destroy $DOMAIN
|
@ -1 +0,0 @@
|
||||
oneshot
|
Loading…
Reference in New Issue
Block a user