#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_script_progression --message="Upgrading NodeJS..." --weight=10 ynh_install_nodejs --nodejs_version="$nodejs_version" #================================================= # STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= # SPECIFIC UPGRADE #================================================= # BUILD NODE DEPENDENCIES #================================================= ynh_script_progression --message="Install $app..." --weight=10 pushd "$install_dir" ynh_use_nodejs ynh_exec_warn_less env $ynh_node_load_PATH yarn install ynh_exec_warn_less env $ynh_node_load_PATH yarn build:frontend:app ynh_exec_warn_less env $ynh_node_load_PATH yarn build:server popd 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 config files..." --weight=2 ynh_add_config --template="config.env" --destination="$install_dir/config.env" chown -R "$app:www-data" "$install_dir/config.env" chmod 400 "$install_dir/config.env" #================================================= # GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= ynh_script_progression --message="Setting files permissions..." --weight=1 # Set permissions on app files chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # 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="Collaborative maps and routing" --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 a systemd service..." --weight=5 ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server started" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last