2020-05-08 20:42:27 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
|
|
|
### $upgrade_type can have 2 different values
|
|
|
|
### - UPGRADE_APP if the upstream app version has changed
|
|
|
|
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
|
|
|
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
|
|
|
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
|
|
|
|
|
|
|
|
# Backup the current version of the app
|
|
|
|
ynh_backup_before_upgrade
|
|
|
|
ynh_clean_setup () {
|
2021-05-09 11:52:48 +02:00
|
|
|
# Restore it if the upgrade fails
|
2020-05-08 20:42:27 +02:00
|
|
|
ynh_restore_upgradebackup
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
2021-05-09 11:52:48 +02:00
|
|
|
# STANDARD UPGRADE STEPS
|
2020-05-08 20:42:27 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2021-02-20 19:31:31 +01:00
|
|
|
ynh_setup_source --dest_dir="$final_path" --source_id=$app
|
2021-05-09 11:52:48 +02:00
|
|
|
#7z archive not handled by ynh and no way to strip component, have to move it manually
|
|
|
|
7zr x $final_path/retroarch.7z -o$final_path
|
2021-05-09 17:08:24 +02:00
|
|
|
#mv not working as target directory is not empty
|
|
|
|
cp -R $final_path/retroarch/* $final_path/
|
2021-05-09 11:52:48 +02:00
|
|
|
mv $final_path/retroarch/* $final_path/
|
|
|
|
ynh_secure_remove --file="$final_path/retroarch.7z"
|
|
|
|
ynh_secure_remove --file="$final_path/retroarch"
|
|
|
|
touch $final_path/analytics.js #https://github.com/libretro/RetroArch/issues/4539#issuecomment-473345195
|
|
|
|
#Get the indexer as exe so that folder w/ ROMs can be indexed
|
|
|
|
chmod +x $final_path/indexer
|
2020-05-08 20:42:27 +02:00
|
|
|
fi
|
|
|
|
|
2021-05-09 11:52:48 +02:00
|
|
|
# SETUP CRON FILE FOR INDEXER
|
2020-05-08 20:42:27 +02:00
|
|
|
|
2021-05-09 11:52:48 +02:00
|
|
|
#setup indexer bash script
|
|
|
|
ynh_add_config --template="../conf/indexer.sh" --destination="$final_path/indexer.sh"
|
|
|
|
chown root: $final_path/indexer.sh
|
|
|
|
chmod 744 $final_path/indexer.sh
|
|
|
|
#setup cron file
|
|
|
|
cron_path="/etc/cron.d/$app"
|
|
|
|
ynh_add_config --template="../conf/retroarch.cron" --destination="$cron_path"
|
|
|
|
chown root: "$cron_path"
|
|
|
|
chmod 644 "$cron_path"
|
2021-05-09 11:19:10 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#SETTING MULTIMEDIA DIRECTORY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up Multimedia directory..." --weight=9
|
|
|
|
|
|
|
|
ynh_multimedia_build_main_dir
|
2021-05-09 17:08:24 +02:00
|
|
|
mkdir -p $final_path/assets/cores/Game
|
|
|
|
ynh_multimedia_addfolder --source_dir="$final_path/assets/cores/Game" --dest_dir="/share/Game"
|
2021-05-09 11:19:10 +02:00
|
|
|
|
2020-05-08 20:42:27 +02:00
|
|
|
#=================================================
|
2021-05-09 11:52:48 +02:00
|
|
|
# NGINX CONFIGURATION
|
2020-05-08 20:42:27 +02:00
|
|
|
#=================================================
|
2021-05-09 11:52:48 +02:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1
|
2020-05-08 20:42:27 +02:00
|
|
|
|
2021-05-09 11:52:48 +02:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-05-09 11:52:48 +02:00
|
|
|
# UPGRADE DEPENDENCIES
|
2020-05-08 20:42:27 +02:00
|
|
|
#=================================================
|
2021-05-09 11:52:48 +02:00
|
|
|
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
2020-05-08 20:42:27 +02:00
|
|
|
|
2021-05-09 11:52:48 +02:00
|
|
|
# Define and install dependencies
|
|
|
|
#Dependencies are not really required as this is just to unzip the 7z file
|
2021-05-09 14:04:51 +02:00
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
2021-05-09 11:52:48 +02:00
|
|
|
#However, npm IS required to run the coffeescript
|
|
|
|
ynh_install_nodejs --nodejs_version=10
|
|
|
|
ynh_use_nodejs
|
|
|
|
ynh_npm install -g coffeescript
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-05-09 11:52:48 +02:00
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# Set permissions on app files
|
2020-05-08 20:42:27 +02:00
|
|
|
#=================================================
|
2021-05-09 11:52:48 +02:00
|
|
|
#
|
|
|
|
chown -R root: $final_path
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2021-05-09 11:52:48 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --time --last
|