1 Commits

Author SHA1 Message Date
fdff324081 Fix runit/s6 calamares chroot service activation 2024-08-10 17:21:06 +02:00
16 changed files with 35 additions and 200 deletions

View File

@@ -21,13 +21,8 @@ S6CRONIEHOOKS = $(wildcard s6/cronie-hooks/*)
S6DBUSHOOKS = $(wildcard s6/dbus-hooks/*)
S6ATDHOOKS = $(wildcard s6/atd-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/*)
DINITSCRIPTS = $(wildcard dinit/scripts/*)
DINITHOOKS = $(wildcard dinit/hooks/*)
DINITCRONIEHOOKS = $(wildcard dinit/cronie-hooks/*)
DINITDBUSHOOKS = $(wildcard dinit/dbus-hooks/*)
@@ -83,16 +78,8 @@ install_s6: install_common
install $(MODE) $(S6HOOKS) $(DESTDIR)$(HOOKSDIR)
install_dinit: install_common
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 $(EMODE) $(DINITSCRIPTS) $(DESTDIR)$(SCRIPTSDIR)
install $(MODE) $(DINITHOOKS) $(DESTDIR)$(HOOKSDIR)
install_openrc_cronie: install_hook_common
install $(MODE) $(OPENRCCRONIEHOOKS) $(DESTDIR)$(HOOKSDIR)
@@ -125,4 +112,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 install_dinit_user install_dinit_user_spawn
.PHONY: install install_base install_s6 install_openrc install_runit install_dinit install_wrapper

View File

@@ -1,9 +0,0 @@
[Trigger]
Type = Package
Operation = Install
Target = 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

@@ -1,9 +0,0 @@
[Trigger]
Type = Package
Operation = Remove
Target = 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

@@ -1,11 +0,0 @@
[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

@@ -1,10 +0,0 @@
[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,25 +14,13 @@ 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>"
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>"
echo " dinitctl disable <service>"
svc_help
}
@@ -64,8 +52,6 @@ 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 ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
esac

View File

@@ -1,20 +0,0 @@
#!/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

@@ -1,28 +0,0 @@
#!/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 = Configuring user service & reexecuting init ...
Description = Reexecuting init ...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/openrc-hook reexec

View File

@@ -1,11 +0,0 @@
[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

@@ -1,10 +0,0 @@
[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,80 +1,46 @@
#!/bin/sh -e
openrc_live() {
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
if [ ! -f /run/openrc/softlevel ]; then
echo >&2 " Skipped: Current root is not booted."
exit 0
fi
}
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"
echo " ==> Start/stop/restart a service:"
echo " rc-service <service> <start/stop/restart>"
}
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"
echo " ==> Add a service to runlevel:"
echo " rc-update add <service> <runlevel>"
svc_help
}
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"
echo " ==> Remove a service from runlevel:"
echo " rc-update del <service> <runlevel>"
svc_help
}
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
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 ;;
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 ;;
# 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 ;;
reload) openrc_live; /usr/bin/rc-service "$@" reload ;;
add) svc_add_help ;;
del) svc_del_help ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
esac
exit 0

View File

@@ -22,6 +22,8 @@ cmds_dinit() {
}
cmds_runit() {
mkdir -p /run/runit
ln -s /etc/runit/runsvdir/current /run/runit/service 2>/dev/null
COMMANDS[start]="runsv /etc/runit/sv/${SV}"
COMMANDS[stop]="sv stop /etc/runit/sv/${SV}"
COMMANDS[enable]="ln -s /etc/runit/sv/${SV} /run/runit/service/"
@@ -84,3 +86,5 @@ case "${ACTION}" in
help) usage; exit 0 ;;
*) usage; exit 1 ;;
esac
[ ${INIT} == s6 ] && s6-db-reload