mirror of
https://github.com/YunoHost-Apps/z-push_ynh.git
synced 2024-09-03 18:05:58 +02:00
94 lines
3 KiB
Bash
94 lines
3 KiB
Bash
#!/bin/bash
|
|
|
|
# Retrieve arguments
|
|
domain=$1
|
|
path="/Microsoft-Server-ActiveSync"
|
|
app=z-push
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain$path -a $app
|
|
if [[ ! $? -eq 0 ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
# Prereqs
|
|
sudo apt-get install php-soap php5-imap libawl-php php5-xsl -y
|
|
|
|
final_logpath=/var/log/$app
|
|
final_path=/var/www/$app
|
|
|
|
# Copy files to the right place
|
|
sudo mkdir -p $final_path
|
|
sudo cp -a ../sources/* $final_path
|
|
|
|
# Configuration
|
|
sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php
|
|
sed -i "s@ALIASTOCHANGE@$final_path@g" ../conf/config.php
|
|
sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/config.php
|
|
|
|
# Enable caldav carddav support
|
|
sudo yunohost app list -f baikal --json | grep '"installed": true'
|
|
if [ "$?" -eq 0 ]; then
|
|
echo "Detected Baikal"
|
|
caldavdomain=$(sudo yunohost app setting baikal domain)
|
|
caldavpath=$(sudo yunohost app setting baikal path)
|
|
caldavpath=${caldavpath%/}
|
|
|
|
# Configuration of backend
|
|
sed -i "s@BACKENDTOCHANGE@BackendCombined@g" ../conf/config.php
|
|
|
|
# Configuration baikal
|
|
sed -i "s@BAIKALDOMAIN@$caldavdomain@g" ../conf/backend/config*.php
|
|
sed -i "s@BAIKALPATH@$caldavpath@g" ../conf/backend/config*.php
|
|
sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/backend/config-imap.php
|
|
sed -i "s@FLAGTOCHANGE@true@g" ../conf/backend/config-imap.php
|
|
|
|
# Copy config
|
|
sudo cp ../conf/config.php $final_path/config.php
|
|
sudo cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php
|
|
sudo cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php
|
|
sudo cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php
|
|
sudo cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php
|
|
else
|
|
# Configuration of backend
|
|
sed -i "s@BACKENDTOCHANGE@BackendIMAP@g" ../conf/config.php
|
|
|
|
# Copy config
|
|
sudo cp ../conf/config.php $final_path/config.php
|
|
sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/backend/config-imap.php
|
|
sed -i "s@FLAGTOCHANGE@false@g" ../conf/backend/config-imap.php
|
|
sudo cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php
|
|
|
|
fi
|
|
|
|
# Set permissions to z-push directory
|
|
sudo chown -R www-data: $final_path
|
|
|
|
|
|
# Create log directory
|
|
sudo mkdir -p $final_logpath
|
|
sudo chmod 750 $final_logpath
|
|
sudo chown www-data:www-data $final_logpath
|
|
|
|
#Copy XMLElement.php
|
|
sudo ln -s /usr/share/awl/inc/XML* /var/www/$app/include/
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
|
sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
# Dedicated php-fpm processes
|
|
sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
|
|
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
|
sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
sudo chown root: $finalphpconf
|
|
sudo chmod 644 $finalphpconf
|
|
|
|
# Enable api for client
|
|
sudo yunohost app setting $app skipped_uris -v "/"
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
sudo service php5-fpm reload
|
|
sudo service nginx reload
|
|
sudo yunohost app ssowatconf
|