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
|
. ../../APKBUILD.template
|
||||||
|
|
||||||
pkgname=nnd-s6-services
|
pkgname=nnd-s6-services
|
||||||
pkgver=3.29
|
pkgver=3.30
|
||||||
pkgrel=0
|
pkgrel=0
|
||||||
pkgdesc="Base services for s6"
|
pkgdesc="Base services for s6"
|
||||||
depends="
|
depends="
|
||||||
|
@ -113,71 +113,37 @@ cleanup() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
default() {
|
custom() {
|
||||||
for svc in $@; do
|
for svc in $@; do
|
||||||
local src="$S6_DIST_RC_PATH/$svc"
|
|
||||||
local target="$S6_RC_PATH/$svc"
|
local target="$S6_RC_PATH/$svc"
|
||||||
|
customfunc || return "$?"
|
||||||
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 "$?"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
for svc in $@; do
|
for svc in $@; do
|
||||||
local src="$S6_DIST_RC_PATH/$svc"
|
|
||||||
local target="$S6_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 "$?"
|
disablefunc || return "$?"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
custom() {
|
default() {
|
||||||
for svc in $@; do
|
for svc in $@; do
|
||||||
local src="$S6_DIST_RC_PATH/$svc"
|
local src="$S6_DIST_RC_PATH/$svc"
|
||||||
local target="$S6_RC_PATH/$svc"
|
local target="$S6_RC_PATH/$svc"
|
||||||
|
|
||||||
if ! [ -e "$src" ]; then
|
defaultfunc || return "$?"
|
||||||
# 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 "$?"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
customfunc() {
|
customfunc() {
|
||||||
: ${src:?"Missing src in customfunc"}
|
|
||||||
: ${target:?"Missing target 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"
|
error "Failed to initialise custom directory $target"
|
||||||
return "$?"
|
return "$?"
|
||||||
fi
|
fi
|
||||||
@ -190,9 +156,19 @@ customfunc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disablefunc() {
|
disablefunc() {
|
||||||
: ${src:?"Missing src in disablefunc"}
|
|
||||||
: ${target:?"Missing target 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"
|
error "Failed to remove directory $target"
|
||||||
return "$?"
|
return "$?"
|
||||||
fi
|
fi
|
||||||
@ -206,6 +182,17 @@ disablefunc() {
|
|||||||
defaultfunc() {
|
defaultfunc() {
|
||||||
: ${src:?"Missing src in defaultfunc"}
|
: ${src:?"Missing src in defaultfunc"}
|
||||||
: ${target:?"Missing target 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
|
if ! rm -rf "$target"; then
|
||||||
error "Failed to remove custom directory $target"
|
error "Failed to remove custom directory $target"
|
||||||
return "$?"
|
return "$?"
|
||||||
@ -282,12 +269,11 @@ makeusertree() {
|
|||||||
echo "oneshot" > "$S6_RC_PATH"/usertree."$UID".kickstart/type
|
echo "oneshot" > "$S6_RC_PATH"/usertree."$UID".kickstart/type
|
||||||
|
|
||||||
# Usertree
|
# Usertree
|
||||||
# TODO: own by user
|
install -o "$USR" -Dm400 <(echo "$RUNTIME_DIR") "$USRHOME/.config/s6/env/global/XDG_RUNTIME_DIR"
|
||||||
install -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 -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 -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 -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"
|
||||||
install -Dm400 <(echo "$USRHOME/.local/state") "$USRHOME/.config/s6/env/global/XDG_STATE_HOME"
|
|
||||||
|
|
||||||
s6-usertree-maker \
|
s6-usertree-maker \
|
||||||
-d "$RUNTIME_DIR"/service \
|
-d "$RUNTIME_DIR"/service \
|
||||||
@ -302,6 +288,9 @@ makeusertree() {
|
|||||||
mkdir -vp "$S6_RC_PATH"/usertree."$UID"/dependencies.d
|
mkdir -vp "$S6_RC_PATH"/usertree."$UID"/dependencies.d
|
||||||
touch "$S6_RC_PATH"/usertree."$UID"/dependencies.d/dir.run-user-"$UID"-service
|
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
|
# Bundle for usertree
|
||||||
mkdir -vp "$S6_RC_PATH"/bundle.usertree."$UID"/contents.d
|
mkdir -vp "$S6_RC_PATH"/bundle.usertree."$UID"/contents.d
|
||||||
touch "$S6_RC_PATH"/bundle.usertree."$UID"/contents.d/usertree."$UID".kickstart
|
touch "$S6_RC_PATH"/bundle.usertree."$UID"/contents.d/usertree."$UID".kickstart
|
||||||
@ -311,8 +300,7 @@ makeusertree() {
|
|||||||
# Service dirs
|
# Service dirs
|
||||||
mkdir -vp "$USR_S6_RC_PATH"/default/contents.d/
|
mkdir -vp "$USR_S6_RC_PATH"/default/contents.d/
|
||||||
echo "bundle" > "$USR_S6_RC_PATH"/default/type
|
echo "bundle" > "$USR_S6_RC_PATH"/default/type
|
||||||
|
chown -Rv "$USR" "$USR_S6_RC_PATH"/default
|
||||||
chown -Rv "$USR" "$USRHOME"/.config/s6
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rename() {
|
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