mirror of
https://github.com/void-linux/void-packages.git
synced 2025-08-02 02:42:56 +02:00
xbps-triggers: new bool arg for systemd-service trigger, to restart or not a service.
This commit is contained in:
parent
1ed2009674
commit
11a2ceb334
2 changed files with 48 additions and 28 deletions
|
@ -1,6 +1,13 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Enable and disable systemd services.
|
# Enable and disable systemd services. The systemd_services environmental
|
||||||
|
# variable is expected to be set as follows:
|
||||||
|
#
|
||||||
|
# SERVICE_NAME RESTART
|
||||||
|
# foo.service off
|
||||||
|
# blah.service on
|
||||||
|
#
|
||||||
|
# i.e systemd_services='foo.service off blah.service on'
|
||||||
#
|
#
|
||||||
# Arguments: $ACTION = [run/targets]
|
# Arguments: $ACTION = [run/targets]
|
||||||
# $TARGET = [post-install/pre-remove]
|
# $TARGET = [post-install/pre-remove]
|
||||||
|
@ -28,35 +35,48 @@ run)
|
||||||
systemd_booted=yes
|
systemd_booted=yes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$TARGET" = "pre-remove" ]; then
|
while [ $# -gt 0 ]; do
|
||||||
if [ "$UPDATE" = "no" ]; then
|
_srv="$1"
|
||||||
# package is being removed.
|
case "$2" in
|
||||||
# disable and stop the units.
|
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
|
||||||
systemctl --no-reload disable ${systemd_services} >/dev/null 2>&1 || :
|
restart=1
|
||||||
systemctl stop ${systemd_services} >/dev/null 2>&1 || :
|
;;
|
||||||
fi
|
*)
|
||||||
elif [ "$TARGET" = "post-install" ]; then
|
unset restart
|
||||||
if [ "$UPDATE" = "no" ]; then
|
;;
|
||||||
# package is being installed.
|
esac
|
||||||
# enable (but don't start) the units by default.
|
if [ "$TARGET" = "pre-remove" ]; then
|
||||||
systemctl enable ${systemd_services} >/dev/null 2>&1 || :
|
if [ "$UPDATE" = "no" ]; then
|
||||||
if [ "$systemd_booted" ]; then
|
# package is being removed.
|
||||||
# reload systemd if running.
|
# disable and stop the unit.
|
||||||
systemctl daemon-reload >/dev/null 2>&1 || :
|
systemctl --no-reload disable ${_srv} >/dev/null 2>&1 || :
|
||||||
|
systemctl stop ${_srv} >/dev/null 2>&1 || :
|
||||||
fi
|
fi
|
||||||
else
|
elif [ "$TARGET" = "post-install" ]; then
|
||||||
# package is being updated.
|
if [ "$UPDATE" = "no" ]; then
|
||||||
if [ "$system_booted" ]; then
|
# package is being installed.
|
||||||
# reload systemd if running.
|
# enable (but don't start) the unit by default.
|
||||||
systemctl daemon-reload >/dev/null 2>&1 || :
|
systemctl enable ${_srv} >/dev/null 2>&1 || :
|
||||||
|
if [ "$systemd_booted" ]; then
|
||||||
|
# reload systemd if running.
|
||||||
|
systemctl daemon-reload >/dev/null 2>&1 || :
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# package is being updated.
|
||||||
|
if [ "$system_booted" ]; then
|
||||||
|
# reload systemd if running.
|
||||||
|
systemctl daemon-reload >/dev/null 2>&1 || :
|
||||||
|
fi
|
||||||
|
if [ -n "$restart" ]; then
|
||||||
|
# try restarting package service.
|
||||||
|
systemctl try-restart ${_srv} >/dev/null 2>&1 || :
|
||||||
|
else
|
||||||
|
echo "systemd ${_srv} service must be restarted manually!"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# try restarting package services.
|
|
||||||
systemctl try-restart ${systemd_services} >/dev/null 2>&1 || :
|
|
||||||
fi
|
fi
|
||||||
else
|
shift; shift
|
||||||
exit 1
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Template file for 'xbps-triggers'
|
# Template file for 'xbps-triggers'
|
||||||
pkgname=xbps-triggers
|
pkgname=xbps-triggers
|
||||||
version=0.26
|
version=0.27
|
||||||
short_desc="XBPS triggers"
|
short_desc="XBPS triggers"
|
||||||
maintainer="Juan RP <xtraeme@gmail.com>"
|
maintainer="Juan RP <xtraeme@gmail.com>"
|
||||||
homepage="http://code.google.com/p/xbps"
|
homepage="http://code.google.com/p/xbps"
|
||||||
|
|
Loading…
Add table
Reference in a new issue