2009-05-04 23:16:41 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Registers or unregisters OpenRC services into the specified
|
|
|
|
# runlevel.
|
|
|
|
#
|
|
|
|
# Arguments: $1 = action [run/targets]
|
|
|
|
# $2 = target [post-install/pre-remove]
|
|
|
|
# $3 = pkgname
|
|
|
|
#
|
2009-08-12 00:26:29 +02:00
|
|
|
initdir=etc/init.d
|
|
|
|
|
2009-05-04 23:16:41 +02:00
|
|
|
case "$1" in
|
|
|
|
targets)
|
|
|
|
echo "post-install pre-remove"
|
|
|
|
;;
|
|
|
|
run)
|
|
|
|
[ ! -x sbin/rc-update ] && exit 0
|
|
|
|
[ ! -x sbin/rc-service ] && exit 0
|
|
|
|
[ -z "$openrc_services" ] && exit 1
|
|
|
|
|
2009-08-12 00:26:29 +02:00
|
|
|
target=$2
|
|
|
|
if [ "$target" = "pre-remove" ]; then
|
2009-05-04 23:16:41 +02:00
|
|
|
text="Unr"
|
|
|
|
rcupdate_args="del"
|
2009-08-12 00:26:29 +02:00
|
|
|
elif [ "$target" = "post-install" ]; then
|
2009-05-04 23:16:41 +02:00
|
|
|
text="R"
|
|
|
|
rcupdate_args="add"
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-05-05 00:47:58 +02:00
|
|
|
[ ! -f etc/fstab ] && touch etc/fstab
|
|
|
|
|
2009-05-04 23:16:41 +02:00
|
|
|
set -- ${openrc_services}
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
if sbin/rc-service -e ${1}; then
|
2009-08-12 00:26:29 +02:00
|
|
|
# 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.
|
2009-05-04 23:16:41 +02:00
|
|
|
echo "${text}egistering ${1} OpenRC service..."
|
|
|
|
sbin/rc-update ${rcupdate_args} ${1} ${2}
|
|
|
|
fi
|
|
|
|
shift; shift;
|
|
|
|
done
|
2009-08-12 00:26:29 +02:00
|
|
|
sbin/rc-update -u
|
2009-05-04 23:16:41 +02:00
|
|
|
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|