2022-12-18 12:15:56 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Colors
|
|
|
|
|
if [ -z ${BASH_SOURCE} ]; then
|
2022-12-19 13:15:39 +00:00
|
|
|
|
blue=`echo "\e[1m\e[34m"`
|
|
|
|
|
green=`echo "\e[1m\e[32m"`
|
|
|
|
|
greenBold=`echo "\e[1m\e[1;32m"`
|
|
|
|
|
redBold=`echo "\e[1m\e[1;31m"`
|
|
|
|
|
red=`echo "\e[1m\e[31m"`
|
|
|
|
|
purple=`echo "\e[1m\e[35m"`
|
|
|
|
|
bold=`echo "\e[1m"`
|
|
|
|
|
normal=`echo "\e[0m"`
|
2022-12-18 12:15:56 +00:00
|
|
|
|
else
|
2022-12-19 13:15:39 +00:00
|
|
|
|
blue=`echo -e "\e[1m\e[34m"`
|
|
|
|
|
green=`echo -e "\e[1m\e[32m"`
|
|
|
|
|
greenBold=`echo -e "\e[1m\e[1;32m"`
|
|
|
|
|
redBold=`echo -e "\e[1m\e[1;31m"`
|
|
|
|
|
purple=`echo -e "\e[1m\e[35m"`
|
|
|
|
|
bold=`echo -e "\e[1m"`
|
|
|
|
|
normal=`echo -en "\e[0m"`
|
2022-12-18 12:15:56 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
HLINE="=================================================================="
|
2023-01-19 08:44:17 +00:00
|
|
|
|
HLINE_SMALL="==============================="
|
2022-12-18 12:15:56 +00:00
|
|
|
|
|
|
|
|
|
BLA_metro=( 0.2 ' ' '= ' '== ' '=== ' ' ===' ' ==' ' =' )
|
|
|
|
|
|
|
|
|
|
BLA::play_loading_animation_loop() {
|
|
|
|
|
while true ; do
|
|
|
|
|
for frame in "${BLA_active_loading_animation[@]}" ; do
|
|
|
|
|
printf "\r%s" "${frame}"
|
|
|
|
|
sleep "${BLA_loading_animation_frame_interval}"
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLA::start_loading_animation() {
|
|
|
|
|
BLA_active_loading_animation=( "${@}" )
|
|
|
|
|
BLA_loading_animation_frame_interval="${BLA_active_loading_animation[0]}"
|
|
|
|
|
unset "BLA_active_loading_animation[0]"
|
|
|
|
|
tput civis # Hide the terminal cursor
|
|
|
|
|
BLA::play_loading_animation_loop &
|
|
|
|
|
BLA_loading_animation_pid="${!}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLA::stop_loading_animation() {
|
|
|
|
|
kill "${BLA_loading_animation_pid}" &> /dev/null
|
|
|
|
|
printf "\n"
|
|
|
|
|
tput cnorm # Restore the terminal cursor
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#######################################################################################
|
|
|
|
|
|
2023-01-18 15:46:49 +00:00
|
|
|
|
|
2023-01-18 15:26:51 +00:00
|
|
|
|
# App Check
|
|
|
|
|
for bin in curl docker git; do
|
2023-01-18 15:46:49 +00:00
|
|
|
|
if [[ -z $(which ${bin}) ]]; then echo "${redBold}Cannot find ${bin}, exiting...${normal}"; exit 1; fi
|
2023-01-18 15:26:51 +00:00
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Docker-Compose Check
|
|
|
|
|
if docker compose > /dev/null 2>&1; then
|
|
|
|
|
if docker compose version --short | grep "^2." > /dev/null 2>&1; then
|
|
|
|
|
COMPOSE_VERSION=native
|
2023-01-18 15:46:49 +00:00
|
|
|
|
echo -e "${purple}Found Docker Compose Plugin (native).${normal}"
|
|
|
|
|
echo -e "${purple}Setting the DOCKER_COMPOSE_VERSION Variable to native${normal}"
|
2023-01-18 15:26:51 +00:00
|
|
|
|
sleep 2
|
|
|
|
|
echo -e "${purple}Notice: You´ll have to update this Compose Version via your Package Manager manually!${normal}"
|
|
|
|
|
else
|
2023-01-18 15:46:49 +00:00
|
|
|
|
echo -e "${redBold}Cannot find Docker Compose with a Version Higher than 2.X.X.${normal}"
|
2023-01-18 15:26:51 +00:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
elif docker-compose > /dev/null 2>&1; then
|
|
|
|
|
if ! [[ $(alias docker-compose 2> /dev/null) ]] ; then
|
|
|
|
|
if docker-compose version --short | grep "^2." > /dev/null 2>&1; then
|
|
|
|
|
COMPOSE_VERSION=standalone
|
2023-01-18 15:46:49 +00:00
|
|
|
|
echo -e "${purple}Found Docker Compose Standalone.${normal}"
|
|
|
|
|
echo -e "${purple}Setting the DOCKER_COMPOSE_VERSION Variable to standalone${normal}"
|
2023-01-18 15:26:51 +00:00
|
|
|
|
sleep 2
|
|
|
|
|
else
|
2023-01-18 15:46:49 +00:00
|
|
|
|
echo -e "${redBold}Cannot find Docker Compose with a Version Higher than 2.X.X.${normal}"
|
2023-01-18 15:26:51 +00:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
else
|
2023-01-18 15:46:49 +00:00
|
|
|
|
echo -e "${redBold}Cannot find Docker Compose.${normal}"
|
2023-01-18 15:26:51 +00:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
#######################################################################################
|
|
|
|
|
|
2022-12-18 15:28:27 +00:00
|
|
|
|
while true; do
|
|
|
|
|
read -ep "Do you want to perform the update?? (y/n): " yn
|
|
|
|
|
case $yn in
|
|
|
|
|
[Yy]* ) echo "${greenBold}********* Update started... Please wait... *********${normal}"; break;;
|
|
|
|
|
[Nn]* ) echo -e "${redBold} The update is canceled!${normal}"; exit;;
|
2023-01-18 15:46:49 +00:00
|
|
|
|
* ) echo -e "${redBold} Please confirm with y or n.${normal}";;
|
2022-12-18 15:28:27 +00:00
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2023-01-19 08:44:17 +00:00
|
|
|
|
installPth=`pwd`
|
|
|
|
|
configPth="$installPth/config"
|
2022-12-19 12:43:14 +00:00
|
|
|
|
etcPth="/var/lib/docker/volumes/piler-docker_piler_etc/_data"
|
2022-12-18 12:15:56 +00:00
|
|
|
|
|
|
|
|
|
# config load
|
|
|
|
|
. ./piler.conf
|
|
|
|
|
|
|
|
|
|
if [ ! -f $installPth/.env ]; then
|
2023-01-19 08:44:17 +00:00
|
|
|
|
ln -s ./piler.conf .env
|
2022-12-18 12:15:56 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f $installPth/docker-compose.yml ]; then
|
2023-01-19 08:44:17 +00:00
|
|
|
|
rm $installPth/docker-compose.yml
|
2022-12-18 12:15:56 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Download yml update
|
|
|
|
|
echo
|
|
|
|
|
echo "${greenBold}${HLINE}"
|
|
|
|
|
echo "${greenBold} Download Update files for Piler"
|
|
|
|
|
echo "${greenBold}${HLINE}${normal}"
|
|
|
|
|
echo
|
|
|
|
|
|
2023-01-19 08:44:17 +00:00
|
|
|
|
# Update Files
|
|
|
|
|
for ymlUpdate in piler-default.yml piler-ssl.yml; do
|
|
|
|
|
echo
|
|
|
|
|
echo "${purple}${HLINE}${HLINE_SMALL}"
|
|
|
|
|
echo "${purple}****** Download Update $ymlUpdate ******"
|
|
|
|
|
curl -o $configPth/$ymlUpdate https://raw.githubusercontent.com/simatec/piler-docker/main/config/$ymlUpdate
|
|
|
|
|
echo "${purple}${HLINE}${HLINE_SMALL}${normal}"
|
|
|
|
|
echo
|
|
|
|
|
done
|
2022-12-18 12:15:56 +00:00
|
|
|
|
|
2023-01-19 08:44:17 +00:00
|
|
|
|
for fileUpdate in install-piler.sh LICENSE piler.conf.example; do
|
|
|
|
|
echo
|
|
|
|
|
echo "${purple}${HLINE}${HLINE_SMALL}"
|
|
|
|
|
echo "${purple}****** Download Update $fileUpdate ******"
|
|
|
|
|
curl -o $installPth/$fileUpdate https://raw.githubusercontent.com/simatec/piler-docker/main/config/$fileUpdate
|
|
|
|
|
echo "${purple}${HLINE}${HLINE_SMALL}${normal}"
|
|
|
|
|
echo
|
|
|
|
|
done
|
2022-12-20 11:11:17 +00:00
|
|
|
|
|
2022-12-18 12:15:56 +00:00
|
|
|
|
# old docker stop
|
|
|
|
|
cd $installPth
|
|
|
|
|
|
2023-01-18 15:26:51 +00:00
|
|
|
|
if [ $COMPOSE_VERSION = native ]; then
|
2023-01-19 08:44:17 +00:00
|
|
|
|
docker compose down
|
2023-01-18 15:26:51 +00:00
|
|
|
|
else
|
2023-01-19 08:44:17 +00:00
|
|
|
|
docker-compose down
|
2023-01-18 15:26:51 +00:00
|
|
|
|
fi
|
2022-12-18 12:15:56 +00:00
|
|
|
|
|
|
|
|
|
if [ "$USE_LETSENCRYPT" = "yes" ]; then
|
2023-01-19 08:44:17 +00:00
|
|
|
|
cp $configPth/piler-ssl.yml $installPth/docker-compose.yml
|
2022-12-18 12:15:56 +00:00
|
|
|
|
else
|
2023-01-19 08:44:17 +00:00
|
|
|
|
cp $configPth/piler-default.yml $installPth/docker-compose.yml
|
2022-12-18 12:15:56 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# start Update Container
|
|
|
|
|
echo
|
|
|
|
|
echo "${greenBold}${HLINE}"
|
|
|
|
|
echo "${greenBold} Update Container for Piler"
|
|
|
|
|
echo "${greenBold}${HLINE}${normal}"
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
|
|
if [ "$USE_LETSENCRYPT" = "yes" ]; then
|
|
|
|
|
if ! docker network ls | grep -o "nginx-proxy"; then
|
2023-01-19 08:44:17 +00:00
|
|
|
|
docker network create nginx-proxy
|
2022-12-18 12:15:56 +00:00
|
|
|
|
|
2023-01-19 08:44:17 +00:00
|
|
|
|
echo
|
|
|
|
|
echo "${blue}${HLINE}"
|
|
|
|
|
echo "${blue} docker network created"
|
|
|
|
|
echo "${blue}${HLINE}${normal}"
|
|
|
|
|
echo
|
2022-12-18 12:15:56 +00:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2023-01-18 15:26:51 +00:00
|
|
|
|
if [ $COMPOSE_VERSION = native ]; then
|
2023-01-19 08:44:17 +00:00
|
|
|
|
docker compose up --force-recreate --build -d
|
2023-01-18 15:26:51 +00:00
|
|
|
|
else
|
2023-01-19 08:44:17 +00:00
|
|
|
|
docker-compose up --force-recreate --build -d
|
2023-01-18 15:26:51 +00:00
|
|
|
|
fi
|
2022-12-18 12:15:56 +00:00
|
|
|
|
|
2022-12-18 15:28:27 +00:00
|
|
|
|
echo "${blue}********* Piler started... Please wait... *********${normal}"
|
2022-12-18 12:15:56 +00:00
|
|
|
|
|
|
|
|
|
BLA::start_loading_animation "${BLA_metro[@]}"
|
2022-12-19 12:43:14 +00:00
|
|
|
|
sleep 20
|
2022-12-18 12:15:56 +00:00
|
|
|
|
BLA::stop_loading_animation
|
|
|
|
|
|
2022-12-19 12:43:14 +00:00
|
|
|
|
if [ ! -f $etcPth/config-site.php.bak ]; then
|
2023-01-19 08:44:17 +00:00
|
|
|
|
cp $etcPth/config-site.php $etcPth/config-site.php.bak
|
2022-12-19 12:43:14 +00:00
|
|
|
|
else
|
2023-01-19 08:44:17 +00:00
|
|
|
|
rm $etcPth/config-site.php
|
|
|
|
|
cp $etcPth/config-site.php.bak $etcPth/config-site.php
|
2022-12-19 12:43:14 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "${blue}${HLINE}"
|
|
|
|
|
echo "${blue} set User settings ..."
|
|
|
|
|
echo "${blue}${HLINE}${normal}"
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
|
|
cat >> $etcPth/config-site.php <<EOF
|
|
|
|
|
|
|
|
|
|
// Smarthost
|
|
|
|
|
\$config['SMARTHOST'] = '$SMARTHOST';
|
|
|
|
|
\$config['SMARTHOST_PORT'] = '25';
|
|
|
|
|
|
|
|
|
|
// CUSTOM
|
|
|
|
|
\$config['PROVIDED_BY'] = '$PILER_DOMAIN';
|
|
|
|
|
\$config['SUPPORT_LINK'] = 'mailto:$SUPPORT_MAIL';
|
|
|
|
|
\$config['COMPATIBILITY'] = '';
|
|
|
|
|
|
|
|
|
|
// fancy features.
|
|
|
|
|
\$config['ENABLE_INSTANT_SEARCH'] = 1;
|
|
|
|
|
\$config['ENABLE_TABLE_RESIZE'] = 1;
|
|
|
|
|
|
|
|
|
|
\$config['ENABLE_DELETE'] = 1;
|
|
|
|
|
\$config['ENABLE_ON_THE_FLY_VERIFICATION'] = 1;
|
|
|
|
|
|
|
|
|
|
// general settings.
|
|
|
|
|
\$config['TIMEZONE'] = '$TIME_ZONE';
|
|
|
|
|
|
|
|
|
|
// authentication
|
|
|
|
|
// Enable authentication against an imap server
|
|
|
|
|
\$config['ENABLE_IMAP_AUTH'] = 1;
|
|
|
|
|
\$config['RESTORE_OVER_IMAP'] = 1;
|
|
|
|
|
\$config['IMAP_RESTORE_FOLDER_INBOX'] = 'INBOX';
|
|
|
|
|
\$config['IMAP_RESTORE_FOLDER_SENT'] = 'Sent';
|
|
|
|
|
\$config['IMAP_HOST'] = '$IMAP_SERVER';
|
|
|
|
|
\$config['IMAP_PORT'] = 993;
|
|
|
|
|
\$config['IMAP_SSL'] = true;
|
|
|
|
|
|
|
|
|
|
// authentication against an ldap directory (disabled by default)
|
|
|
|
|
//\$config['ENABLE_LDAP_AUTH'] = 1;
|
|
|
|
|
//\$config['LDAP_HOST'] = '$SMARTHOST';
|
|
|
|
|
//\$config['LDAP_PORT'] = 389;
|
|
|
|
|
//\$config['LDAP_HELPER_DN'] = 'cn=administrator,cn=users,dc=mydomain,dc=local';
|
|
|
|
|
//\$config['LDAP_HELPER_PASSWORD'] = 'myxxxxpasswd';
|
|
|
|
|
//\$config['LDAP_MAIL_ATTR'] = 'mail';
|
|
|
|
|
//\$config['LDAP_AUDITOR_MEMBER_DN'] = '';
|
|
|
|
|
//\$config['LDAP_ADMIN_MEMBER_DN'] = '';
|
|
|
|
|
//\$config['LDAP_BASE_DN'] = 'ou=Benutzer,dc=krs,dc=local';
|
|
|
|
|
|
|
|
|
|
// authentication against an Uninvention based ldap directory
|
|
|
|
|
//\$config['ENABLE_LDAP_AUTH'] = 1;
|
|
|
|
|
//\$config['LDAP_HOST'] = '$SMARTHOST';
|
|
|
|
|
//\$config['LDAP_PORT'] = 7389;
|
|
|
|
|
//\$config['LDAP_HELPER_DN'] = 'uid=ldap-search-user,cn=users,dc=mydomain,dc=local';
|
|
|
|
|
//\$config['LDAP_HELPER_PASSWORD'] = 'myxxxxpasswd';
|
|
|
|
|
//\$config['LDAP_AUDITOR_MEMBER_DN'] = '';
|
|
|
|
|
//\$config['LDAP_ADMIN_MEMBER_DN'] = '';
|
|
|
|
|
//\$config['LDAP_BASE_DN'] = 'cn=users,dc=mydomain,dc=local';
|
|
|
|
|
//\$config['LDAP_MAIL_ATTR'] = 'mailPrimaryAddress';
|
|
|
|
|
//\$config['LDAP_ACCOUNT_OBJECTCLASS'] = 'person';
|
|
|
|
|
//\$config['LDAP_DISTRIBUTIONLIST_OBJECTCLASS'] = 'person';
|
|
|
|
|
//\$config['LDAP_DISTRIBUTIONLIST_ATTR'] = 'mailAlternativeAddress';
|
|
|
|
|
|
|
|
|
|
// special settings.
|
|
|
|
|
//\$config['MEMCACHED_ENABLED'] = 1;
|
|
|
|
|
\$config['SPHINX_STRICT_SCHEMA'] = 1; // required for Sphinx see https://bitbucket.org/jsuto/piler/issues/1085/sphinx-331.
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
if [ "$USE_MAILCOW" = true ]; then
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "${blue}${HLINE}"
|
|
|
|
|
echo "set Mailcow Api-Key config"
|
|
|
|
|
echo "${blue}${HLINE}${normal}"
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
|
|
cat >> $etcPth/config-site.php <<EOF
|
|
|
|
|
|
|
|
|
|
// Mailcow API
|
|
|
|
|
\$config['MAILCOW_API_KEY'] = '$MAILCOW_APIKEY';
|
|
|
|
|
\$config['MAILCOW_SET_REALNAME'] = true;
|
|
|
|
|
\$config['CUSTOM_EMAIL_QUERY_FUNCTION'] = 'query_mailcow_for_email_access';
|
|
|
|
|
\$config['MAILCOW_HOST'] = '$MAILCOW_HOST'; // default $config['IMAP_HOST']
|
|
|
|
|
include('auth-mailcow.php');
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
curl -o $etcPth/auth-mailcow.php https://raw.githubusercontent.com/patschi/mailpiler-mailcow-integration/master/auth-mailcow.php
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# add config settings
|
|
|
|
|
|
|
|
|
|
if [ ! -f $etcPth/piler.conf.bak ]; then
|
2023-01-19 08:44:17 +00:00
|
|
|
|
cp $etcPth/piler.conf $etcPth/piler.conf.bak
|
2022-12-19 12:43:14 +00:00
|
|
|
|
else
|
2023-01-19 08:44:17 +00:00
|
|
|
|
rm $etcPth/piler.conf
|
|
|
|
|
cp $etcPth/piler.conf.bak $etcPth/piler.conf
|
2022-12-19 12:43:14 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
sed -i "s/default_retention_days=.*/default_retention_days=$DEFAULT_RETENTION_DAYS/" $etcPth/piler.conf
|
|
|
|
|
sed -i "s/update_counters_to_memcached=.*/update_counters_to_memcached=1/" $etcPth/piler.conf
|
|
|
|
|
|
|
|
|
|
cat >> $etcPth/piler.conf <<EOF
|
|
|
|
|
queuedir=/var/piler/store
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
# piler restart
|
|
|
|
|
echo
|
|
|
|
|
echo "${blue}${HLINE}"
|
|
|
|
|
echo "${blue} restart piler ..."
|
|
|
|
|
echo "${blue}${HLINE}${normal}"
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
|
|
cd $installPth
|
2023-01-18 15:26:51 +00:00
|
|
|
|
|
|
|
|
|
if [ $COMPOSE_VERSION = native ]; then
|
2023-01-19 08:44:17 +00:00
|
|
|
|
docker compose restart piler
|
2023-01-18 15:26:51 +00:00
|
|
|
|
else
|
2023-01-19 08:44:17 +00:00
|
|
|
|
docker-compose restart piler
|
2023-01-18 15:26:51 +00:00
|
|
|
|
fi
|
2022-12-19 12:43:14 +00:00
|
|
|
|
|
2022-12-18 12:15:56 +00:00
|
|
|
|
echo
|
|
|
|
|
echo "${greenBold}${HLINE}"
|
|
|
|
|
echo "${greenBold} Piler Update completed successfully"
|
|
|
|
|
echo "${greenBold}${HLINE}${normal}"
|
|
|
|
|
echo
|
|
|
|
|
echo
|
2023-01-19 08:44:17 +00:00
|
|
|
|
echo "${greenBold}${HLINE}${HLINE_SMALL}"
|
|
|
|
|
|
2022-12-18 12:15:56 +00:00
|
|
|
|
if [ "$USE_LETSENCRYPT" = "yes" ]; then
|
2023-01-19 08:44:17 +00:00
|
|
|
|
echo "${greenBold}you can start in your Browser with https://${PILER_DOMAIN}!"
|
2022-12-18 12:15:56 +00:00
|
|
|
|
else
|
2023-01-19 08:44:17 +00:00
|
|
|
|
echo "${greenBold}you can start in your Browser with:"
|
|
|
|
|
echo "${greenBold}http://${PILER_DOMAIN} or http://local-ip"
|
2022-12-18 12:15:56 +00:00
|
|
|
|
fi
|
2023-01-19 08:44:17 +00:00
|
|
|
|
|
|
|
|
|
echo "${greenBold}${HLINE}${HLINE_SMALL}${normal}"
|
2022-12-18 12:15:56 +00:00
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "${blue}${HLINE}"
|
|
|
|
|
echo "${blue}You can remove the old unused containers on your system!"
|
|
|
|
|
echo "${blue}Execute the following command: docker system prune"
|
|
|
|
|
echo "${blue}${HLINE}${normal}"
|
|
|
|
|
echo
|