1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/digiscreen_ynh.git synced 2024-09-03 18:26:15 +02:00
digiscreen_ynh/scripts/upgrade

90 lines
3 KiB
Text
Raw Normal View History

2022-02-16 10:25:34 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2022-03-13 01:22:48 +01:00
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
2022-02-16 10:25:34 +01:00
2024-01-17 16:04:18 +01:00
# Renamed settings
if [[ -z "${api_key_pixabay:-}" ]]; then
api_key_pixabay="$pixabay"
ynh_app_setting_delete --app="$app" --key=pixabay
ynh_app_setting_set --app="$app" --key="api_key_pixabay" --value="$api_key_pixabay"
2022-02-16 10:25:34 +01:00
2024-01-17 16:04:18 +01:00
api_key_google_youtube="$googleYoutube"
ynh_app_setting_delete --app="$app" --key=googleYoutube
ynh_app_setting_set --app="$app" --key="api_key_google_youtube" --value="$api_key_google_youtube"
2022-02-16 10:25:34 +01:00
fi
#=================================================
2024-01-17 16:04:18 +01:00
# INSTALL NODEJS
2022-02-16 10:25:34 +01:00
#=================================================
2024-01-17 16:04:18 +01:00
ynh_script_progression --message="Installing NodeJS..." --weight=1
2022-02-16 10:25:34 +01:00
2024-01-17 16:04:18 +01:00
ynh_install_nodejs --nodejs_version="$nodejs_version"
2022-02-16 10:25:34 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-01-17 16:04:18 +01:00
ynh_script_progression --message="Upgrading source files..." --weight=1
2022-02-16 10:25:34 +01:00
2024-01-17 16:04:18 +01:00
# Download, check integrity, uncompress and patch the source
ynh_setup_source --dest_dir="$install_dir" --full_replace=1
2022-02-16 10:25:34 +01:00
# Patch broken dependency
sed -i 's|"v-calendar": "^2.3.0"|"v-calendar": "2.3.0"|' "$install_dir/source/package.json"
2024-01-17 16:04:18 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
2022-02-16 10:25:34 +01:00
#=================================================
2024-01-17 16:04:18 +01:00
# NODEJS BUILD
2022-02-16 10:25:34 +01:00
#=================================================
2024-01-17 16:04:18 +01:00
ynh_script_progression --message="Building $app..." --weight=3
2022-02-16 10:25:34 +01:00
2024-01-17 16:04:18 +01:00
pushd "$install_dir/source"
echo VUE_APP_PIXABAY_API_KEY="$api_key_pixabay" >> .env
echo VUE_APP_GOOGLE_API_KEY="$api_key_google_youtube" >> .env
2022-02-16 10:25:34 +01:00
2024-01-17 16:04:18 +01:00
ynh_use_nodejs
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install
ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run build
popd
2022-02-16 10:25:34 +01:00
2024-01-17 16:04:18 +01:00
ynh_secure_remove --file="$install_dir/www"
mv "$install_dir/source/dist" "$install_dir/www"
ynh_secure_remove --file="$install_dir/source"
2022-02-16 10:25:34 +01:00
2024-01-17 16:04:18 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
2022-02-16 10:25:34 +01:00
#=================================================
2024-01-17 16:04:18 +01:00
# REAPPLY SYSTEM CONFIGURATIONS
2022-02-16 10:25:34 +01:00
#=================================================
2024-01-17 16:04:18 +01:00
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
2022-02-16 10:25:34 +01:00
2024-01-17 16:04:18 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2022-02-16 10:25:34 +01:00
2024-01-17 16:04:18 +01:00
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
2022-02-16 10:25:34 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2022-03-13 01:22:48 +01:00
ynh_script_progression --message="Upgrade of $app completed" --last