| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #!/bin/bash
- source /usr/share/yunohost/helpers
- source _common.sh
- # UPGRADE_PACKAGE if only the YunoHost package has changed
- # UPGRADE_APP if the upstream app version has changed
- # DOWNGRADE
- # UPGRADE_SAME
- upgrade_type=$(ynh_check_app_version_changed)
- # show variables - used from installed or from to be upgraded version?
- # variables of the new upgrade version are used
- # env
- ynh_script_progression --message="Stopping flohmarkt and CouchDB..." --weight=5
- # stop flohmarkt
- flohmarkt_ynh_stop_service
- # stop couchdb
- flohmarkt_ynh_stop_couchdb
- # Upgrade ynh4 → ynh5, change of paths and filenames
- # https://matrix.to/#/!PauySEslPVuJCJCwlZ:matrix.org/$auU_rSL6MACt9wkyFGlCQbO8ivFlU0ztYW74TimZdcM?via=matrix.org&via=aria-net.org&via=sans-nuage.fr
- # and follow-ups
- if ynh_compare_current_package_version --comparison lt --version 0.0~ynh5 &&
- ( [[ "$upgrade_type" == UPGRADE_PACKAGE ]] || [[ "$upgrade_type" == UPGRADE_APP ]] )
- then
- flohmarkt_ynh_upgrade_path_ynh5
- fi
- # upgrade couchdb
- ynh_script_progression --message="Upgrading CouchDB..." --weight=50
- flohmarkt_ynh_up_inst_couchdb
- # stop couchdb
- ynh_script_progression --message="Stop couchdb before updating configuration file..." --weight=1
- flohmarkt_ynh_stop_couchdb
- # upgrade couchdb config
- ynh_script_progression --message="Updating couchdb configuration file..." --weight=1
- ynh_add_config --template="../conf/05-flohmarkt.ini" --destination="/opt/couchdb/etc/local.d/05-flohmarkt.ini"
- chown root:couchdb /opt/couchdb/etc/local.d/05-flohmarkt.ini
- chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
- # start couchdb
- ynh_script_progression --message="Starting couchdb..." --weight=1
- flohmarkt_ynh_start_couchdb
- # install upgrade for flohmarkt
- ynh_script_progression --message="Upgrading flohmarkt..." --weight=4
- ynh_setup_source --dest_dir="$flohmarkt_app_dir/"
- ynh_script_progression --message="Upgrading flohmarkt python dependencies..." --weight=6
- # upgrade python environment / install new dependencies
- flohmarkt_ynh_venv_requirements
- # upgrade flohmarkt.conf
- ynh_script_progression --message="Upgrading flohmarkt configuration..." --weight=1
- ynh_add_config --template="../conf/flohmarkt.conf" --destination="$flohmarkt_app_dir/flohmarkt.conf"
- ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10
- flohmarkt_ynh_initialize_couchdb
- # set file permissions for install dir
- flohmarkt_ynh_set_permission
- # systemd service upgrade
- ynh_script_progression --message="Upgrading flohmarkt systemd service..." --weight=1
- ynh_add_systemd_config --service=$flohmarkt_filename
- # INTEGRATE SERVICE IN YUNOHOST
- ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
- yunohost service add $flohmarkt_filename --description="A decentral federated small advertisement platform" --log="$flohmarkt_logfile"
- # upgrade logrotate
- ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
- # Use logrotate to manage app-specific logfile(s)
- ynh_use_logrotate --non-append
- # upgrade nginx configuration
- ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
- ynh_add_nginx_config
- # UPGRADE FAIL2BAN
- ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=3
- ynh_add_fail2ban_config --logpath="$flohmarkt_logfile" --failregex='INFO: +<HOST>:\d+ - "POST /token HTTP/\d+\.\d+" 403 Forbidden' --max_retry=5
- # start flohmarkt
- ynh_script_progression --message="Starting flohmarkt..." --weight=3
- flohmarkt_ynh_start_service
- ynh_script_progression --message="Upgrade of $app completed" --last
|