]> git.pld-linux.org Git - packages/rpm-build-macros.git/commitdiff
- add "%service [-q] SERVICE ACTION" macro
authorElan Ruusamäe <glen@pld-linux.org>
Sun, 10 Jul 2005 11:43:40 +0000 (11:43 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    rpm.macros -> 1.228

rpm.macros

index a95bb6a53e6524277a7154865fcc2c5bb3460791..d3ed11e9d1111a09f6d3a465c31a81522dd73f10 100644 (file)
@@ -740,3 +740,36 @@ if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
        done ) \
 ) | ( %banner -t 5 -e %{name}-un ); fi; \
 }
+
+# service macro.
+#
+# calls usual service restart on package %post, but skips the restart if
+# administrator has disabled automatic service restarts in either global
+# /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
+#
+# written by glen@pld-linux.org.
+# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
+#
+# Usage:
+#   %service [-q] SERVICE ACTION
+#
+#  -q be silent when service isn't started (for postun scriplets)
+#
+%service(q) \
+# we use function, not to globber namespace with useless variables \
+skip_auto_restart() { \
+       . /etc/sysconfig/rpm # global setting \
+       [ -f /etc/sysconfig/%1 ] && . /etc/sysconfig/%1 # per service setting \
+       echo ${RPM_SKIP_AUTO_RESTART:-no} \
+} \
+if [ -f /var/lock/subsys/%1 ]; then \
+       if [ $(skip_auto_restart) = no ]; then \
+               /etc/rc.d/init.d/%1 %2 1>&2 \
+       else \
+               echo 'Run "/etc/rc.d/init.d/%1 %2" to %2 %1 service.' \
+       fi \
+else \
+       %{!-q:echo 'Run "/etc/rc.d/init.d/%1 start" to start %1 service.'} \
+       %{-q::} \
+fi;
+
This page took 0.040031 seconds and 4 git commands to generate.