summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2010-10-08 16:09:58 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2010-10-08 16:09:58 (GMT)
commitdc60626d2a0608c7bf90ce65027429596025de4e (patch)
tree5450090939f7a4195af4a48508a13f00d33b8e14
parent61418a3b5c233f56f4c2c6b8c5843b7ebe9b7cf6 (diff)
downloadserver-dc60626d2a0608c7bf90ce65027429596025de4e.tar.gz
Add a kolabctl script that just loops through a list of services, and
simply loops through a list of potential service providers. This gets us closer to not having to install / configure / maintain all services on every single server, as well as is more sustainable then keeping lists of operating systems and versions, along with the options of which LDAP server technology is in use. The script takes a very simple approach; if it's installed, it'll find it and execute the stated action on it. If it's not installed, it won't.
-rw-r--r--kolabd/kolabd/dist_conf/kolabctl96
1 files changed, 96 insertions, 0 deletions
diff --git a/kolabd/kolabd/dist_conf/kolabctl b/kolabd/kolabd/dist_conf/kolabctl
new file mode 100644
index 0000000..069236f
--- /dev/null
+++ b/kolabd/kolabd/dist_conf/kolabctl
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+function usage() {
+ echo "Usage: $0 <status|start|stop|restart> [service]"
+ echo ""
+ echo "Restart, start or stop the services that concern Kolab Groupware."
+ echo ""
+ echo "Specify 'all' for service to restart, stop or start all services."
+ exit 1
+}
+
+if [ $# -lt 2 -o $# -gt 3 ]; then
+ usage
+fi
+
+debug=0
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ status|start|stop|restart)
+ action=$1
+ shift
+ ;;
+
+ --debug)
+ debug=1
+ shift
+ ;;
+
+ *)
+ service=$1
+ shift
+ ;;
+
+ esac
+done
+
+declare -a services
+declare -a service_providers
+
+services[${#services[@]}]=ldap; service_providers[${#service_providers[@]}]=ldap
+services[${#services[@]}]=ldap; service_providers[${#service_providers[@]}]=dirsrv
+
+services[${#services[@]}]=mta; service_providers[${#service_providers[@]}]=sendmail
+services[${#services[@]}]=mta; service_providers[${#service_providers[@]}]=postfix
+services[${#services[@]}]=mta; service_providers[${#service_providers[@]}]=exim
+services[${#services[@]}]=mta; service_providers[${#service_providers[@]}]=qmail
+
+services[${#services[@]}]=imap; service_providers[${#service_providers[@]}]=cyrus
+services[${#services[@]}]=imap; service_providers[${#service_providers[@]}]=cyrus-imapd
+services[${#services[@]}]=imap; service_providers[${#service_providers[@]}]=kolab-cyrus-imapd
+services[${#services[@]}]=imap; service_providers[${#service_providers[@]}]=imapd
+services[${#services[@]}]=imap; service_providers[${#service_providers[@]}]=dovecot
+
+services[${#services[@]}]=httpd; service_providers[${#service_providers[@]}]=apache2
+services[${#services[@]}]=httpd; service_providers[${#service_providers[@]}]=httpd
+
+services[${#services[@]}]=antispam; service_providers[${#service_providers[@]}]=spamassassin
+services[${#services[@]}]=antispam; service_providers[${#service_providers[@]}]=spamd
+services[${#services[@]}]=antispam; service_providers[${#service_providers[@]}]=amavisd
+
+services[${#services[@]}]=antivirus; service_providers[${#service_providers[@]}]=clamd
+services[${#services[@]}]=antivirus; service_providers[${#service_providers[@]}]=clamd.amavisd
+services[${#services[@]}]=antivirus; service_providers[${#service_providers[@]}]=clamav-daemon
+services[${#services[@]}]=antivirus; service_providers[${#service_providers[@]}]=clamav
+services[${#services[@]}]=antivirus; service_providers[${#service_providers[@]}]=freshclam
+services[${#services[@]}]=antivirus; service_providers[${#service_providers[@]}]=clamav-freshclam
+
+service_num=0
+
+while [ ${service_num} -lt ${#services[@]} ]; do
+
+ if [ "${service}" == "all" -o \
+ "${service}" == "${services[${service_num}]}" -o \
+ "${service}" == "${service_providers[${service_num}]}" \
+ ]; then
+
+ [ ${debug} -gt 0 ] && \
+ echo "Checking service ${services[${service_num}]}, provider ${service_providers[${service_num}]}..."
+
+ service_provider=${service_providers[${service_num}]}
+
+ if [ -x "/etc/rc.d/init.d/${service_provider}" ]; then
+ [ ${debug} -gt 0 ] && \
+ echo "Service ${services[${service_num}]} / provider ${service_providers[${service_num}]} found."
+
+ /etc/rc.d/init.d/${service_provider} $action
+
+ else
+ [ ${debug} -gt 0 ] && \
+ echo "Service ${services[${service_num}]} / provider ${service_providers[${service_num}]} not installed."
+ fi
+ fi
+
+ let service_num++;
+done