piler-docker/install-piler.sh

124 lines
3.8 KiB
Bash
Raw Normal View History

2022-03-08 11:02:21 +00:00
#!/bin/bash
. ./piler.conf
ln -s ./piler.conf .env
2022-03-08 12:42:38 +00:00
# docker start
echo
echo "==================================="
2022-03-08 11:02:21 +00:00
echo "start docker-compose for Piler"
2022-03-08 12:42:38 +00:00
echo "==================================="
echo
2022-03-08 11:02:21 +00:00
2022-03-08 12:42:38 +00:00
cd /opt/piler-docker
2022-03-08 11:02:21 +00:00
docker-compose up -d
2022-03-08 12:42:38 +00:00
echo
echo "==================================="
2022-03-08 11:02:21 +00:00
echo "backup the File config-site.php"
2022-03-08 12:42:38 +00:00
echo "==================================="
echo
2022-03-08 11:02:21 +00:00
2022-03-08 12:42:38 +00:00
cp /var/lib/docker/volumes/piler-docker_piler_etc/_data/config-site.php /var/lib/docker/volumes/piler-docker_piler_etc/_data/config-site.php.bak
2022-03-08 11:02:21 +00:00
2022-03-08 12:42:38 +00:00
echo
echo "==================================="
echo "set User settings ..."
echo "==================================="
echo
cat >> /var/lib/docker/volumes/piler-docker_piler_etc/_data/config-site.php <<EOF
2022-03-08 11:02:21 +00:00
// Smarthost
2022-03-08 12:42:38 +00:00
\$config['SMARTHOST'] = '$SMARTHOST';
\$config['SMARTHOST_PORT'] = '25';
2022-03-08 11:02:21 +00:00
// 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';
EOF
if [ "$USE_MAILCOW" = true ] ; then
2022-03-08 12:42:38 +00:00
echo
echo "==================================="
2022-03-08 11:02:21 +00:00
echo "set Mailcow Api-Key config"
2022-03-08 12:42:38 +00:00
echo "==================================="
echo
2022-03-08 11:02:21 +00:00
2022-03-08 12:42:38 +00:00
cat >> /var/lib/docker/volumes/piler-docker_piler_etc/_data/config-site.php <<EOF
2022-03-08 11:02:21 +00:00
// Mailcow API
2022-03-08 12:42:38 +00:00
\$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']
2022-03-08 11:02:21 +00:00
include('auth-mailcow.php');
EOF
2022-03-08 12:42:38 +00:00
curl -o /var/lib/docker/volumes/piler-docker_piler_etc/_data/auth-mailcow.php https://raw.githubusercontent.com/patschi/mailpiler-mailcow-integration/master/auth-mailcow.php
2022-03-08 11:02:21 +00:00
fi
# docker start
2022-03-08 12:42:38 +00:00
echo
echo "==================================="
2022-03-08 11:02:21 +00:00
echo "restart docker-compose ..."
2022-03-08 12:42:38 +00:00
echo "==================================="
echo
2022-03-08 11:02:21 +00:00
2022-03-08 12:42:38 +00:00
cd /opt/piler-docker
2022-03-08 11:02:21 +00:00
docker-compose restart
2022-03-08 12:42:38 +00:00
echo
echo "======================================================================="
2022-03-08 11:02:21 +00:00
echo "Piler install completed successfully"
2022-03-08 12:42:38 +00:00
echo
echo "you can start in your Browser with http://${PILER_DOMAIN}:8080!"
echo "======================================================================="
echo