1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/retroarch_ynh.git synced 2024-09-03 20:16:12 +02:00
retroarch_ynh/scripts/upgrade

110 lines
4.1 KiB
Text
Raw Normal View History

2020-05-08 20:42:27 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
2023-08-20 16:50:19 +02:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Downward Compatibility checks..." --weight=1
#move from /opt/yunohost to /var/www : symbolic link will be remade by multimedia dir
if ynh_compare_current_package_version --comparison lt --version 1.15.0~ynh3; then
if [ -L /home/yunohost.multimedia/share/Game ]; then
#ynh_secure_remove --file="/home/yunohost.multimedia/share/Game"
rm /home/yunohost.multimedia/share/Game #ynh_secure_remove does not remove link
fi
fi
2020-05-08 20:42:27 +02:00
#=================================================
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
2021-05-09 19:11:18 +02:00
ynh_script_progression --message="Upgrading source files..." --weight=5
2020-05-08 20:42:27 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2023-05-07 18:10:21 +02:00
ynh_setup_source --dest_dir="$install_dir"
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
2023-08-20 11:23:25 +02:00
7zr x $install_dir/main -o$install_dir
2021-05-09 17:08:24 +02:00
#mv not working as target directory is not empty
2023-05-07 18:10:21 +02:00
cp -R $install_dir/retroarch/* $install_dir/
2023-08-20 11:23:25 +02:00
ynh_secure_remove --file="$install_dir/main"
2023-05-07 18:10:21 +02:00
touch $install_dir/analytics.js #https://github.com/libretro/RetroArch/issues/4539#issuecomment-473345195
2021-05-09 11:52:48 +02:00
#Get the indexer as exe so that folder w/ ROMs can be indexed
2023-05-07 18:10:21 +02:00
chmod +x $install_dir/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
2023-05-07 18:10:21 +02:00
ynh_add_config --template="../conf/indexer.sh" --destination="$install_dir/indexer.sh"
chown www-data: $install_dir/indexer.sh
chmod 744 $install_dir/indexer.sh
2021-05-09 11:52:48 +02:00
#setup cron file
cron_path="/etc/cron.d/$app"
ynh_add_config --template="../conf/retroarch.cron" --destination="$cron_path"
2022-01-30 22:35:23 +01:00
chown root: "$cron_path"
2021-05-09 11:52:48 +02:00
chmod 644 "$cron_path"
2021-05-09 11:19:10 +02:00
#=================================================
#SETTING MULTIMEDIA DIRECTORY
#=================================================
2021-05-09 19:11:18 +02:00
ynh_script_progression --message="Setting up Multimedia directory..." --weight=4
2021-05-09 11:19:10 +02:00
ynh_multimedia_build_main_dir
2023-05-07 18:10:21 +02:00
mkdir -p $install_dir/assets/cores/Game
ynh_multimedia_addfolder --source_dir="$install_dir/assets/cores/Game" --dest_dir="/share/Game"
ynh_add_config --template="../conf/README.GAME" --destination="$install_dir/assets/cores/Game/README"
chmod 666 $install_dir/assets/cores/Game/README
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 19:11:18 +02:00
ynh_script_progression --message="Upgrading NGINX web server configuration..." --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
#=================================================
2023-08-20 11:23:25 +02:00
ynh_script_progression --message="Upgrading dependencies..." --weight=20
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
#However, npm IS required to run the coffeescript
2021-09-08 10:11:26 +02:00
ynh_install_nodejs --nodejs_version=$nodejs_version
2021-05-09 11:52:48 +02:00
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
#=================================================
2023-08-20 11:23:25 +02:00
chown -R www-data:multimedia $install_dir
2022-01-30 22:35:23 +01:00
# Requested so that multimedia group can see the Game folder : all parent folder should be readable by others
2023-08-20 11:23:25 +02:00
chmod 750 $install_dir
2020-05-08 20:42:27 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2021-05-09 19:11:18 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last