#!/bin/bash #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # INITIALIZE AND STORE SETTINGS #================================================= admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 ynh_systemd_action --service_name="${app}-app" --action="stop" --log_path=systemd ynh_systemd_action --service_name="${app}-worker" --action="stop" --log_path=systemd #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then ynh_script_progression --message="Removing $app service integration..." yunohost service remove "$app" fi ynh_remove_logrotate ynh_secure_remove --file="/etc/supervisor/conf.d/$app.conf" ynh_secure_remove --file="/var/log/supervisor/$app-app-stderr.log" ynh_secure_remove --file="/var/log/supervisor/$app-app-stdout.log" ynh_secure_remove --file="/var/log/supervisor/$app-worker-stderr.log" ynh_secure_remove --file="/var/log/supervisor/$app-worker-stdout.log" #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Updating NodeJS..." --weight=1 ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" ynh_script_progression --message="Updating Ruby..." --weight=4 ynh_exec_warn_less ynh_install_ruby --ruby_version="$ruby_version" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config/secrets.yml config/database.yml" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="secrets.yml" --destination="$install_dir/config/secrets.yml" chmod 400 "$install_dir/config/secrets.yml" chown "$app:$app" "$install_dir/config/secrets.yml" ynh_add_config --template="database.yml" --destination="$install_dir/config/database.yml" chmod 400 "$install_dir/config/database.yml" chown "$app:$app" "$install_dir/config/database.yml" #================================================= # BUILD APP #================================================= ynh_script_progression --message="Building app..." --weight=7 ynh_secure_remove --file="$install_dir/.cache" ynh_secure_remove --file="$install_dir/node_modules" ynh_secure_remove --file="$install_dir/tmp/cache" fabmanager_build_ruby fabmanager_migrate_db fabmanager_build_ui #================================================= # 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 systemd config ynh_add_systemd_config --service="$app-app" --template="fab-manager-app.service" ynh_add_systemd_config --service="$app-worker" --template="fab-manager-worker.service" yunohost service add "$app-app" --description="$app app service" yunohost service add "$app-worker" --description="$app worker service" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting $app's systemd service..." --weight=1 ynh_systemd_action --service_name="${app}-app" --action="start" --log_path=systemd ynh_systemd_action --service_name="${app}-worker" --action="start" --log_path=systemd --line_match="Schedules Loaded" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last