mirror of
https://github.com/YunoHost-Apps/retroarch_ynh.git
synced 2024-09-03 20:16:12 +02:00
Update scripts to new standard
This commit is contained in:
parent
4dcc10a89c
commit
804d0e5125
6 changed files with 71 additions and 114 deletions
|
@ -8,7 +8,7 @@
|
|||
},
|
||||
"version": "1.9.1~ynh1",
|
||||
"url": "http://www.retroarch.com/",
|
||||
"license": "free",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"maintainer": {
|
||||
"name": "Krakinou",
|
||||
"email": "misterl56@hotmail.com"
|
||||
|
@ -25,19 +25,15 @@
|
|||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain name for RetroArch (RetroArch requires its own domain)",
|
||||
"fr": "Choisissez un nom de domaine pour RetroArch (RetroArch nécessite son propre domaine)"
|
||||
"help": {
|
||||
"en": "RetroArch requires its own subdomain",
|
||||
"fr": "RetroArch nécessite son propre sous-domaine"
|
||||
},
|
||||
"example": "retroarch.example.com"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Is it a public application?",
|
||||
"fr": "Est-ce une application publique ?"
|
||||
},
|
||||
"default": true,
|
||||
"help":{
|
||||
"en":"Yes will allow everyone to access the app without login to yunohost instance first",
|
||||
|
|
|
@ -24,36 +24,42 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
|
||||
#=================================================
|
||||
# BACKUP A CRON FILE
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
#ynh_backup --src_path="/etc/cron.d/$app"
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -25,11 +25,8 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
#path_url=$YNH_APP_ARG_PATH
|
||||
path_url="/"
|
||||
#admin=$YNH_APP_ARG_ADMIN
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
#language=$YNH_APP_ARG_LANGUAGE
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
|
@ -50,7 +47,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=1
|
|||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
|
@ -75,12 +71,9 @@ ynh_setup_source --dest_dir="$final_path" --source_id=$app
|
|||
#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
|
||||
mv $final_path/retroarch/* $final_path/
|
||||
rm $final_path/retroarch.7z
|
||||
rm -r $final_path/retroarch
|
||||
ynh_secure_remove --file="$final_path/retroarch.7z"
|
||||
ynh_secure_remove --file="$final_path/retroarch"
|
||||
|
||||
#create additionnal folders & file #https://github.com/libretro/RetroArch/tree/master/pkg/emscripten
|
||||
#mkdir -p $final_path/assets/frontend/bundle
|
||||
#mkdir -p $final_path/assets/cores
|
||||
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
|
||||
|
|
|
@ -31,7 +31,13 @@ ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
|||
ynh_use_nodejs
|
||||
ynh_npm uninstall -g coffeescript
|
||||
ynh_remove_nodejs
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE CRONJOB
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove --file="/etc/cron.d/$app
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
|
|
|
@ -60,6 +60,8 @@ if [ !$(grep wasm /etc/nginx/mime.types) ]; then
|
|||
ynh_replace_string --match_string=" application/octet-stream bin exe dll;" --replace_string=" application/wasm wasm;\n\n application/octet-stream bin exe dll;" --target_file="/etc/nginx/mime.types"
|
||||
ynh_store_file_checksum --file="/etc/nginx/mime.types"
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -84,11 +86,8 @@ ynh_script_progression --message="Reinstalling dependencies..." --time --weight=
|
|||
# Define and install dependencies
|
||||
#Dependencies are not really required as this is just to unzip the 7z file
|
||||
#ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#However, npm IS required to run the coffeescript
|
||||
#ynh_install_nodejs --nodejs_version=14
|
||||
#ynh_use_nodejs
|
||||
#ynh_npm install -g coffeescript
|
||||
ynh_install_nodejs --nodejs_version=10
|
||||
ynh_use_nodejs
|
||||
ynh_npm install -g coffeescript
|
||||
|
||||
|
@ -99,22 +98,15 @@ ynh_npm install -g coffeescript
|
|||
ynh_script_progression --message="Setting up Multimedia directory..." --weight=9
|
||||
|
||||
ynh_multimedia_build_main_dir
|
||||
ynh_multimedia_addfolder --source_dir="$final_path/assets/cores" --dest_dir="/Game"
|
||||
ynh_multimedia_addfolder --source_dir="$final_path/assets/cores" --dest_dir="/share/Game"
|
||||
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE CRON FILE
|
||||
#=================================================
|
||||
|
||||
#ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
#ynh_app_setting_set $app unprotected_uris "/"
|
||||
ynh_permission_update --permission "main" --add visitors
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
118
scripts/upgrade
118
scripts/upgrade
|
@ -18,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
|
@ -33,26 +32,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
### 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)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -61,24 +40,14 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
|
|||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK THE PATH
|
||||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
# N.B. : this is for app installations before YunoHost 2.7
|
||||
# where this value might be something like /foo/ or foo/
|
||||
# instead of /foo ....
|
||||
# If nobody installed your app before 2.7, then you may
|
||||
# safely remove this line
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -89,32 +58,27 @@ then
|
|||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id=$app
|
||||
7zr e $final_path/retroarch.7z -o$final_path
|
||||
rm $final_path/retroarch.7z
|
||||
#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
|
||||
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
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
# SETUP CRON FILE FOR INDEXER
|
||||
|
||||
#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"
|
||||
|
||||
#=================================================
|
||||
#SETTING MULTIMEDIA DIRECTORY
|
||||
|
@ -122,42 +86,42 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_script_progression --message="Setting up Multimedia directory..." --weight=9
|
||||
|
||||
ynh_multimedia_build_main_dir
|
||||
ynh_multimedia_addfolder --source_dir="$final_path/assets/cores" --dest_dir="/Game"
|
||||
|
||||
ynh_multimedia_addfolder --source_dir="$final_path/assets/cores" --dest_dir="/share/Game"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1
|
||||
|
||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
||||
#ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE"
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
#ynh_store_file_checksum --file="$final_path/CONFIG_FILE"
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||
|
||||
# Define and install dependencies
|
||||
#Dependencies are not really required as this is just to unzip the 7z file
|
||||
#ynh_install_app_dependencies $pkg_dependencies
|
||||
#However, npm IS required to run the coffeescript
|
||||
ynh_install_nodejs --nodejs_version=10
|
||||
ynh_use_nodejs
|
||||
ynh_npm install -g coffeescript
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# Set permissions on app files
|
||||
#=================================================
|
||||
#
|
||||
chown -R root: $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
Loading…
Reference in a new issue