3 Commits
1.9 ... 2.1

Author SHA1 Message Date
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
5 changed files with 47 additions and 54 deletions

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

@@ -5,7 +5,7 @@ Operation = Upgrade
Target = etc/user/init.d/*
[Action]
Description = Configuring openrc user ...
Description = Displaying openrc user service help ...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/openrc-user-hook create
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

@@ -24,6 +24,37 @@ svc_del_help(){
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_user_help
}
svc_user_del_help(){
echo " ==> Remove a user service from runlevel:"
echo " rc-update -U del <service> <runlevel>"
svc_user_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"
@@ -35,11 +66,13 @@ 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 ;;
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 ;;
esac

View File

@@ -1,50 +0,0 @@
#!/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 -U <service> <start/stop/restart>"
}
svc_add_help(){
echo " ==> Add a user service to runlevel:"
echo " rc-update -U add <service> <runlevel>"
svc_help
}
svc_del_help(){
echo " ==> Remove a user service from runlevel:"
echo " rc-update -U del <service> <runlevel>"
svc_help
}
create_user_symlinks() {
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
create) openrc_live; create_user_symlinks ;;
add) svc_add_help ;;
del) svc_del_help ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
esac
exit 0