mirror of
https://github.com/YunoHost-Apps/z-push_ynh.git
synced 2024-09-03 18:05:58 +02:00
146 lines
5.4 KiB
Bash
Executable file
146 lines
5.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# CHECK VERSION
|
|
#=================================================
|
|
|
|
timezone="$(cat /etc/timezone)"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading source files..."
|
|
|
|
mkdir "$install_dir/bkp"
|
|
conf_files_to_keep="config.php backend/caldav/config.php backend/carddav/config.php backend/imap/config.php backend/combined/config.php autodiscover/config.php backend/searchldap/config.php"
|
|
for file in $conf_files_to_keep
|
|
do
|
|
if [ -e $install_dir/$file ]
|
|
then
|
|
mkdir -p $install_dir/bkp/$(dirname $file)
|
|
cp $install_dir/$file $install_dir/bkp/$file
|
|
fi
|
|
done
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
mkdir "$install_dir/tmp"
|
|
ynh_setup_source --dest_dir="$install_dir/tmp"
|
|
cp -af "$install_dir/tmp/src/." "$install_dir/."
|
|
ynh_secure_remove --file="$install_dir/tmp"
|
|
|
|
for file in $conf_files_to_keep
|
|
do
|
|
if [ -e $install_dir/bkp/$file ]
|
|
then
|
|
cp $install_dir/bkp/$file $install_dir/$file
|
|
fi
|
|
done
|
|
ynh_secure_remove --file="$install_dir/bkp"
|
|
|
|
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 --non-append
|
|
|
|
#=================================================
|
|
# SPECIFIC UPGRADE
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Updating a config 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"
|
|
|
|
# Fixstates to avoid full resync of devices after version upgrades
|
|
"php$phpversion" "$install_dir/z-push-admin.php" -a fixstates
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|