#!/usr/bin/env bash

set -e
set -x

. ${0%/*}/_functions.sh

ok "* installing z-push notifications"

phpenmod imap

cd /opt
#wget -q http://download.z-push.org/final/2.3/z-push-2.3.9.tar.gz
wget -q http://poste.io/z-push-2.3.9.tar.gz
tar xvfz z-push-2.3.9.tar.gz && rm z-push-2.3.9.tar.gz
mv z-push-2.3.9 z-push

# settings
# --------

replaceLine "define('BACKEND_PROVIDER" "define('BACKEND_PROVIDER', 'BackendIMAP');" /opt/z-push/config.php
replaceLine "define('USE_FULLEMAIL_FOR_LOGIN" "define('USE_FULLEMAIL_FOR_LOGIN', true);" /opt/z-push/config.php

replaceLine "define('IMAP_FOLDER_CONFIGURED" "define('IMAP_FOLDER_CONFIGURED', true);" /opt/z-push/backend/imap/config.php

ln -s /opt/z-push/z-push-admin.php /usr/sbin/z-push-admin
ln -s /opt/z-push/z-push-top.php /usr/sbin/z-push-top
