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
# 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
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