#!/bin/bash # # Copyright (C) 2006-2009 Eric Shubert # # Set configuration variables for the qtp package # ################################################################### # change log # 03/05/11 shubes - added variables for qtp-backup to bypass Maildirs, squirrelmail # 08/14/09 shubes - changed for single OVERLAY (FUSE) unionfs filesystem # 07/18/09 shubes - added vpopmail backend access variables, from qtp-backup # 07/07/09 shubes - added work-around for package names with arch appended # 02/03/09 Jake - Changed download paths # 02/26/08 shubes - fixed kernelver variable for n.n.n.n versions # 02/08/08 Jake - Updated links for downloading of packages # 01/07/08 shubes - added UNIONROOT for qtp-newmodel # - renamed a1 <-> a2 so they're in order # 06/27/07 Jake - Moved a2_backup_variables to head of script to make # - it easier for user to set these variables. # - Added more comments for clarity # 03/06/07 shubes - added x01_compare_versions function # 01/13/07 shubes - added RPMBUILD_OPT_DIR variable # 01/04/07 shubes - added QMT_DEV variable # 01/03/07 shubes - added RPMBUILD_OPTIONS variable ################################################################### ##################################################################### ## set variables for qtp-backup processing # a1_backup_variables(){ # backupdest is the Backup Destination on your HD (don't include trailing /) # If the dir does not exist, it will be created for you. # ex: backupdest=/backuphd/toasterbackup export backupdest=/backup/qmailbkup # FTP Information and Destination # This will upload the files backed up via FTP using Curl ( y or n ) export useftp=n # Syntax for ftpserver: ftp://user:pass@ftp.server.com/folder (WITHOUT Trailing /) export ftpserver=ftp:// # E-Mail Information and Destination # This will Send you an e-mail after the Cron Job Runs each time. ( y or n ) export emailinfo=y # Syntax for email: your@emailaddress.com export email=postmaster # Remove previous backup file before creating a new one? ( y or n ) export removeprevious=n # variable for including Maildirs (actual mail) or not ( y or n ) export includemaildirs=y # variable for including squirrelmail stuff or not ( y or n ) export includesquirrelmail=y } ##################################################################### ## set variables for qtp-newmodel processing # a2_newmodel_variables(){ # this is used by qtp-newmodel and qtp-ami-up2date export QMT_WEB=http://www.qmailtoaster.com #export QMT_WEB=http://www.qmailtoaster.org #export QMT_DEV=http://devel.qmailtoaster.com export QMT_DEV=http://www.qmailtoaster.org # these are used by qtp-newmodel and subscripts export UPGRADE_DIR=/usr/src/qtp-upgrade export SANDBOX=/mnt/qtp-sandbox export OVERLAY=/opt/qtp-overlay # you may specify any global options for rpmbuild here (used by qtp-build-rpms) #export RPMBUILD_OPTIONS="-v" #export RPMBUILD_OPTIONS="--quiet" export RPMBUILD_OPTIONS="" # you may specify any package specific options for rpmbuild # by creating a file named 'package' (e.g. qmailadmin-toaster) # in the RPMBUILD_OPT_DIR directory which contains the parameters # you would like to use, e.g. "--define 'spambox 1'" export RPMBUILD_OPT_DIR=/opt/qmailtoaster-plus/etc/rpmbuild } ################################################################### ## set variables for vpopmail backend access # a3_vpopmail_variables(){ mysql_file=~vpopmail/etc/vpopmail.mysql if [ -f $mysql_file ]; then mysql_host=$(cut -d"|" -f1 < $mysql_file) mysql_port=$(cut -d"|" -f2 < $mysql_file) mysql_user=$(cut -d"|" -f3 < $mysql_file) mysql_password=$(cut -d"|" -f4 < $mysql_file) mysql_database=$(cut -d"|" -f5 < $mysql_file) else unset mysql_host \ mysql_port \ mysql_user \ mysql_password \ mysql_database fi ldap_file=~vpopmail/etc/vpopmail.ldap if [ -f $ldap_file ]; then ldap_host=$(cut -d"|" -f1 < $ldap_file) ldap_port=$(cut -d"|" -f2 < $ldap_file) ldap_user="$(cut -d"|" -f3 < $ldap_file)" ldap_password="$(cut -d"|" -f4 < $ldap_file)" ldap_database="$(cut -d"|" -f5 < $ldap_file)" else unset ldap_host \ ldap_port \ ldap_user \ ldap_password \ ldap_database fi } ################################################################### ## compare versions function ## QMT greater than installed returns zero, not greater (<=) returns 1 ## used by qtp-newmodel, qtp-ami-up2date, qtp-convert, qtp-remove-pkgs # x01_compare_versions(){ installed_version=${installed_pkgver#${QMT_PKGNAME}-} # shubes 7/07/09 - this is a work-around to strip arch from package name for arch in noarch i386 i586 i686 x86_64; do installed_version=${installed_version%.$arch} QMT_VERSION=${QMT_VERSION%.$arch} done if [ "$QMT_PKGNAME" == "zlib" ]; then installed_qmtver=${installed_version%-[^-]*} QMT_QMTVER=${QMT_VERSION%-[^-]*} else installed_qmtver=${installed_version#[^-]*-} QMT_QMTVER=${QMT_VERSION#[^-]*-} fi inst_v1=${installed_qmtver%%.[.0-9]*} inst_temp=${installed_qmtver#${inst_v1}} inst_temp=${inst_temp#.} inst_v2=${inst_temp%%.[.0-9]*} inst_temp=${inst_temp#${inst_v2}} inst_temp=${inst_temp#.} inst_v3=${inst_temp%%.[.0-9]*} : ${inst_v3:=0} updt_v1=${QMT_QMTVER%%.[.0-9]*} updt_temp=${QMT_QMTVER#${updt_v1}} updt_temp=${updt_temp#.} updt_v2=${updt_temp%%.[.0-9]*} updt_temp=${updt_temp#${updt_v2}} updt_temp=${updt_temp#.} updt_v3=${updt_temp%%.[.0-9]*} : ${updt_v3:=0} if [ $((updt_v1)) -gt $((inst_v1)) ] \ || ( [ $((updt_v1)) -eq $((inst_v1)) ] \ && [ $((updt_v2)) -gt $((inst_v2)) ] ) \ || ( [ $((updt_v1)) -eq $((inst_v1)) ] \ && [ $((updt_v2)) -eq $((inst_v2)) ] \ && [ $((updt_v3)) -gt $((inst_v3)) ] ); then return 0 else return 1 fi } ##################################################################### ## main execution begins here # myname=qtp-config myver=v0.3.2 if [ "${0##*/}" == "$myname" ]; then retexit=exit else retexit=return fi unset silent if [ ! -z "$1" ]; then case $1 in -s ) silent=$1 ;; * ) echo "$myname usage: $myname [-s]" $retexit 8 ;; esac else echo "$myname $myver" fi a1_backup_variables a2_newmodel_variables a3_vpopmail_variables if [ ! $silent ]; then echo "QMT_WEB=$QMT_WEB" echo "QMT_DEV=$QMT_DEV" echo "SANDBOX=$SANDBOX" echo "OVERLAY=$OVERLAY" echo "UPGRADE_DIR=$UPGRADE_DIR" echo "RPMBUILD_OPTIONS=$RPMBUILD_OPTIONS" echo "backupdest=$backupdest" echo "useftp=$useftp" echo "ftpserver=$ftpserver" echo "emailinfo=$emailinfo" echo "email=$email" echo "removeprevious=$removeprevious" echo "mysql_user=$mysql_user" echo "ldap_user=$ldap_user" fi $retexit 0