#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # GET THE CALDAV APP #================================================= caldav_info=$(_ynh_agendav_find_caldav_app) caldav_app="$(cut -d " " -f 1 <<< "$caldav_info")" caldav_baseurl="$(cut -d " " -f 2 <<< "$caldav_info")" #================================================= # STANDARD MODIFICATIONS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=4 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config # Create a dedicated NGINX config ynh_add_nginx_config mkdir -p "/var/log/$app" chown -R "$app:" "/var/log/$app" # Use logrotate to manage application logfile(s) ynh_use_logrotate #================================================= # SPECIFIC SETUP #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=2 # Generate random encryption key encryptkey=$(ynh_string_random --length=24) ynh_app_setting_set --app="$app" --key=encryptkey --value="$encryptkey" # Copy and set AgenDAV configuration timezone=$(cat /etc/timezone) caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain) caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path) caldav_url="https://${caldav_domain}${caldav_path%/}" caldav_baseurl="${caldav_url}${caldav_baseurl}" ynh_add_config --template="../conf/settings.php" --destination="${install_dir}/web/config/settings.php" #================================================= # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) #================================================= ynh_script_progression --message="Initialising $app..." --weight=3 ( cd "$install_dir" || ynh_die "php$phpversion" agendavcli migrations:migrate --no-interaction ) chown -R "$app:www-data" "$install_dir" # Only agendav user should write here chown -R "$app" "$install_dir/web/var/cache/"{profiler,twig} # The agendav user should read here, but does not need to write # Other users should not be able to read as it stores passwords. chown -R "$app:www-data" "$install_dir/web/config/" chmod -R 750 "$install_dir/web/config/" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last