triggers/openrc-service: stop services in pre-remove.
--HG-- extra : convert_revision : 33ec8f3658010a878fc7599fba64129e0d653326
This commit is contained in:
parent
a2d08743c5
commit
ea578470eb
1 changed files with 14 additions and 4 deletions
|
@ -7,6 +7,8 @@
|
||||||
# $2 = target [post-install/pre-remove]
|
# $2 = target [post-install/pre-remove]
|
||||||
# $3 = pkgname
|
# $3 = pkgname
|
||||||
#
|
#
|
||||||
|
initdir=etc/init.d
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
targets)
|
targets)
|
||||||
echo "post-install pre-remove"
|
echo "post-install pre-remove"
|
||||||
|
@ -16,10 +18,11 @@ run)
|
||||||
[ ! -x sbin/rc-service ] && exit 0
|
[ ! -x sbin/rc-service ] && exit 0
|
||||||
[ -z "$openrc_services" ] && exit 1
|
[ -z "$openrc_services" ] && exit 1
|
||||||
|
|
||||||
if [ "$2" = "pre-remove" ]; then
|
target=$2
|
||||||
|
if [ "$target" = "pre-remove" ]; then
|
||||||
text="Unr"
|
text="Unr"
|
||||||
rcupdate_args="del"
|
rcupdate_args="del"
|
||||||
elif [ "$2" = "post-install" ]; then
|
elif [ "$target" = "post-install" ]; then
|
||||||
text="R"
|
text="R"
|
||||||
rcupdate_args="add"
|
rcupdate_args="add"
|
||||||
else
|
else
|
||||||
|
@ -31,13 +34,20 @@ run)
|
||||||
set -- ${openrc_services}
|
set -- ${openrc_services}
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
if sbin/rc-service -e ${1}; then
|
if sbin/rc-service -e ${1}; then
|
||||||
|
# Stop the service if it's running.
|
||||||
|
if [ "$target" = "pre-remove" -a -f $initdir/$1 ]; then
|
||||||
|
$initdir/$1 -q status
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
$initdir/$1 stop
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# (Un)register the service.
|
||||||
echo "${text}egistering ${1} OpenRC service..."
|
echo "${text}egistering ${1} OpenRC service..."
|
||||||
sbin/rc-update ${rcupdate_args} ${1} ${2}
|
sbin/rc-update ${rcupdate_args} ${1} ${2}
|
||||||
[ $? -ne 0 ] && exit $?
|
|
||||||
sbin/rc-update -u
|
|
||||||
fi
|
fi
|
||||||
shift; shift;
|
shift; shift;
|
||||||
done
|
done
|
||||||
|
sbin/rc-update -u
|
||||||
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
Loading…
Add table
Reference in a new issue