19 Commits
1.7 ... 2.4.3

Author SHA1 Message Date
a54971dada Merge pull request 'add dinit user spawn hook' (#28) from user-spawn into master
Reviewed-on: #28
2025-08-25 14:58:02 +02:00
6e5f39e281 add dinit user spawn hook 2025-08-25 14:58:25 +02:00
c4d712bcc4 dinit: separate user hook from system hook 2025-08-19 19:52:29 +07:00
199eee77c1 dinit: remove user spawn hooks, enabled ootb now 2025-08-16 15:14:52 +02:00
faca7dbca1 dinit: fix user spawn handling in chroot 2025-08-15 17:28:11 +02:00
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
51cf1104bd openrc: small refactoring 2025-03-08 23:03:00 +01:00
89b170310d remove live check from openrc-user-hook 2025-03-08 16:51:06 +01:00
4937e1ee11 Merge pull request 'add openrc-user-hook' (#27) from openrc-user-sv into master
Reviewed-on: #27
2025-03-08 16:30:54 +01:00
b6e6922998 add openrc-user-hook 2025-03-08 16:28:30 +01:00
48b9a2a9ec openrc (#26)
Reviewed-on: #26
2025-03-06 22:44:30 +00:00
e14878b49c artix-service: use dinitctl for disable and enable ops 2024-06-03 07:42:36 +07:00
31f3dda786 openrc: readd binfmt hook 2024-05-05 19:36:55 +02:00
09ef3fc619 Merge pull request 'unify binfmt into a single implementation' (#25) from binfmt into master
Reviewed-on: #25
2024-05-05 17:46:14 +02:00
9442565f14 unify binfmt into a single implementation
Since binfmt now lives in artix-groups, all the inits can use the same,
simplified hook.
2024-05-05 09:50:02 -05:00
21 changed files with 211 additions and 67 deletions

View File

@@ -21,8 +21,13 @@ S6CRONIEHOOKS = $(wildcard s6/cronie-hooks/*)
S6DBUSHOOKS = $(wildcard s6/dbus-hooks/*)
S6ATDHOOKS = $(wildcard s6/atd-hooks/*)
DINITSCRIPTS = $(wildcard dinit/scripts/*)
DINITHOOKS = $(wildcard dinit/hooks/*)
DINITSYSTEMSCRIPTS = $(wildcard dinit/scripts/system/*)
DINITUSERSCRIPTS = $(wildcard dinit/scripts/user/*)
DINITSYSTEMHOOKS = $(wildcard dinit/hooks/system/*)
DINITUSERHOOKS = $(wildcard dinit/hooks/user/*)
DINITUSERSPAWNSCRIPTS = $(wildcard dinit/scripts/user-spawn/*)
DINITUSERSPAWNHOOKS = $(wildcard dinit/hooks/user-spawn/*)
DINITCRONIEHOOKS = $(wildcard dinit/cronie-hooks/*)
DINITDBUSHOOKS = $(wildcard dinit/dbus-hooks/*)
@@ -78,8 +83,16 @@ install_s6: install_common
install $(MODE) $(S6HOOKS) $(DESTDIR)$(HOOKSDIR)
install_dinit: install_common
install $(EMODE) $(DINITSCRIPTS) $(DESTDIR)$(SCRIPTSDIR)
install $(MODE) $(DINITHOOKS) $(DESTDIR)$(HOOKSDIR)
install $(EMODE) $(DINITSYSTEMSCRIPTS) $(DESTDIR)$(SCRIPTSDIR)
install $(MODE) $(DINITSYSTEMHOOKS) $(DESTDIR)$(HOOKSDIR)
install_dinit_user: install_common
install $(EMODE) $(DINITUSERSCRIPTS) $(DESTDIR)$(SCRIPTSDIR)
install $(MODE) $(DINITUSERHOOKS) $(DESTDIR)$(HOOKSDIR)
install_dinit_user_spawn: install_common
install $(EMODE) $(DINITUSERSPAWNSCRIPTS) $(DESTDIR)$(SCRIPTSDIR)
install $(MODE) $(DINITUSERSPAWNHOOKS) $(DESTDIR)$(HOOKSDIR)
install_openrc_cronie: install_hook_common
install $(MODE) $(OPENRCCRONIEHOOKS) $(DESTDIR)$(HOOKSDIR)
@@ -112,4 +125,4 @@ install_wrapper:
install $(DMODE) $(DESTDIR)$(BINDIR)
install $(EMODE) $(WRAPPER) $(DESTDIR)$(BINDIR)
.PHONY: install install_base install_s6 install_openrc install_runit install_dinit install_wrapper
.PHONY: install install_base install_s6 install_openrc install_runit install_dinit install_wrapper install_dinit_user install_dinit_user_spawn

View File

@@ -7,5 +7,5 @@ Target = usr/lib/binfmt.d/*.conf
[Action]
Description = Registering binary formats...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/dinit-hook binfmt
Exec = /usr/lib/artix/binfmt.sh
NeedsTargets

View File

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

View File

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

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-user-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-user-hook delU
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
}
@@ -46,13 +58,14 @@ op="$1"; shift
case $op in
sysctl) dinit_live; each_conf /usr/bin/sysctl -q -p ;;
binfmt) dinit_live; /usr/bin/dinitctl restart binfmt ;;
dbus_reload) dinit_live; reload_dbus ;;
# For use by other packages
reload) dinit_live; /usr/bin/dinitctl reload "$@"; /usr/bin/dinitctl restart "$@" ;;
restart) dinit_live; restart_service "$1" ;;
add) svc_add_help ;;
del) svc_del_help ;;
addU) svc_user_add_help ;;
delU) svc_user_del_help ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
esac

View File

@@ -0,0 +1,20 @@
#!/bin/sh -e
handle_user_spawn() {
if [ ! -S /run/dinitctl ]; then
echo >&2 " Current root is not booted."
dinitctl "$1" -o "$2"
else
dinitctl "$1" "$2"
fi
}
op="$1"; shift
case $op in
enable) handle_user_spawn "$op" 'dinit-user-spawn' ;;
disable) handle_user_spawn "$op" 'dinit-user-spawn' ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
esac
exit 0

View File

@@ -0,0 +1,28 @@
#!/bin/sh -e
svc_help(){
echo " ==> Start/stop/restart a service:"
echo " dinitctl <start/stop/restart> <service>"
}
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
}
op="$1"; shift
case $op in
addU) svc_user_add_help ;;
delU) svc_user_del_help ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
esac
exit 0

View File

@@ -4,6 +4,6 @@ Operation = Upgrade
Target = openrc
[Action]
Description = Reexecuting init ...
Description = Configuring user service & reexecuting init ...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/openrc-hook reexec

View File

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

View File

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

View File

@@ -1,46 +1,80 @@
#!/bin/sh -e
openrc_live() {
if [ ! -f /run/openrc/softlevel ]; then
echo >&2 " Skipped: Current root is not booted."
exit 0
fi
}
svc_help(){
echo " ==> Start/stop/restart a service:"
echo " rc-service <service> <start/stop/restart>"
}
svc_add_help(){
echo " ==> Add a service to runlevel:"
echo " rc-update add <service> <runlevel>"
svc_help
}
svc_del_help(){
echo " ==> Remove a service from runlevel:"
echo " rc-update del <service> <runlevel>"
svc_help
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
while read -r f; do
"$@" "/$f"
done
}
svc_help(){
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(){
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(){
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() {
umin=$(grep "^UID_MIN" /etc/login.defs)
umax=$(grep "^UID_MAX" /etc/login.defs)
users=$(awk -F':' -v "min=${umin##UID_MIN}" -v "max=${umax##UID_MAX}" \
'{ if ( $3 >= min && $3 <= max ) print $0 }' /etc/passwd \
| cut -d: -f1)
for u in $users; do
if [ ! -e /etc/init.d/user.$u ]; then
ln -sv /etc/init.d/user /etc/init.d/user.$u
fi
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) openrc_live; /usr/bin/openrc-shutdown -R ;;
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 ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
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

View File

@@ -1,11 +0,0 @@
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = usr/lib/binfmt.d/*.conf
[Action]
Description = Registering binary formats...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/runit-hook binfmt
NeedsTargets

View File

@@ -34,7 +34,6 @@ op="$1"; shift
case $op in
sysctl) runit_live; each_conf /usr/bin/sysctl -q -p ;;
binfmt) runit_live; each_conf /usr/lib/rc/sv.d/binfmt once ;;
# For use by other packages
reload) runit_live; /usr/bin/sv "$@" reload ;;
add) svc_add_help ;;

View File

@@ -1,11 +0,0 @@
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = usr/lib/binfmt.d/*.conf
[Action]
Description = Registering binary formats...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/s6-rc-hook binfmt
NeedsTargets

View File

@@ -51,7 +51,6 @@ op="$1"; shift
case $op in
sysctl) s6_live; each_conf /usr/bin/sysctl -q -p ;;
binfmt) s6_live; sh /etc/s6/sv/binfmt/shell_up ;;
dbus_reload) s6_live; reload_dbus ;;
# For use by other packages
add) svc_add_help ;;

View File

@@ -17,8 +17,8 @@ cmds_s6() {
cmds_dinit() {
COMMANDS[start]="dinitctl start ${SV}"
COMMANDS[stop]="dinitctl stop ${SV}"
COMMANDS[enable]="ln -s /etc/dinit.d/${SV} /etc/dinit.d/boot.d/"
COMMANDS[disable]="rm /etc/dinit.d/boot.d/${SV}"
COMMANDS[enable]="dinitctl -o enable ${SV}"
COMMANDS[disable]="dinitctl -o disable ${SV}"
}
cmds_runit() {