Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f78e5fa1c | |||
| e5e819e337 | |||
| 1729205a54 | |||
| bd83fd645d | |||
| c9518dae35 | |||
| 51cf1104bd | |||
| 89b170310d | |||
| 4937e1ee11 | |||
| b6e6922998 |
11
dinit/hooks/dinit-user-install.hook
Normal file
11
dinit/hooks/dinit-user-install.hook
Normal 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
|
||||||
10
dinit/hooks/dinit-user-remove.hook
Normal file
10
dinit/hooks/dinit-user-remove.hook
Normal 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
|
||||||
11
dinit/hooks/dinit-user-spawn-install.hook
Normal file
11
dinit/hooks/dinit-user-spawn-install.hook
Normal 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
|
||||||
10
dinit/hooks/dinit-user-spawn-remove.hook
Normal file
10
dinit/hooks/dinit-user-spawn-remove.hook
Normal 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
|
||||||
@@ -14,13 +14,25 @@ svc_help(){
|
|||||||
|
|
||||||
svc_add_help(){
|
svc_add_help(){
|
||||||
echo " ==> Add a service:"
|
echo " ==> Add a service:"
|
||||||
echo " dinitctl enable <service>"
|
echo " # dinitctl enable <service>"
|
||||||
svc_help
|
svc_help
|
||||||
}
|
}
|
||||||
|
|
||||||
svc_del_help(){
|
svc_del_help(){
|
||||||
echo " ==> Remove a service:"
|
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
|
svc_help
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +64,22 @@ case $op in
|
|||||||
restart) dinit_live; restart_service "$1" ;;
|
restart) dinit_live; restart_service "$1" ;;
|
||||||
add) svc_add_help ;;
|
add) svc_add_help ;;
|
||||||
del) svc_del_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 ;;
|
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ Operation = Upgrade
|
|||||||
Target = openrc
|
Target = openrc
|
||||||
|
|
||||||
[Action]
|
[Action]
|
||||||
Description = Reexecuting init ...
|
Description = Configuring user service & reexecuting init ...
|
||||||
When = PostTransaction
|
When = PostTransaction
|
||||||
Exec = /usr/share/libalpm/scripts/openrc-hook reexec
|
Exec = /usr/share/libalpm/scripts/openrc-hook reexec
|
||||||
|
|||||||
11
openrc/hooks/openrc-user-install.hook
Normal file
11
openrc/hooks/openrc-user-install.hook
Normal 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
|
||||||
10
openrc/hooks/openrc-user-remove.hook
Normal file
10
openrc/hooks/openrc-user-remove.hook
Normal 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
|
||||||
@@ -1,52 +1,80 @@
|
|||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
openrc_live() {
|
openrc_live() {
|
||||||
if [ ! -f /run/openrc/softlevel ]; then
|
if [ ! -f /run/openrc/softlevel ]; then
|
||||||
echo >&2 " Skipped: Current root is not booted."
|
echo >&2 " Skipped: Current root is not booted."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
svc_help(){
|
|
||||||
echo " ==> Start/stop/restart a service:"
|
|
||||||
echo " rc-service <service> <start/stop/restart>"
|
|
||||||
echo " ==> Further info on user services:"
|
|
||||||
echo "https://wiki.artixlinux.org/Main/OpenRC#User_Services"
|
|
||||||
}
|
|
||||||
|
|
||||||
svc_add_help(){
|
|
||||||
echo " ==> Add a service to runlevel:"
|
|
||||||
echo " rc-update add <service> <runlevel>"
|
|
||||||
echo " ==> Add a user service to runlevel:"
|
|
||||||
echo " rc-update add <service> <runlevel> -U"
|
|
||||||
svc_help
|
|
||||||
}
|
|
||||||
|
|
||||||
svc_del_help(){
|
|
||||||
echo " ==> Remove a service from runlevel:"
|
|
||||||
echo " rc-update del <service> <runlevel>"
|
|
||||||
echo " ==> Remove a user service from runlevel:"
|
|
||||||
echo " rc-update del <service> <runlevel> -U"
|
|
||||||
svc_help
|
|
||||||
}
|
}
|
||||||
|
|
||||||
each_conf() {
|
each_conf() {
|
||||||
while read -r f; do
|
while read -r f; do
|
||||||
"$@" "/$f"
|
"$@" "/$f"
|
||||||
done
|
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
|
op="$1"; shift
|
||||||
|
|
||||||
case $op in
|
case $op in
|
||||||
sysctl) openrc_live; each_conf /usr/bin/sysctl -q -p ;;
|
sysctl) openrc_live; each_conf /usr/bin/sysctl -q -p ;;
|
||||||
binfmt) openrc_live; each_conf /usr/lib/openrc/sh/binfmt.sh ;;
|
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
|
# For use by other packages
|
||||||
reload) openrc_live; /usr/bin/rc-service "$@" reload ;;
|
reload) openrc_live; /usr/bin/rc-service "$@" reload ;;
|
||||||
add) svc_add_help ;;
|
add) svc_add_help ;;
|
||||||
del) svc_del_help ;;
|
del) svc_del_help ;;
|
||||||
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
|
uadd) svc_add_help "--user" ;;
|
||||||
|
udel) svc_del_help "--user" ;;
|
||||||
|
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user