summaryrefslogtreecommitdiff
path: root/kolabd/kolabd/dist_conf/kolabctl
blob: 1b4db991c96866214f807a757bd241f28ac5ad45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/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[@]}]=slapd
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