X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=service_generator.sh;h=7fa360b9120937a9bdc21764855b6bcc5a4f5bc8;hb=f51f5213a7611e36be1b4f179408517a9f36c7f8;hp=b0303ac90669d2200c48baaed451b6da9a3503c6;hpb=c1f02440b1aa4d9f906ce8bca9e59a032f9eb103;p=packages%2Frpm-build-macros.git diff --git a/service_generator.sh b/service_generator.sh old mode 100644 new mode 100755 index b0303ac..7fa360b --- a/service_generator.sh +++ b/service_generator.sh @@ -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,37 +19,55 @@ fi # common part service_body() { cat <<-EOF - if [ -f /var/lock/subsys/$service ]; then - /etc/rc.d/init.d/$service $action 1>&2 -EOF + if [ ! -x /bin/systemd_booted ] || ! /bin/systemd_booted; then + 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 "/etc/rc.d/init.d/$service start" to start $desc.' -EOF + else + echo 'Run "/sbin/service $service start" to start $desc.' + EOF fi cat <<-EOF - fi -EOF + fi + 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 'else' + # service restart was disabled, tell them to restart it + cat <<-EOF + if [ ! -x /bin/systemd_booted ] || ! /bin/systemd_booted; then + if [ -f /var/lock/subsys/$service ]; then + echo 'Run "/sbin/service $service restart" to restart $desc.' + fi + else NORESTART=1 # for %systemd_post if called after + fi + EOF echo 'fi' else service_body @@ -69,4 +88,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