#!/bin/bash # (C) 2004 Jean-Michel Dault <jmdault@mandrakesoft.com> # This program is Free Software under the GNU General Public License (>=v2). # Read the file COPYING that comes with this packages for details. # Reworked by Oden Eriksson <oeriksson@mandriva.com> SERVICES="ldap saslauthd cyrus-imapd httpd proftpd freshclam clamd spamd amavisd postfix" BACKUP_DIR="/etc/kolab/backup" BACKUP_DATE="`date +%Y%m%d-%H%M%S`" BACKUP_FILES="\ /etc/amavisd/amavisd.conf \ /etc/cyrus.conf \ /etc/httpd/modules.d/41_mod_ssl.default-vhost.conf \ /etc/imapd.conf \ /etc/rc.d/init.d/ldap \ /etc/openldap/slapd.conf \ /etc/postfix/main.cf \ /etc/postfix/master.cf \ /etc/postfix/sasl/smtpd.conf \ /etc/postfix/transport \ /etc/postfix/virtual \ /etc/proftpd.conf \ /etc/sysconfig/ldap \ /etc/sysconfig/saslauthd \ " show_usage() { cat << EOF Usage: kolab_bootstrap [OPTION] Known values for OPTION are: -b, --bootstrap Configure the kolab server -r, --restore Restore original configuration files -h, --help Print this help EOF } if test $# -eq 0; then show_usage exit 1 fi flags="" while test $# -gt 0; do case "$1" in --bootstrap|-b) mkdir -p $BACKUP_DIR if ! [ -s /etc/kolab/backup/kolab_backup-orig.tar.gz ]; then echo "Backuping config files to $BACKUP_DIR/kolab_backup-orig.tar.gz" tar -cPf - $BACKUP_FILES | gzip -9 > $BACKUP_DIR/kolab_backup-orig.tar.gz else echo "Backuping config files to $BACKUP_DIR/kolab_backup-$BACKUP_DATE.tar.gz" tar -cPf - $BACKUP_FILES | gzip -9 > $BACKUP_DIR/kolab_backup-$BACKUP_DATE.tar.gz fi # i guess we could stop these from the real kolab_bootstrap script for s in $SERVICES; do chkconfig --level 35 $s off /etc/rc.d/init.d/$s stop >/dev/null 2>&1 done # stop the kolab backend service /etc/rc.d/init.d/kolab stop >/dev/null 2>&1 # call the real boot strapper /usr/sbin/kolab_bootstrap.real -b touch /etc/kolab/.kolab2_configured exit 0 ;; --restore|-r) if ! [ -f /etc/kolab/backup/kolab_backup-orig.tar.gz ]; then echo "The $BACKUP_DIR/kolab_backup-orig.tar.gz file does not exist" echo "No action taken" else # stop the kolab backend service /etc/rc.d/init.d/kolab stop >/dev/null 2>&1 chkconfig --level 35 kolab off echo "Restoring original files from $BACKUP_DIR/kolab_backup-orig.tar.gz" tar -zxvf $BACKUP_DIR/kolab_backup-orig.tar.gz for s in $SERVICES; do echo "Resetting the $s service" chkconfig --add $s done fi exit 0 ;; --help|-h) show_usage exit 0 ;; *) show_usage exit 1 ;; esac # Next please. shift done exit 0