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)
commitcf13d5d1211cd9b7bdcda3f67d4c1bf593a5ac54 (patch)
treea3d60d295c612ebce53059714c3f6d9fa30851e4
parentebb1d29c6e008c7072128e33f585e96b1a569447 (diff)
downloadkolab-conf-cf13d5d1211cd9b7bdcda3f67d4c1bf593a5ac54.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--conf/dist/kolabctl96
1 files changed, 96 insertions, 0 deletions
diff --git a/conf/dist/kolabctl b/conf/dist/kolabctl
new file mode 100644
index 0000000..069236f
--- /dev/null
+++ b/conf/dist/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