2014-07-12 00:02:32 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2014-09-21 20:05:11 +00:00
|
|
|
# Z-Push: The Microsoft Exchange protocol server
|
|
|
|
# ----------------------------------------------
|
|
|
|
#
|
2014-11-05 03:53:24 +00:00
|
|
|
# Mostly for use on iOS which doesn't support IMAP IDLE.
|
2014-07-12 00:02:32 +00:00
|
|
|
#
|
|
|
|
# Although Ubuntu ships Z-Push (as d-push) it has a dependency on Apache
|
|
|
|
# so we won't install it that way.
|
|
|
|
#
|
|
|
|
# Thanks to http://frontender.ch/publikationen/push-mail-server-using-nginx-and-z-push.html.
|
|
|
|
|
|
|
|
source setup/functions.sh # load our functions
|
|
|
|
source /etc/mailinabox.conf # load global vars
|
|
|
|
|
|
|
|
# Prereqs.
|
|
|
|
|
2015-08-19 19:58:35 +00:00
|
|
|
echo "Installing Z-Push (Exchange/ActiveSync server)..."
|
2014-07-12 00:02:32 +00:00
|
|
|
apt_install \
|
2024-06-18 12:29:51 +00:00
|
|
|
php"${PHP_VER}"-soap php"${PHP_VER}"-imap libawl-php php"$PHP_VER"-xml php"${PHP_VER}"-intl
|
2014-07-12 00:02:32 +00:00
|
|
|
|
2023-12-21 14:58:34 +00:00
|
|
|
phpenmod -v "$PHP_VER" imap
|
2014-07-12 00:02:32 +00:00
|
|
|
|
|
|
|
# Copy Z-Push into place.
|
2024-06-18 12:29:22 +00:00
|
|
|
VERSION=2.7.3
|
|
|
|
TARGETHASH=9d4bec41935e9a4e07880c5ff915bcddbda4443b
|
2014-09-21 20:05:11 +00:00
|
|
|
needs_update=0 #NODOC
|
2014-08-12 12:03:36 +00:00
|
|
|
if [ ! -f /usr/local/lib/z-push/version ]; then
|
2014-09-21 20:05:11 +00:00
|
|
|
needs_update=1 #NODOC
|
2021-05-03 23:28:23 +00:00
|
|
|
elif [[ $VERSION != $(cat /usr/local/lib/z-push/version) ]]; then
|
2015-11-18 20:39:17 +00:00
|
|
|
# checks if the version
|
2014-09-21 20:05:11 +00:00
|
|
|
needs_update=1 #NODOC
|
2014-08-12 12:03:36 +00:00
|
|
|
fi
|
|
|
|
if [ $needs_update == 1 ]; then
|
2018-09-02 15:27:20 +00:00
|
|
|
# Download
|
2021-05-08 11:59:51 +00:00
|
|
|
wget_verify "https://github.com/Z-Hub/Z-Push/archive/refs/tags/$VERSION.zip" $TARGETHASH /tmp/z-push.zip
|
2018-09-02 15:27:20 +00:00
|
|
|
|
|
|
|
# Extract into place.
|
|
|
|
rm -rf /usr/local/lib/z-push /tmp/z-push
|
|
|
|
unzip -q /tmp/z-push.zip -d /tmp/z-push
|
2021-05-08 11:59:51 +00:00
|
|
|
mv /tmp/z-push/*/src /usr/local/lib/z-push
|
2018-09-02 15:27:20 +00:00
|
|
|
rm -rf /tmp/z-push.zip /tmp/z-push
|
2017-04-17 11:42:44 +00:00
|
|
|
|
2023-09-02 10:55:15 +00:00
|
|
|
# Create admin and top scripts with PHP_VER
|
2014-08-12 12:03:36 +00:00
|
|
|
rm -f /usr/sbin/z-push-{admin,top}
|
2023-09-02 10:55:15 +00:00
|
|
|
echo '#!/bin/bash' > /usr/sbin/z-push-admin
|
2023-12-21 14:58:34 +00:00
|
|
|
echo php"$PHP_VER" /usr/local/lib/z-push/z-push-admin.php '"$@"' >> /usr/sbin/z-push-admin
|
2023-09-02 10:55:15 +00:00
|
|
|
chmod 755 /usr/sbin/z-push-admin
|
|
|
|
echo '#!/bin/bash' > /usr/sbin/z-push-top
|
2023-12-21 14:58:34 +00:00
|
|
|
echo php"$PHP_VER" /usr/local/lib/z-push/z-push-top.php '"$@"' >> /usr/sbin/z-push-top
|
2023-09-02 10:55:15 +00:00
|
|
|
chmod 755 /usr/sbin/z-push-top
|
|
|
|
|
2017-12-23 22:51:18 +00:00
|
|
|
echo $VERSION > /usr/local/lib/z-push/version
|
2014-07-12 00:02:32 +00:00
|
|
|
fi
|
|
|
|
|
2014-08-12 12:03:36 +00:00
|
|
|
# Configure default config.
|
2014-08-20 21:51:10 +00:00
|
|
|
sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" /usr/local/lib/z-push/config.php
|
2014-08-11 17:08:02 +00:00
|
|
|
sed -i "s/define('BACKEND_PROVIDER', .*/define('BACKEND_PROVIDER', 'BackendCombined');/" /usr/local/lib/z-push/config.php
|
2014-09-24 12:24:30 +00:00
|
|
|
sed -i "s/define('USE_FULLEMAIL_FOR_LOGIN', .*/define('USE_FULLEMAIL_FOR_LOGIN', true);/" /usr/local/lib/z-push/config.php
|
2015-11-18 20:39:17 +00:00
|
|
|
sed -i "s/define('LOGLEVEL', .*/define('LOGLEVEL', LOGLEVEL_ERROR);/" /usr/local/lib/z-push/config.php
|
2014-08-11 17:08:02 +00:00
|
|
|
|
|
|
|
# Configure BACKEND
|
|
|
|
rm -f /usr/local/lib/z-push/backend/combined/config.php
|
2014-08-11 17:42:52 +00:00
|
|
|
cp conf/zpush/backend_combined.php /usr/local/lib/z-push/backend/combined/config.php
|
2014-08-11 17:08:02 +00:00
|
|
|
|
2014-08-11 17:42:52 +00:00
|
|
|
# Configure IMAP
|
|
|
|
rm -f /usr/local/lib/z-push/backend/imap/config.php
|
|
|
|
cp conf/zpush/backend_imap.php /usr/local/lib/z-push/backend/imap/config.php
|
2016-09-19 15:10:44 +00:00
|
|
|
sed -i "s%STORAGE_ROOT%$STORAGE_ROOT%" /usr/local/lib/z-push/backend/imap/config.php
|
2014-07-12 00:02:32 +00:00
|
|
|
|
2014-08-11 17:08:02 +00:00
|
|
|
# Configure CardDav
|
2014-08-11 17:42:52 +00:00
|
|
|
rm -f /usr/local/lib/z-push/backend/carddav/config.php
|
|
|
|
cp conf/zpush/backend_carddav.php /usr/local/lib/z-push/backend/carddav/config.php
|
2014-08-11 17:08:02 +00:00
|
|
|
|
|
|
|
# Configure CalDav
|
2014-08-11 17:42:52 +00:00
|
|
|
rm -f /usr/local/lib/z-push/backend/caldav/config.php
|
|
|
|
cp conf/zpush/backend_caldav.php /usr/local/lib/z-push/backend/caldav/config.php
|
2014-07-12 00:02:32 +00:00
|
|
|
|
2014-08-19 11:03:44 +00:00
|
|
|
# Configure Autodiscover
|
|
|
|
rm -f /usr/local/lib/z-push/autodiscover/config.php
|
|
|
|
cp conf/zpush/autodiscover_config.php /usr/local/lib/z-push/autodiscover/config.php
|
2014-08-19 11:49:20 +00:00
|
|
|
sed -i "s/PRIMARY_HOSTNAME/$PRIMARY_HOSTNAME/" /usr/local/lib/z-push/autodiscover/config.php
|
2017-04-17 11:42:44 +00:00
|
|
|
sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" /usr/local/lib/z-push/autodiscover/config.php
|
2014-08-19 11:03:44 +00:00
|
|
|
|
2014-07-12 00:02:32 +00:00
|
|
|
# Some directories it will use.
|
|
|
|
|
|
|
|
mkdir -p /var/log/z-push
|
|
|
|
mkdir -p /var/lib/z-push
|
|
|
|
chmod 750 /var/log/z-push
|
|
|
|
chmod 750 /var/lib/z-push
|
|
|
|
chown www-data:www-data /var/log/z-push
|
|
|
|
chown www-data:www-data /var/lib/z-push
|
|
|
|
|
2015-11-17 14:27:05 +00:00
|
|
|
# Add log rotation
|
|
|
|
|
|
|
|
cat > /etc/logrotate.d/z-push <<EOF;
|
|
|
|
/var/log/z-push/*.log {
|
|
|
|
weekly
|
|
|
|
missingok
|
|
|
|
rotate 52
|
|
|
|
compress
|
|
|
|
delaycompress
|
|
|
|
notifempty
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2014-07-12 00:02:32 +00:00
|
|
|
# Restart service.
|
|
|
|
|
2023-12-21 14:58:34 +00:00
|
|
|
restart_service php"$PHP_VER"-fpm
|
2017-04-17 11:42:44 +00:00
|
|
|
|
|
|
|
# Fix states after upgrade
|
|
|
|
|
2023-12-21 14:58:34 +00:00
|
|
|
hide_output php"$PHP_VER" /usr/local/lib/z-push/z-push-admin.php -a fixstates
|