Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fdff324081 |
@@ -4,6 +4,6 @@ Operation = Upgrade
|
|||||||
Target = openrc
|
Target = openrc
|
||||||
|
|
||||||
[Action]
|
[Action]
|
||||||
Description = Configuring user service & reexecuting init ...
|
Description = Reexecuting init ...
|
||||||
When = PostTransaction
|
When = PostTransaction
|
||||||
Exec = /usr/share/libalpm/scripts/openrc-hook reexec
|
Exec = /usr/share/libalpm/scripts/openrc-hook reexec
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -1,80 +1,46 @@
|
|||||||
#!/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
|
||||||
}
|
|
||||||
|
|
||||||
each_conf() {
|
|
||||||
while read -r f; do
|
|
||||||
"$@" "/$f"
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
svc_help(){
|
svc_help(){
|
||||||
arg="${1:-}"
|
echo " ==> Start/stop/restart a service:"
|
||||||
str="${arg#--*}"
|
echo " rc-service <service> <start/stop/restart>"
|
||||||
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(){
|
svc_add_help(){
|
||||||
arg="${1:-}"
|
echo " ==> Add a service to runlevel:"
|
||||||
str="${arg#--*}"
|
echo " rc-update add <service> <runlevel>"
|
||||||
if [ -n "$str" ]; then
|
svc_help
|
||||||
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(){
|
svc_del_help(){
|
||||||
arg="${1:-}"
|
echo " ==> Remove a service from runlevel:"
|
||||||
str="${arg#--*}"
|
echo " rc-update del <service> <runlevel>"
|
||||||
if [ -n "$str" ]; then
|
svc_help
|
||||||
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() {
|
each_conf() {
|
||||||
umin=$(grep "^UID_MIN" /etc/login.defs)
|
while read -r f; do
|
||||||
umax=$(grep "^UID_MAX" /etc/login.defs)
|
"$@" "/$f"
|
||||||
users=$(awk -F':' -v "min=${umin##UID_MIN}" -v "max=${umax##UID_MAX}" \
|
done
|
||||||
'{ 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) svc_user_ln; openrc_live; /usr/bin/openrc-shutdown -R ;;
|
reexec) 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 ;;
|
||||||
uadd) svc_add_help "--user" ;;
|
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
|
||||||
udel) svc_del_help "--user" ;;
|
|
||||||
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ cmds_dinit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmds_runit() {
|
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[start]="runsv /etc/runit/sv/${SV}"
|
||||||
COMMANDS[stop]="sv stop /etc/runit/sv/${SV}"
|
COMMANDS[stop]="sv stop /etc/runit/sv/${SV}"
|
||||||
COMMANDS[enable]="ln -s /etc/runit/sv/${SV} /run/runit/service/"
|
COMMANDS[enable]="ln -s /etc/runit/sv/${SV} /run/runit/service/"
|
||||||
@@ -84,3 +86,5 @@ case "${ACTION}" in
|
|||||||
help) usage; exit 0 ;;
|
help) usage; exit 0 ;;
|
||||||
*) usage; exit 1 ;;
|
*) usage; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
[ ${INIT} == s6 ] && s6-db-reload
|
||||||
|
|||||||
Reference in New Issue
Block a user