mirror of
https://github.com/YunoHost-Apps/z-push_ynh.git
synced 2024-09-03 18:05:58 +02:00
125 lines
4.6 KiB
Bash
Executable file
125 lines
4.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
|
|
path="/Microsoft-Server-ActiveSync"
|
|
timezone="$(cat /etc/timezone)"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..."
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
mkdir -p "$install_dir/tmp"
|
|
ynh_setup_source --dest_dir="$install_dir/tmp"
|
|
cp -af "$install_dir/tmp/src/." "$install_dir/."
|
|
ynh_secure_remove "$install_dir/tmp"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Installing system configurations..."
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
ynh_add_fpm_config
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
mkdir -p "/var/log/$app/"
|
|
chmod 750 "/var/log/$app/"
|
|
chmod -R o-rwx "/var/log/$app/"
|
|
chown -R $app:www-data "/var/log/$app/"
|
|
|
|
ynh_use_logrotate
|
|
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding a configuration file..."
|
|
|
|
# Enable caldav carddav support
|
|
if yunohost app list | grep -q 'id: baikal' ; then
|
|
echo "Detected Baikal"
|
|
baikaldomain=$(ynh_app_setting_get --app="baikal" --key=domain)
|
|
baikalpath=$(ynh_app_setting_get --app="baikal" --key=path)
|
|
baikalpath=${baikalpath%/}
|
|
|
|
# Variables to hydrate template
|
|
backend="BackendCombined"
|
|
caldav_server="$baikaldomain"
|
|
caldav_path="${baikalpath}/cal.php/calendars/%u/"
|
|
caldav_personal="default"
|
|
|
|
carddav_server="$baikaldomain"
|
|
carddav_path="${baikalpath}/card.php/addressbooks/%u/"
|
|
carddav_default_path="${baikalpath}/card.php/addressbooks/%u/default"
|
|
|
|
imap_server="$domain"
|
|
imap_meeting_use_caldav="true"
|
|
|
|
ynh_add_config --template="backend/config-caldav.php" --destination="$install_dir/backend/caldav/config.php"
|
|
ynh_add_config --template="backend/config-carddav.php" --destination="$install_dir/backend/carddav/config.php"
|
|
ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php"
|
|
ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php"
|
|
|
|
elif yunohost app list | grep -q 'id: nextcloud' ; then
|
|
echo "Detected NextCloud"
|
|
nextclouddomain=$(ynh_app_setting_get --app="nextcloud" --key=domain)
|
|
nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path)
|
|
nextcloudpath=${nextcloudpath%/}
|
|
|
|
# Variables to hydrate template
|
|
backend="BackendCombined"
|
|
caldav_server="$nextclouddomain"
|
|
caldav_path="${nextcloudpath}/remote.php/dav/calendars/%u/"
|
|
caldav_personal="personal"
|
|
|
|
carddav_server="$nextclouddomain"
|
|
carddav_path="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/"
|
|
carddav_default_path="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/"
|
|
|
|
imap_server="$domain"
|
|
imap_meeting_use_caldav="true"
|
|
|
|
ynh_add_config --template="backend/config-caldav.php" --destination="$install_dir/backend/caldav/config.php"
|
|
ynh_add_config --template="backend/config-carddav.php" --destination="$install_dir/backend/carddav/config.php"
|
|
ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php"
|
|
ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php"
|
|
|
|
else
|
|
backend="BackendIMAP"
|
|
imap_server="$domain"
|
|
imap_meeting_use_caldav="false"
|
|
|
|
ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php"
|
|
fi
|
|
|
|
# Copy config
|
|
ynh_add_config --template="config.php" --destination="$install_dir/config.php"
|
|
ynh_add_config --template="backend/config-autodiscover.php" --destination="$install_dir/autodiscover/config.php"
|
|
ynh_add_config --template="backend/config-searchldap.php" --destination="$install_dir/backend/searchldap/config.php"
|
|
|
|
#Copy XMLElement.php
|
|
ln -s /usr/share/awl/inc/XML* /var/www/$app/include/
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|