#!/bin/bash #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." if [ ! -d "$install_dir/sources" ]; then # Final cleanup... ynh_secure_remove --file="$install_dir" mkdir -p "$install_dir" chmod 750 "$install_dir" fi #================================================= # INSTALLĀ GO #================================================= ynh_script_progression --message="Upgrading Go..." --weight=10 ynh_install_go --go_version="$go_version" #================================================= # INSTALLĀ NODEJS #================================================= ynh_script_progression --message="Upgrading NodeJS..." --weight=10 ynh_install_nodejs --nodejs_version="$node_version" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=5 ynh_setup_source --dest_dir="$install_dir/sources" --full_replace=1 mkdir -p "$install_dir/output/"{data,ui} chown -R "$app:$app" "$install_dir" chown -R "$app:$app" "$data_dir" #================================================= # BUILD APP #================================================= ynh_script_progression --message="Compiling Go API..." --weight=165 build_api ynh_script_progression --message="Building static UI files..." --weight=45 build_ui cleanup_sources #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." ynh_add_config --template=".env" --destination="$install_dir/output/.env" chown "$app:$app" "$install_dir/output/.env" #================================================= # 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 yunohost service add "$app" --description="Photoview photo manager API" --log="/var/log/$app/$app.log" # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting $app's systemd service..." --weight=1 ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last