#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # INSTALL NODEJS #================================================= ynh_script_progression --message="Installing NodeJS..." --weight=20 # Install Nodejs ynh_install_nodejs --nodejs_version="$nodejs_version" #================================================= # STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null; then ynh_script_progression --message="Removing $app service integration..." --weight=1 yunohost service remove "$app" fi ynh_app_setting_delete --app="$app" --key=port ynh_remove_systemd_config if [[ -d "$install_dir/src/" ]]; then mv "$install_dir/src" "$install_dir/live" fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=20 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/source" --full_replace=1 chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= # BUILD APP #================================================= ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=20 pushd "$install_dir/source" ynh_use_nodejs ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install ynh_exec_warn_less env "$ynh_node_load_PATH" "$ynh_npm" install gulp -g ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build popd mv "$install_dir/live/config.js" "$install_dir/config.js" ynh_secure_remove --file="$install_dir/live" ynh_exec_as "$app" mv "$install_dir/source/dist" "$install_dir/live" mv "$install_dir/config.js" "$install_dir/live/config.js" chmod 750 "$install_dir" 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..." ynh_add_config --template="config.example.js" --destination="$install_dir/live/config.js" chmod 400 "$install_dir/live/config.js" chown "$app:$app" "$install_dir/live/config.js" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last