events 41.httpd: support suse and ubuntu/debian systems for managing apache
authorMichael Adam <obnox@samba.org>
Tue, 3 Feb 2009 23:42:33 +0000 (00:42 +0100)
committerMichael Adam <obnox@samba.org>
Tue, 3 Feb 2009 23:42:33 +0000 (00:42 +0100)
The httpd service on suse and ubuntu/debian systems is usually
called "apache2" nowadays.

Note: There are older installs with Apache 1.3 out there, in which case
the service is called "apache". An extra check for these installs could
be useful as a sequel to this patch...

Michael

config/events.d/41.httpd

index 5f244d107402721a74e254b6b4dbb84afb68d089..fae9f47f55e159a21f3a84d0adff226e436233c0 100755 (executable)
@@ -3,7 +3,31 @@
 
 . $CTDB_BASE/functions
 loadconfig ctdb
-loadconfig http
+
+detect_init_style
+
+case $CTDB_INIT_STYLE in
+       redhat)
+               CTDB_SERVICE_HTTP="httpd"
+               CTDB_CONFIG_HTTP="http"
+               ;;
+       suse)
+               CTDB_SERVICE_HTTP="apache2"
+               CTDB_CONFIG_HTTP="apache2"
+               ;;
+       ubuntu)
+               CTDB_SERVICE_HTTP="apache2"
+               CTDB_CONFIG_HTTP="apache2"
+               ;;
+       *)
+               # should not happen.
+               # for now use red hat style as default
+               CTDB_SERVICE_HTTP="httpd"
+               CTDB_CONFIG_HTTP="http"
+               ;;
+esac
+
+loadconfig "${CTDB_CONFIG_HTTP}"
 
 [ "$CTDB_MANAGES_HTTPD" = "yes" ] || exit 0
 
@@ -12,12 +36,12 @@ shift
 
 case $cmd in 
      startup)
-        service httpd stop > /dev/null 2>&1
-        service httpd start
+        service "${CTDB_SERVICE_HTTP}" stop > /dev/null 2>&1
+        service "${CTDB_SERVICE_HTTP}" start
         ;;
 
      shutdown)
-        service httpd stop
+        service "${CTDB_SERVICE_HTTP}" stop
         ;;
 
      monitor)