]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - service_generator.sh
- add %nagios_nrpe
[packages/rpm-build-macros.git] / service_generator.sh
index dd52786c6bb06193edbbf1deecf70ec8b439c25f..2519854ae186b85c368c64613bf6a5ffb92586fa 100644 (file)
@@ -4,12 +4,13 @@ service="$1"
 action="$2"
 desc="$3"
 quiet=$quiet
+noop=$noop
 if [ -z "$desc" ]; then
        desc="$1 service"
 fi
 
 # action stop implies quiet mode and check disabling
-if [ $action = stop ]; then
+if [ "$action" = "stop" ]; then
        quiet=1
 else
        check=1
@@ -18,36 +19,43 @@ fi
 # common part
 service_body() {
        cat <<-EOF
-       if [ -f /var/lock/subsys/$service ]; then
-               /sbin/service $service $action 1>&2 || :;
-EOF
+               if [ -f /var/lock/subsys/$service ]; then
+       EOF
+       if [ "$noop" = 1 ]; then
+               echo :
+       else
+               cat <<-EOF
+                               /sbin/service $service $action 1>&2 || :;
+               EOF
+       fi
+
        if [ "$quiet" != 1 ]; then
                cat <<-EOF
                else
                        echo 'Run "/sbin/service $service start" to start $desc.'
-EOF
+               EOF
        fi
        cat <<-EOF
-       fi
-EOF
+               fi
+       EOF
 }
 
 # include check function
 skip_auto_restart_body() {
        cat <<-EOF
-       skip_auto_restart() {
-               [ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm
-               [ -f /etc/sysconfig/$service ] && . /etc/sysconfig/$service
-               echo \${RPM_SKIP_AUTO_RESTART:-no}
-       };
-EOF
+               skip_auto_restart() {
+                       [ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm
+                       [ -f /etc/sysconfig/$service ] && . /etc/sysconfig/$service
+                       echo \${RPM_SKIP_AUTO_RESTART:-no}
+               };
+       EOF
 }
 
 echo ''
 if [ "$check" = 1 ]; then
        skip_auto_restart_body
        echo 'if [ $(skip_auto_restart) = no ]; then'
-       service_body
+               service_body
        echo 'fi'
 else
        service_body
@@ -68,4 +76,5 @@ rpm -E '%service monit reload "Monit Daemon"' | sh
 rpm -E '%service monit reload -q "Monit Daemon"' | sh
 rpm -E '%{service monit reload "Monit Daemon"} date' | sh
 rpm -E '%{service monit reload "Monit Daemon" -q} date' | sh
+rpm -E '%{service -n monit restart "Monit Daemon" } date' | sh
 
This page took 0.036644 seconds and 4 git commands to generate.