5 Commits
2.0 ... 2.3.2

Author SHA1 Message Date
1f78e5fa1c dinit: handle user spawn in chroot 2025-08-15 16:55:18 +02:00
e5e819e337 dinit: add user spawn install & remove hooks 2025-08-15 16:16:02 +02:00
1729205a54 dinit: support user services with dinit-uuser-spawn 2025-08-15 13:05:10 +02:00
bd83fd645d openrc-hook: final refactor 2025-03-10 17:11:03 +01:00
c9518dae35 openrc-hook: fix user help 2025-03-10 16:14:31 +01:00
6 changed files with 118 additions and 47 deletions

View File

@@ -0,0 +1,11 @@
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = etc/dinit.d/user/*
[Action]
Description = Displaying dinit user service help ...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/dinit-hook addU
NeedsTargets

View File

@@ -0,0 +1,10 @@
[Trigger]
Type = Path
Operation = Remove
Target = etc/dinit.d/user/*
[Action]
Description = Displaying dinit user service help ...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/dinit-hook delU
NeedsTargets

View File

@@ -0,0 +1,11 @@
[Trigger]
Type = Path
Operation = Install
# Operation = Upgrade
Target = usr/lib/dinit.d/dinit-user-spawn
[Action]
Description = Enabling dinit user spawn ...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/dinit-hook userspawnE
NeedsTargets

View File

@@ -0,0 +1,10 @@
[Trigger]
Type = Path
Operation = Remove
Target = usr/lib/dinit.d/dinit-user-spawn
[Action]
Description = Disabling dinit user service help ...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/dinit-hook userspawnD
NeedsTargets

View File

@@ -14,13 +14,25 @@ svc_help(){
svc_add_help(){
echo " ==> Add a service:"
echo " dinitctl enable <service>"
echo " # dinitctl enable <service>"
svc_help
}
svc_del_help(){
echo " ==> Remove a service:"
echo " dinitctl disable <service>"
echo " # dinitctl disable <service>"
svc_help
}
svc_user_add_help(){
echo " ==> Add a user service:"
echo " $ dinitctl enable <service>"
svc_help
}
svc_user_del_help(){
echo " ==> Remove a user service:"
echo " $ dinitctl disable <service>"
svc_help
}
@@ -52,6 +64,22 @@ case $op in
restart) dinit_live; restart_service "$1" ;;
add) svc_add_help ;;
del) svc_del_help ;;
addU) svc_user_add_help ;;
delU) svc_user_del_help ;;
userspawnE)
if dinit_live; then
/usr/bin/dinitctl enable dinit-user-spawn
else
/usr/bin/dinitctl enable -o dinit-user-spawn
fi
;;
userspawnD)
if dinit_live; then
/usr/bin/dinitctl disable dinit-user-spawn
else
/usr/bin/dinitctl disable -o dinit-user-spawn
fi
;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
esac

View File

@@ -1,44 +1,51 @@
#!/bin/sh -e
openrc_live() {
if [ ! -f /run/openrc/softlevel ]; then
echo >&2 " Skipped: Current root is not booted."
exit 0
fi
if [ ! -f /run/openrc/softlevel ]; then
echo >&2 " Skipped: Current root is not booted."
exit 0
fi
}
each_conf() {
while read -r f; do
"$@" "/$f"
done
}
svc_help(){
echo " ==> Start/stop/restart a service:"
echo " rc-service <service> <start/stop/restart>"
arg="${1:-}"
str="${arg#--*}"
if [ -n "$str" ]; then
echo " ==> Start/stop/restart a $str service:"
else
echo " ==> Start/stop/restart a service:"
fi
echo " rc-service <service> <start/stop/restart>" "$arg"
}
svc_add_help(){
echo " ==> Add a service to runlevel:"
echo " rc-update add <service> <runlevel>"
svc_help
arg="${1:-}"
str="${arg#--*}"
if [ -n "$str" ]; then
echo " ==> Add a $str service to runlevel:"
else
echo " ==> Add a service to runlevel:"
fi
echo " rc-update add <service> <runlevel>" "$arg"
svc_help "$arg"
}
svc_del_help(){
echo " ==> Remove a service from runlevel:"
echo " rc-update del <service> <runlevel>"
svc_help
}
svc_user_help(){
echo " ==> Start/stop/restart a service:"
echo " rc-service -U <service> <start/stop/restart>"
}
svc_user_add_help(){
echo " ==> Add a user service to runlevel:"
echo " rc-update -U add <service> <runlevel>"
svc_help
}
svc_user_del_help(){
echo " ==> Remove a user service from runlevel:"
echo " rc-update -U del <service> <runlevel>"
svc_help
arg="${1:-}"
str="${arg#--*}"
if [ -n "$str" ]; then
echo " ==> Remove a $str service from runlevel:"
else
echo " ==> Remove a service from runlevel:"
fi
echo " rc-update del <service> <runlevel>" "$arg"
svc_help "$arg"
}
svc_user_ln() {
@@ -55,25 +62,19 @@ svc_user_ln() {
done
}
each_conf() {
while read -r f; do
"$@" "/$f"
done
}
op="$1"; shift
case $op in
sysctl) openrc_live; each_conf /usr/bin/sysctl -q -p ;;
binfmt) openrc_live; each_conf /usr/lib/openrc/sh/binfmt.sh ;;
reexec) svc_user_ln; openrc_live; /usr/bin/openrc-shutdown -R ;;
# For use by other packages
reload) openrc_live; /usr/bin/rc-service "$@" reload ;;
add) svc_add_help ;;
del) svc_del_help ;;
uadd) svc_user_add_help ;;
udel) svc_user_del_help ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
sysctl) openrc_live; each_conf /usr/bin/sysctl -q -p ;;
binfmt) openrc_live; each_conf /usr/lib/openrc/sh/binfmt.sh ;;
reexec) svc_user_ln; openrc_live; /usr/bin/openrc-shutdown -R ;;
# For use by other packages
reload) openrc_live; /usr/bin/rc-service "$@" reload ;;
add) svc_add_help ;;
del) svc_del_help ;;
uadd) svc_add_help "--user" ;;
udel) svc_del_help "--user" ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
esac
exit 0