Setup script cleanups: master
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Sun, 17 Mar 2013 23:27:02 +0000 (23:27 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Sun, 17 Mar 2013 23:36:48 +0000 (00:36 +0100)
- Debian:
  - do not launch daemons immediately
  - RUN_xxx= in separate default files for each daemon
  - workaround problem (kill -9) with start-stop-daemon after upgrade
- always stop and start explicitely instead of restart
- common function to setup daemon starting, cleanups
- proper enable/disable according to the $GLITE_LB_TYPE

org.glite.lb.harvester/project/debian.glite-lb-harvester.default [new file with mode: 0644]
org.glite.lb.logger/project/debian.glite-lb-interlogd.default [new file with mode: 0644]
org.glite.lb.logger/project/debian.glite-lb-logd.default [new file with mode: 0644]
org.glite.lb.logger/project/debian.glite-lb-notif-interlogd.default [new file with mode: 0644]
org.glite.lb.logger/project/debian.glite-lb-proxy-interlogd.default [new file with mode: 0644]
org.glite.lb.server/config/glite-lb
org.glite.lb.server/config/setup
org.glite.lb.server/project/debian.glite-lb-bkserverd.default [new file with mode: 0644]

diff --git a/org.glite.lb.harvester/project/debian.glite-lb-harvester.default b/org.glite.lb.harvester/project/debian.glite-lb-harvester.default
new file mode 100644 (file)
index 0000000..e387f65
--- /dev/null
@@ -0,0 +1 @@
+RUN_HARVESTER=no
diff --git a/org.glite.lb.logger/project/debian.glite-lb-interlogd.default b/org.glite.lb.logger/project/debian.glite-lb-interlogd.default
new file mode 100644 (file)
index 0000000..85f0133
--- /dev/null
@@ -0,0 +1 @@
+RUN_IL=no
diff --git a/org.glite.lb.logger/project/debian.glite-lb-logd.default b/org.glite.lb.logger/project/debian.glite-lb-logd.default
new file mode 100644 (file)
index 0000000..860183b
--- /dev/null
@@ -0,0 +1 @@
+RUN_LOGD=no
diff --git a/org.glite.lb.logger/project/debian.glite-lb-notif-interlogd.default b/org.glite.lb.logger/project/debian.glite-lb-notif-interlogd.default
new file mode 100644 (file)
index 0000000..6638d7c
--- /dev/null
@@ -0,0 +1 @@
+RUN_NOTIF_IL=no
diff --git a/org.glite.lb.logger/project/debian.glite-lb-proxy-interlogd.default b/org.glite.lb.logger/project/debian.glite-lb-proxy-interlogd.default
new file mode 100644 (file)
index 0000000..0242ae0
--- /dev/null
@@ -0,0 +1 @@
+RUN_PROXY_IL=no
index ef2ac3a..01f82f1 100644 (file)
@@ -94,12 +94,3 @@ GLITE_LB_RTM_DN='/C=UK/O=eScience/OU=Imperial/L=Physics/CN=heppc24.hep.ph.ic.ac.
 # harvester additional options
 #GLITE_LB_HARVESTER_OPTIONS=
 
-@debian@#
-@debian@# change to 'yes' to enable the individual deamons
-@debian@#
-@debian@RUN_SERVER=no
-@debian@RUN_IL=no
-@debian@RUN_PROXY_IL=no
-@debian@RUN_NOTIF_IL=no
-@debian@RUN_LOGD=no
-@debian@RUN_HARVESTER=no
index 7347d02..f0fda4a 100755 (executable)
@@ -116,6 +116,38 @@ EOF
 }
 
 
