diff --git a/srcpkgs/xbps-triggers/files/systemd-service b/srcpkgs/xbps-triggers/files/systemd-service new file mode 100755 index 00000000000..fd56300f328 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/systemd-service @@ -0,0 +1,66 @@ +#!/bin/sh +# +# Enable and disable systemd services. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +export PATH="$PATH:/usr/local/bin" + +case "$ACTION" in +targets) + echo "post-install pre-remove" + ;; +run) + [ ! -x bin/systemctl ] && exit 0 + [ -z "${systemd_services}" ] && exit 1 + + if [ -e sys/fs/cgroups/systemd ]; then + systemd_booted=yes + fi + + if [ "$TARGET" = "pre-remove" ]; then + if [ "$UPDATE" = "no" ]; then + # package is being removed. + # disable and stop the units. + systemctl --no-reload disable ${systemd_services} >/dev/null 2>&1 || : + systemctl stop ${systemd_services} >/dev/null 2>&1 || : + fi + elif [ "$TARGET" = "post-install" ]; then + if [ "$UPDATE" = "no" ]; then + # package is being installed. + # enable (but don't start) the units by default. + systemctl enable ${systemd_services} >/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 + # try restarting package services. + systemctl try-restart ${systemd_services} >/dev/null 2>&1 || : + fi + else + exit 1 + fi + + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template index 2a6109009e3..9f4c75d6b0a 100644 --- a/srcpkgs/xbps-triggers/template +++ b/srcpkgs/xbps-triggers/template @@ -1,6 +1,6 @@ # Template file for 'xbps-triggers' pkgname=xbps-triggers -version=0.22 +version=0.23 build_style=custom-install short_desc="XBPS triggers" maintainer="Juan RP "