#!/bin/bash #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=6 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="app/config/parameters.yml var/logs web/assets/images" # Create log dir/file FIXME: is it useless? mkdir -p "$install_dir/var/logs/" touch "$install_dir/var/logs/prod.log" # Set permissions to app files chown -R "$app:www-data" "$install_dir" # Restrict rights to Wallabag user only if [ -e "$install_dir/var/cache/prod/appProdProjectContainer.php" ]; then chmod 700 "$install_dir/var/cache/prod/appProdProjectContainer.php" fi #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Reconfiguring $app..." --weight=1 # Upgrade database and clear the cache php_exec doctrine:migrations:migrate php_exec cache:clear # Configure Wallabag instance URL ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" \ <<< "UPDATE internal_setting SET value = 'https://$domain$path' WHERE name = 'wallabag_url'" #================================================= # SETUP HOOKS #================================================= ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_user_create" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_user_delete" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config # Create a dedicated PHP-FPM config ynh_add_fpm_config ynh_use_logrotate --non-append --logfile="$install_dir/var/logs/prod.log" # Add fail2ban config ynh_add_fail2ban_config --logpath="$install_dir/var/logs/prod.log" --failregex='app.ERROR: Authentication failure for user "([\w]+)?", from IP ""' --max_retry=5 # same as install config #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last