+setup_daemon() {
+       local name=$1
+       local id=$2
+       local enabled=$3
+
+@debian@       update-rc.d glite-lb-$name defaults >/dev/null
+@debian@       update-rc.d glite-lb-$name enable >/dev/null
+@debian@       grep -v ^RUN_ @defaultdir@/glite-lb-$name > /tmp/glite-lb-$name.$$
+@debian@       mv /tmp/glite-lb-$name.$$ @defaultdir@/glite-lb-$name
+       if test x"$enabled" = x"true"; then
+@fedora@               systemctl enable glite-lb-$name.service
+@fedora@               systemctl stop glite-lb-$name.service >/dev/null 2>&1 || :
+@fedora@               systemctl start glite-lb-$name.service || startup_error=1
+@debian@               echo "RUN_$id=yes" >> @defaultdir@/glite-lb-$name
+@debian@               /etc/init.d/glite-lb-$name stop >/dev/null 2>&1 || :
+@debian@               killall -9 glite-lb-$name >/dev/null 2>&1
+@debian@               /etc/init.d/glite-lb-$name start || startup_error=1
+@redhat@               /sbin/chkconfig glite-lb-$name on
+@redhat@               /sbin/service glite-lb-$name stop >/dev/null 2>&1 || :
+@redhat@               /sbin/service glite-lb-$name start || startup_error=1
+       else
+@fedora@               systemctl disable glite-lb-$name.service
+@fedora@               systemctl stop glite-lb-$name.service >/dev/null 2>&1 || :
+@debian@               /etc/init.d/glite-lb-$name stop >/dev/null 2>&1 || :
+@debian@               killall -9 glite-lb-$name >/dev/null 2>&1
+@debian@               echo "RUN_$id=no" >> @defaultdir@/glite-lb-$name
+@redhat@               /sbin/chkconfig glite-lb-$name off
+@redhat@               /sbin/service glite-lb-$name stop >/dev/null 2>&1 || :
+       fi
+}
+
+
 setup_all() {
        setup_db=1
        setup_certs=1
@@ -760,6 +792,9 @@ fi
 if test "$setup_startup" = "1" -a "$startup_error" != "1"; then
        [  -d $GLITE_HOME/dump ] || mkdir $GLITE_HOME/dump && chown $GLITE_USER:$GLITE_GROUP $GLITE_HOME/dump
        [  -d $GLITE_HOME/purge ] || mkdir $GLITE_HOME/purge && chown $GLITE_USER:$GLITE_GROUP $GLITE_HOME/purge
+
+       startup_error=0
+@fedora@
 @fedora@       case "$GLITE_LB_TYPE" in
 @fedora@       proxy)
 @fedora@               GLITE_LB_SERVER_PROXY_OPTIONS="-P "
@@ -787,93 +822,38 @@ if test "$setup_startup" = "1" -a "$startup_error" != "1"; then
 @fedora@       systemctl --system daemon-reload
 @fedora@
 @fedora@       systemctl enable mysqld.service
-@fedora@       systemctl enable glite-lb-bkserverd.service
-@fedora@       systemctl enable glite-lb-logd.service
-@fedora@       systemctl enable glite-lb-interlogd.service
-@fedora@       systemctl enable glite-lb-notif-interlogd.service
-@fedora@       if test x"$GLITE_LB_TYPE" = x"proxy" -o x"$GLITE_LB_TYPE" = x"both"; then
-@fedora@               systemctl enable glite-lb-proxy-interlogd.service
-@fedora@       else
-@fedora@               systemctl disable glite-lb-proxy-interlogd.service
-@fedora@       fi
-@fedora@       if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then
-@fedora@               systemctl enable glite-lb-harvester.service
-@fedora@       else
-@fedora@               systemctl disable glite-lb-harvester.service
-@fedora@       fi
-@fedora@
-@fedora@       startup_error=0
-@fedora@       systemctl restart glite-lb-bkserverd.service || startup_error=1
-@fedora@       systemctl restart glite-lb-logd.service || startup_error=1
-@fedora@       systemctl restart glite-lb-interlogd.service || startup_error=1
-@fedora@       systemctl restart glite-lb-notif-interlogd.service || startup_error=1
-@fedora@       if test x"$GLITE_LB_TYPE" = x"proxy" -o x"$GLITE_LB_TYPE" = x"both"; then
-@fedora@               systemctl restart glite-lb-proxy-interlogd.service || startup_error=1
-@fedora@       else
-@fedora@               systemctl stop glite-lb-proxy-interlogd.service >/dev/null 2>&1
-@fedora@       fi
-@fedora@       if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then
-@fedora@               systemctl restart glite-lb-harvester.service || startup_error=1
-@fedora@       else
-@fedora@               systemctl stop glite-lb-harvester.service >/dev/null 2>&1
-@fedora@       fi
-@debian@       run_proxy=no
-@debian@       run_harvester=no
-@debian@       if test x"$GLITE_LB_TYPE" = x"proxy" -o x"$GLITE_LB_TYPE" = x"both"; then
-@debian@               run_proxy=yes
-@debian@       fi
-@debian@       if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then
-@debian@               run_harvester=yes
-@debian@       fi
-@debian@       grep -v ^RUN_ @defaultdir@/glite-lb > /tmp/glite-lb
-@debian@       cat <<EOF >> /tmp/glite-lb
-@debian@RUN_SERVER=yes
-@debian@RUN_IL=yes
-@debian@RUN_PROXY_IL=$run_proxy
-@debian@RUN_NOTIF_IL=yes
-@debian@RUN_LOGD=yes
-@debian@RUN_HARVESTER=$run_harvester
-@debian@EOF
-@debian@       mv /tmp/glite-lb @defaultdir@/glite-lb
+@debian@       grep -v ^RUN_ @defaultdir@/glite-lb > /tmp/glite-lb.$$
+@debian@       mv /tmp/glite-lb.$$ @defaultdir@/glite-lb
 @debian@
