#!/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