2020-09-29 16:25:50 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
# INSTALL NODEJS
|
2020-09-29 16:25:50 +02:00
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_script_progression --message="Installing NodeJS..." --weight=20
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
# Install Nodejs
|
|
|
|
ynh_install_nodejs --nodejs_version="$nodejs_version"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
2022-06-16 03:06:21 +02:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
|
2022-06-16 04:10:16 +02:00
|
|
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
2024-01-17 00:10:12 +01:00
|
|
|
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"
|
2022-06-16 04:10:16 +02:00
|
|
|
fi
|
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_app_setting_delete --app="$app" --key=port
|
2022-06-16 04:10:16 +02:00
|
|
|
ynh_remove_systemd_config
|
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
if [[ -d "$install_dir/src/" ]]; then
|
|
|
|
mv "$install_dir/src" "$install_dir/live"
|
2022-06-23 02:00:22 +02:00
|
|
|
fi
|
|
|
|
|
2020-09-29 16:25:50 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=20
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source --dest_dir="$install_dir/source"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2022-06-18 15:37:49 +02:00
|
|
|
|
2022-06-16 03:06:21 +02:00
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
# BUILD APP
|
2022-06-16 03:06:21 +02:00
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=20
|
2022-06-16 03:06:21 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
pushd "$install_dir/build"
|
|
|
|
ynh_use_nodejs
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install
|
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$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
|
2022-06-16 03:06:21 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
mv "$install_dir/live/config.js" "$install_dir/config.js"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_secure_remove --file="$install_dir/live"
|
|
|
|
ynh_exec_as "$app" mv "$install_dir/source/dist" "$install_dir/live"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
mv "$install_dir/config.js" "$install_dir/live/config.js"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-06-16 04:10:16 +02:00
|
|
|
# UPDATE A CONFIG FILE
|
2020-09-29 16:25:50 +02:00
|
|
|
#=================================================
|
2022-06-16 04:10:16 +02:00
|
|
|
ynh_script_progression --message="Updating a configuration file..."
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_add_config --template="config.example.js" --destination="$install_dir/live/config.js"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
chmod 400 "$install_dir/live/config.js"
|
|
|
|
chown "$app:$app" "$install_dir/live/config.js"
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2022-06-16 04:10:16 +02:00
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2020-09-29 16:25:50 +02:00
|
|
|
#=================================================
|
2024-01-17 00:10:12 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
2020-09-29 16:25:50 +02:00
|
|
|
|
2024-01-17 00:10:12 +01:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2020-09-29 16:25:50 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-06-16 03:06:21 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|