-@debian@       startup_error=0
+@debian@       # legacy startup script
 @debian@       update-rc.d glite-lb-locallogger defaults >/dev/null 2>&1 || :
 @debian@       update-rc.d glite-lb-locallogger disable >/dev/null 2>&1 || :
-@debian@       for i in bkserverd logd interlogd notif-interlogd proxy-interlogd harvester; do
-@debian@               update-rc.d glite-lb-$i defaults
-@debian@               update-rc.d glite-lb-$i enable
-@debian@               $GLITE_LOCATION_ETC/init.d/glite-lb-$i restart || startup_error=1
-@debian@       done
+@debian@
 @redhat@       /sbin/chkconfig mysqld on
+@redhat@
+@redhat@       # legacy startup script
 @redhat@       /sbin/chkconfig glite-lb-locallogger off >/dev/null 2>&1 || :
-@redhat@       /sbin/chkconfig glite-lb-bkserverd on
-@redhat@       /sbin/chkconfig glite-lb-logd on
-@redhat@       /sbin/chkconfig glite-lb-interlogd on
-@redhat@       /sbin/chkconfig glite-lb-notif-interlogd on
-@redhat@       if test x"$GLITE_LB_TYPE" = x"proxy" -o x"$GLITE_LB_TYPE" = x"both"; then
-@redhat@               /sbin/chkconfig glite-lb-proxy-interlogd on
-@redhat@       else
-@redhat@               /sbin/chkconfig glite-lb-proxy-interlogd off
-@redhat@       fi
-@redhat@       if test x"$GLITE_LB_HARVETER_ENABLED" = x"true"; then
-@redhat@               /sbin/chkconfig glite-lb-harvester on
-@redhat@       else
-@redhat@               /sbin/chkconfig glite-lb-harvester off
-@redhat@       fi
 @redhat@
-@redhat@       startup_error=0
-@redhat@       for i in bkserverd logd interlogd notif-interlogd; do
-@redhat@               /sbin/service glite-lb-$i stop >/dev/null 2>&1 || :
-@redhat@               /sbin/service glite-lb-$i start || startup_error=1
-@redhat@        done
-@redhat@       /sbin/service glite-lb-proxy-interlogd stop >/dev/null 2>&1 || :
-@redhat@       if test x"$GLITE_LB_TYPE" = x"proxy" -o x"$GLITE_LB_TYPE" = x"both"; then
-@redhat@               /sbin/service glite-lb-proxy-interlogd start || startup_error=1
-@redhat@       fi
-@redhat@       /sbin/service glite-lb-proxy-harvester stop >/dev/null 2>&1 || :
-@redhat@       if test x"$GLITE_LB_HARVESTER_ENABLED" = x"true"; then
-@redhat@               /sbin/service glite-lb-harvester start || startup_error=1
-@redhat@       fi
+       setup_daemon bkserverd SERVER true
+       setup_daemon notif-interlogd NOTIF_IL true
+       case "$GLITE_LB_TYPE" in
+       proxy)
+               setup_daemon logd LOGD false
+               setup_daemon interlogd IL false
+               setup_daemon proxy-interlogd PROXY_IL true
+               ;;
+       both)
+               setup_daemon logd LOGD true
+               setup_daemon interlogd IL true
+               setup_daemon proxy-interlogd PROXY_IL true
+               ;;
+       *)
+               setup_daemon logd LOGD true
+               setup_daemon interlogd IL true
+               setup_daemon proxy-interlogd PROXY_IL false
+               ;;
+       esac
+       setup_daemon harvester HARVESTER "$GLITE_LB_HARVESTER_ENABLED"
 
        if test "$startup_error" = "0"; then
                qecho "Services started successfully"
diff --git a/org.glite.lb.server/project/debian.glite-lb-bkserverd.default b/org.glite.lb.server/project/debian.glite-lb-bkserverd.default
new file mode 100644 (file)
index 0000000..4e8c346
--- /dev/null
@@ -0,0 +1 @@
+RUN_SERVER=no