<commit_before>#!/bin/bash
#
if [[ -z ${PSQLUSRPWD} || -z ${NEWHOSTDOMAIN} || -z ${INSTALLERS}  ]]
then
#
echo "Usage :  ./iredmailInstallAll.sh"
echo "With required variables :"
echo " - PSQLUSRPWD : ${PSQLUSRPWD}"
echo " - NEWHOSTDOMAIN : ${NEWNEWHOSTDOMAINHOSTDOMAIN}"
echo " - INSTALLERS : $INSTALLERS"
# echo " -  : $"
exit 0
#
fi
#
genpasswd() {
	local l=$1
       	[ "$l" == "" ] && l=16
      	tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}

export IREDMAIL="https://bitbucket.org/zhb/iredmail/downloads"
export IREDMAILPKG="iRedMail-0.8.6"
export IREDMAILTAR="${IREDMAILPKG}.tar.bz2"
#
echo "Entering ${INSTALLERS}"
pushd ${INSTALLERS}
if [[ ! -d ${IREDMAILPKG} ]]; then
if [[ ! -f ${IREDMAILTAR} ]]; then
echo "Obtaining iRedMail installers from ${IREDMAIL}/${IREDMAILTAR}"
wget $IREDMAIL/${IREDMAILTAR}
fi
echo "untar"
tar jxvf ${IREDMAILTAR}
else
echo "Have directory"
fi
rm -f iRedMail
ln -s ${IREDMAILPKG} iRedMail
#
echo "Entering ${INSTALLERS}/iRedMail"
pushd iRedMail
#
echo " Configure PostgreSQL to 9.3"
sed -i.bak "s|export PGSQL_VERSION='9.1'|export PGSQL_VERSION='9.3'|g" conf/postgresql 
#
export FIRST_USER_PASSWD_PLAIN=${PSQLUSRPWD}
export FIRST_USER_PASSWD=${PSQLUSRPWD}
#
export DOMAIN_ADMIN_PASSWD_PLAIN=${PSQLUSRPWD}
export DOMAIN_ADMIN_PASSWD=${PSQLUSRPWD}
#
export SITE_ADMIN_PASSWD=${<PASSWORD>}
#
#   Generate config file in iRedMail directory
echo "Generating a config file in directory"
pwd
#
cat >./config <<CONFIGFILE
export VMAIL_USER_HOME_DIR='/var/vmail'
export STORAGE_BASE_DIR='/var/vmail'
export STORAGE_MAILBOX_DIR='/var/vmail/vmail1'
export SIEVE_DIR='/var/vmail/sieve'
export BACKUP_DIR='/var/vmail/backup'
export BACKUP_SCRIPT_OPENLDAP='/var/vmail/backup/backup_openldap.sh'
export BACKUP_SCRIPT_MYSQL='/var/vmail/backup/backup_mysql.sh'
export BACKUP_SCRIPT_PGSQL='/var/vmail/backup/backup_pgsql.sh'
export BACKEND_ORIG='PGSQL'
export BACKEND='PGSQL'
export VMAIL_DB_BIND_PASSWD='$(gen<PASSWORD>)'
export VMAIL_DB_ADMIN_PASSWD='$(<PASSWORD>)'
export LDAP_BINDPW='$(gen<PASSWORD>)'
export LDAP_ADMIN_PW='$(gen<PASSWORD>)'
export PGSQL_ROOT_PASSWD='<PASSWORD>}'
export PGSQL_ROOT_USER='postgres'
export SQL_SERVER='127.0.0.1'
export SQL_SERVER_PORT='5432'
export FIRST_DOMAIN='${NEWHOSTDOMAIN}'
export DOMAIN_ADMIN_NAME='postmaster'
export SITE_ADMIN_NAME='postmaster@${NEWHOSTDOMAIN}'
export DOMAIN_ADMIN_PASSWD_PLAIN='${DOMAIN_ADMIN_PASSWD_PLAIN}'
export DOMAIN_ADMIN_PASSWD='${DOMAIN_ADMIN_PASSWD}'
export SITE_ADMIN_PASSWD='${SITE_ADMIN_PASSWD}'
export FIRST_USER='postmaster'
export FIRST_USER_PASSWD='${FIRST_USER_PASSWD}'
export FIRST_USER_PASSWD_PLAIN='${FIRST_USER_PASSWD_PLAIN}'
export ENABLE_DKIM='YES'
export USE_IREDADMIN='YES'
export USE_WEBMAIL='YES'
export USE_RCM='YES'
export REQUIRE_PHP='YES'
export USE_PHPPGADMIN='YES'
export USE_AWSTATS='YES'
export USE_FAIL2BAN='YES'
export AMAVISD_DB_PASSWD='<PASSWORD>)'
export CLUEBRINGER_DB_PASSWD='$(<PASSWORD>)'
export IREDADMIN_DB_PASSWD='<PASSWORD>)'
export RCM_DB_PASSWD='<PASSWORD>)'
#EOF
CONFIGFILE
#
echo "Make iRedMail installer executable."
chmod a+x iRedMail.sh
#
$DEFDIR/iredmailUnattendedInstall.sh $(pwd)
exit
#
echo "Executing iRedMail installer"
VAR=$(expect -c '
  bash iRedMail.sh
  expect eof
')
#
#  expect "Command may disrupt existing ssh connections. Proceed with operation (y|n)?"
#  send "y\n"
#
echo "Exiting ${INSTALLERS}/iRedMail"
popd
echo "Exiting ${INSTALLERS}"
popd
exit
#
echo $VAR
#
ufw allow 8019
#
exit 0
<commit_msg>Remove spurious "exit" Changes to be committed: 	modified:   iredmailInstallAll.sh<commit_after>#!/bin/bash
#
if [[ -z ${PSQLUSRPWD} || -z ${NEWHOSTDOMAIN} || -z ${INSTALLERS}  ]]
then
#
echo "Usage :  ./iredmailInstallAll.sh"
echo "With required variables :"
echo " - PSQLUSRPWD : ${PSQLUSRPWD}"
echo " - NEWHOSTDOMAIN : ${NEWNEWHOSTDOMAINHOSTDOMAIN}"
echo " - INSTALLERS : $INSTALLERS"
# echo " -  : $"
exit 0
#
fi
#
genpasswd() {
	local l=$1
       	[ "$l" == "" ] && l=16
      	tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}

export IREDMAIL="https://bitbucket.org/zhb/iredmail/downloads"
export IREDMAILPKG="iRedMail-0.8.6"
export IREDMAILTAR="${IREDMAILPKG}.tar.bz2"
#
echo "Entering ${INSTALLERS}"
pushd ${INSTALLERS}
if [[ ! -d ${IREDMAILPKG} ]]; then
if [[ ! -f ${IREDMAILTAR} ]]; then
echo "Obtaining iRedMail installers from ${IREDMAIL}/${IREDMAILTAR}"
wget $IREDMAIL/${IREDMAILTAR}
fi
echo "untar"
tar jxvf ${IREDMAILTAR}
else
echo "Have directory"
fi
rm -f iRedMail
ln -s ${IREDMAILPKG} iRedMail
#
echo "Entering ${INSTALLERS}/iRedMail"
pushd iRedMail
#
echo " Configure PostgreSQL to 9.3"
sed -i.bak "s|export PGSQL_VERSION='9.1'|export PGSQL_VERSION='9.3'|g" conf/postgresql 
#
export FIRST_USER_PASSWD_PLAIN=${PSQLUSRPWD}
export FIRST_USER_PASSWD=${P<PASSWORD>}
#
export DOMAIN_ADMIN_PASSWD_PLAIN=${PSQL<PASSWORD>WD}
export DOMAIN_ADMIN_PASSWD=${P<PASSWORD>}
#
export SITE_ADMIN_PASSWD=${<PASSWORD>}
#
#   Generate config file in iRedMail directory
echo "Generating a config file in directory"
pwd
#
cat >./config <<CONFIGFILE
export VMAIL_USER_HOME_DIR='/var/vmail'
export STORAGE_BASE_DIR='/var/vmail'
export STORAGE_MAILBOX_DIR='/var/vmail/vmail1'
export SIEVE_DIR='/var/vmail/sieve'
export BACKUP_DIR='/var/vmail/backup'
export BACKUP_SCRIPT_OPENLDAP='/var/vmail/backup/backup_openldap.sh'
export BACKUP_SCRIPT_MYSQL='/var/vmail/backup/backup_mysql.sh'
export BACKUP_SCRIPT_PGSQL='/var/vmail/backup/backup_pgsql.sh'
export BACKEND_ORIG='PGSQL'
export BACKEND='PGSQL'
export VMAIL_DB_BIND_PASSWD='$(<PASSWORD>)'
export VMAIL_DB_ADMIN_PASSWD='$(<PASSWORD>)'
export LDAP_BINDPW='$(genpasswd)'
export LDAP_ADMIN_PW='$(genpasswd)'
export PGSQL_ROOT_PASSWD='${P<PASSWORD>}'
export PGSQL_ROOT_USER='postgres'
export SQL_SERVER='127.0.0.1'
export SQL_SERVER_PORT='5432'
export FIRST_DOMAIN='${NEWHOSTDOMAIN}'
export DOMAIN_ADMIN_NAME='postmaster'
export SITE_ADMIN_NAME='postmaster@${NEWHOSTDOMAIN}'
export DOMAIN_ADMIN_PASSWD_PLAIN='${DOMAIN_ADMIN_PASSWD_PLAIN}'
export DOMAIN_ADMIN_PASSWD='${DOMAIN_ADMIN_PASSWD}'
export SITE_ADMIN_PASSWD='${SITE_ADMIN_<PASSWORD>}'
export FIRST_USER='postmaster'
export FIRST_USER_PASSWD='${<PASSWORD>}'
export FIRST_USER_PASSWD_PLAIN='${FIRST_USER_PASSWD_PLAIN}'
export ENABLE_DKIM='YES'
export USE_IREDADMIN='YES'
export USE_WEBMAIL='YES'
export USE_RCM='YES'
export REQUIRE_PHP='YES'
export USE_PHPPGADMIN='YES'
export USE_AWSTATS='YES'
export USE_FAIL2BAN='YES'
export AMAVISD_DB_PASSWD='$(gen<PASSWORD>)'
export CLUEBRINGER_DB_PASSWD='$(<PASSWORD>)'
export IREDADMIN_DB_PASSWD='<PASSWORD>)'
export RCM_DB_PASSWD='<PASSWORD>)'
#EOF
CONFIGFILE
#
echo "Make iRedMail installer executable."
chmod a+x iRedMail.sh
#
$DEFDIR/iredmailUnattendedInstall.sh $(pwd)
exit
#
echo "Executing iRedMail installer"
VAR=$(expect -c '
  bash iRedMail.sh
  expect eof
')
#
#  expect "Command may disrupt existing ssh connections. Proceed with operation (y|n)?"
#  send "y\n"
#
echo "Exiting ${INSTALLERS}/iRedMail"
popd
echo "Exiting ${INSTALLERS}"
popd
exit
#
echo $VAR
#
ufw allow 8019
#

{'fraction_non_alphanumeric': 0.14430488153011703, 'fraction_numerical': 0.009277761918355694, 'mean_word_length': 6.935447338618347, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 28, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4641809', 'n_tokens_mistral': 2930, 'n_tokens_neox': 2850, 'n_words': 526}