2020-05-08 20:42:27 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
2021-06-06 23:28:54 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2021-05-13 21:28:15 +02:00
|
|
|
path_url=$YNH_APP_ARG_PATH
|
2020-05-08 20:42:27 +02:00
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
2021-05-08 15:43:13 +02:00
|
|
|
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
2020-05-08 20:42:27 +02:00
|
|
|
|
2021-04-25 16:50:33 +02:00
|
|
|
final_path=/opt/yunohost/$app
|
2020-05-08 20:42:27 +02:00
|
|
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
|
|
|
|
|
|
|
# Register (book) web path
|
|
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2021-05-08 15:43:13 +02:00
|
|
|
ynh_script_progression --message="Storing installation settings..." --weight=1
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
|
|
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2021-05-08 15:43:13 +02:00
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=13
|
2020-05-08 20:42:27 +02:00
|
|
|
|
2021-09-08 10:11:26 +02:00
|
|
|
ynh_install_nodejs --nodejs_version=$nodejs_version
|
2020-05-08 20:42:27 +02:00
|
|
|
ynh_use_nodejs
|
|
|
|
ynh_npm install -g coffeescript
|
|
|
|
|
2021-02-20 19:31:31 +01:00
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2021-05-08 15:43:13 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=60
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2021-02-20 19:31:31 +01:00
|
|
|
# uncompress and patch done manually as 7z format is not supported
|
2020-05-08 20:42:27 +02:00
|
|
|
ynh_setup_source --dest_dir="$final_path" --source_id=$app
|
2021-04-25 16:50:33 +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
|
|
|
|
mv $final_path/retroarch/* $final_path/
|
2021-05-09 11:52:48 +02:00
|
|
|
ynh_secure_remove --file="$final_path/retroarch.7z"
|
|
|
|
ynh_secure_remove --file="$final_path/retroarch"
|
2021-02-20 19:31:31 +01:00
|
|
|
|
|
|
|
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
|
2020-05-08 20:42:27 +02:00
|
|
|
chmod +x $final_path/indexer
|
|
|
|
|
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:12 +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 17:36:41 +02:00
|
|
|
ynh_add_config --template="../conf/README.GAME" --destination="$final_path/assets/cores/Game/README"
|
|
|
|
chmod 666 $final_path/assets/cores/Game/README
|
2021-05-09 11:19:10 +02:00
|
|
|
|
|
|
|
# SETUP CRON FILE FOR INDEXER
|
|
|
|
|
|
|
|
#setup indexer bash script
|
|
|
|
ynh_add_config --template="../conf/indexer.sh" --destination="$final_path/indexer.sh"
|
2021-05-10 23:19:36 +02:00
|
|
|
chown www-data: $final_path/indexer.sh
|
2021-05-09 11:19:10 +02:00
|
|
|
chmod 744 $final_path/indexer.sh
|
2021-09-08 10:11:26 +02:00
|
|
|
|
2021-05-09 11:19:10 +02:00
|
|
|
#setup cron file
|
|
|
|
cron_path="/etc/cron.d/$app"
|
|
|
|
ynh_add_config --template="../conf/retroarch.cron" --destination="$cron_path"
|
|
|
|
chmod 644 "$cron_path"
|
|
|
|
|
2020-05-08 20:42:27 +02:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2021-09-08 10:11:26 +02:00
|
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=3
|
2020-05-08 20:42:27 +02:00
|
|
|
|
2021-02-20 19:31:31 +01:00
|
|
|
#backup & Update nginx MIME type so wasm mime type is recognized
|
2020-05-08 20:42:27 +02:00
|
|
|
|
2021-02-20 19:31:31 +01:00
|
|
|
if [ !$(grep wasm /etc/nginx/mime.types) ]; then
|
|
|
|
ynh_print_info "/etc/nginx/mime.types saved as /etc/nginx/mime.types.$app"
|
|
|
|
cp /etc/nginx/mime.types /etc/nginx/mime.types.$app
|
|
|
|
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"
|
2020-05-08 20:42:27 +02:00
|
|
|
fi
|
|
|
|
|
2021-02-20 19:31:31 +01:00
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
2020-05-08 20:42:27 +02:00
|
|
|
|
2021-05-10 23:19:36 +02:00
|
|
|
### For security reason, any app should set the permissions to www-data: before anything else.
|
2020-05-08 20:42:27 +02:00
|
|
|
### Then, if write authorization is needed, any access should be given only to directories
|
|
|
|
### that really need such authorization.
|
|
|
|
|
|
|
|
# Set permissions to app files
|
2021-05-10 23:19:36 +02:00
|
|
|
chown -R www-data: $final_path
|
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
|
|
|
|
chmod 751 $final_path
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
2021-09-08 10:11:26 +02:00
|
|
|
ynh_script_progression --message="Configuring permissions..." --weight=1
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
# Make app public if necessary
|
|
|
|
if [ $is_public -eq 1 ]
|
|
|
|
then
|
2021-02-20 19:31:31 +01:00
|
|
|
ynh_permission_update --permission "main" --add visitors
|
2020-05-08 20:42:27 +02:00
|
|
|
fi
|
|
|
|
|
2021-05-09 11:19:10 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP INDEX
|
|
|
|
#=================================================
|
|
|
|
#indexer use the current directory to run #https://github.com/libretro/RetroArch/tree/master/pkg/emscripten,
|
|
|
|
# so we have to cd in it to use it correctly => last step of the install so to not mess with other commands relative path
|
|
|
|
#Indexer will list the available ROM and cores for Retroarch
|
|
|
|
ynh_script_progression --message="Setup Indexer for content..." --weight=3
|
|
|
|
|
|
|
|
cd $final_path/assets/frontend/bundle/
|
|
|
|
../../../indexer > .index-xhr
|
|
|
|
cd $final_path/assets/cores
|
|
|
|
../../indexer > .index-xhr
|
|
|
|
|
2020-05-08 20:42:27 +02:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2021-09-08 10:11:26 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
2020-05-08 20:42:27 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
2021-05-08 15:43:13 +02:00
|
|
|
|
2020-05-08 20:42:27 +02:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-05-08 15:43:13 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|