summaryrefslogtreecommitdiff
blob: 2c629c13885f4e5b37a283959d7c5e765a0b330e (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash

function die {
    echo $1
    exit 1
}

#
# INSTALL
#
if [ $1 = "start" -o $1 = "install" ]; then
    echo ""
    echo ""
    echo ""
    #
    #
    # Preparing TOMCAT
    #
    #
    echo "- Prepare Tomcat servlet directory for the Open-Xchange"
    
    mkdir -p /opt/tomcat5/webapps/servlet/WEB-INF/classes
    cp /opt/open-xchange/share/servlets/* /opt/tomcat5/webapps/servlet/WEB-INF/classes/
    mkdir -p /opt/tomcat5/webapps/servlet/WEB-INF/lib
    cp /opt/open-xchange/lib/* /opt/tomcat5/webapps/servlet/WEB-INF/lib/
    cp ${FILESDIR}/web.xml /opt/tomcat5/webapps/servlet/WEB-INF/web.xml
    chown -R tomcat:tomcat /opt/tomcat5/webapps/servlet/
    chmod -R 755 /opt/tomcat5/webapps/servlet/

    echo "- Restarting tomcat"
    /etc/init.d/tomcat5 restart || die "tomcat needs to be running"

    #
    #
    # Preparing the DB
    #
    #
    echo "- Starting postgresql"
    /etc/init.d/postgresql restart || die "postgresql needs to be running"
    echo "- Create openexchange user"
    sudo -u postgres createuser -A -d openexchange >/dev/null 2>&1
    echo "- Create openexchange database"
    sudo -u postgres createdb -O openexchange -E UNICODE openexchange >/dev/null 2>&1
    echo "- Init openexchange database"
    psql -U openexchange openexchange < /opt/open-xchange/share/init_database.sql >/dev/null 2>&1
    psql -U openexchange openexchange < ${FILESDIR}/init_db.sql >/dev/null 2>&1

    #
    #
    # Preparing SLAPD
    #
    #
    cp ${FILESDIR}/ldap_ox.include /opt/open-xchange/etc/.
    chmod 640 /opt/open-xchange/etc/ldap_ox.include
    chown root:ldap /opt/open-xchange/etc/ldap_ox.include

    #egrep -e "ldap_ox.include" /etc/openldap/slapd.conf
    #if [ $? -eq 1 ] ; then
    #    echo "include /opt/open-xchange/etc/ldap_ox.include" >> /etc/openldap/slapd.conf
    #    chown ldap:ldap /etc/openldap/slapd.conf
    #fi

    # make state directories
    #mkdir /var/lib/openldap-ox
    #chown ldap:ldap /var/lib/openldap-ox
    #chmod 0700 /var/lib/openldap-ox

    #echo "- Starting ldap"
    #/etc/init.d/slapd restart || die "slapd needs to be running"

    #PASS=`perl -e 'print crypt(admin,pack("C2",(int(rand 26)+65),(int(rand 26)+65)));'`
    sed -i "s|newmailadminpass|$PASS|g" /opt/open-xchange/share/init_ldap.ldif 
    #slapadd -b "dc=example,dc=org" -l /opt/open-xchange/share/init_ldap.ldif

    #egrep -e "dc=example,dc=org" /etc/openldap/ldap.conf
    #if [ $? -eq 1 ] ; then
    #    echo "BASE dc=example,dc=org" >> /etc/openldap/ldap.conf
    #    echo "HOST localhost" >> /etc/openldap/ldap.conf
    #    chown ldap:ldap /etc/openldap/slapd.conf
    #fi

    ln -s /etc/openldap/ldap.conf /opt/open-xchange/etc/groupware/ldap.conf
    ln -s /etc/openldap/ldap.conf /opt/open-xchange/etc/webmail/ldap.conf

    #
    #
    # Creating test user
    #
    #
    #/opt/open-xchange/sbin/./adduser_ox \
    #            --username="test" \
    #            --passwd="test" \
    #            --name="user" \
    #            --sname="test" \
    #            --maildomain="example.org" \
    #            --ox_timezone="Europe/Paris"

    #/opt/open-xchange/sbin/./addgroup_ox --group=developers 

    #
    #
    # Filespool
    #
    #
    echo "- Creating filespool"
    /opt/open-xchange/sbin/./correctfilespool

    #
    #
    # Admintools
    #
    #
    echo "- Changing admintools"
    sed -i "s|cn=Manager|uid=admin|g" /opt/open-xchange/etc/admintools.conf

    #
    #
    # Restarting apache2
    #
    #
    #echo "- Restarting apache2"
    #/etc/init.d/apache2 restart || die "apache2 needs to be running"

    #
    #
    # Restarting open-xchange
    #
    #
    #echo "- Restarting open-xchange"
    #/etc/init.d/openexchange start || die "openxchange needs to be running"

#
# CLEAN
#
else
    echo "- Delete Tomcat servlet directory"
    rm -r /opt/tomcat5/webapps/servlet/ >/dev/null 2>&1
    rm -r /opt/open-xchange/etc/
    rm -r /opt/open-xchange/share/
    rm -r /opt/open-xchange/var/
fi