diff --git a/README.md b/README.md index 6c6aa0f..3adcfbf 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ These programs are instantiated as dynamic libraries. We refer to these as "libr * no user management * some core are listed but not implemented : they do not work, the issue is from the upstream app. * Games are located in `/opt/yunohost/retroarch/assets/cores`. A symbolic link is created to this folder in `/home/yunohost.multimedia/share/Games`, so that you can place your games from here -* cores have to be indexed to work : script `/opt/yunohost/retroarch/indexer.sh` run every 10 minutes to index all games in `opt/yunohost/retroarch/assets/cores` +* cores have to be indexed to work : script `/opt/yunohost/retroarch/indexer.sh` run every 5 minutes to index all games in `opt/yunohost/retroarch/assets/cores` **Shipped version:** 1.9.1 diff --git a/README_fr.md b/README_fr.md index 4d3df85..015ae07 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Ces programmes sont instanciés comme bibliothèques dynamiques, appelées "libr * Pas de gestion d'utilisateurs * certains cores sont listés mais ne sont pas implémentés : ils ne fonctionnent donc pas, le problème vient de l'application elle même. * Les jeux sont situés dans `/opt/yunohost/retroarch/assets/cores`. Un lien symbolique est créé vers `/home/yunohost.multimedia/share/Games` de façon à ce que vous puissiez les y mettre facilement. -* Les cores doivent être indexés pour fonctionner : le script `/opt/yunohost/retroarch/indexer.sh` tourne toutes les 10 minutes pour indexer tous les jeux dans `opt/yunohost/retroarch/assets/cores` +* Les cores doivent être indexés pour fonctionner : le script `/opt/yunohost/retroarch/indexer.sh` tourne toutes les 5 minutes pour indexer tous les jeux dans `opt/yunohost/retroarch/assets/cores` diff --git a/conf/indexer.sh b/conf/indexer.sh new file mode 100644 index 0000000..53b93d1 --- /dev/null +++ b/conf/indexer.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers +source _common.sh + +app=__APP__ +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + + +ynh_use_nodejs +cd $final_path/assets/frontend/bundle/ +../../../indexer > .index-xhr +cd $final_path/assets/cores +../../indexer > .index-xhr + diff --git a/conf/retroarch.cron b/conf/retroarch.cron new file mode 100644 index 0000000..93c6552 --- /dev/null +++ b/conf/retroarch.cron @@ -0,0 +1 @@ +*/5 * * * * root __FINAL_PATH__/indexer.sh > /dev/null 2>&1 \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index 47bd95f..1fc5425 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -18,3 +18,82 @@ pkg_dependencies="p7zip" #================================================= # FUTURE OFFICIAL HELPERS #================================================= + +# Install or update the main directory yunohost.multimedia +# +# usage: ynh_multimedia_build_main_dir +ynh_multimedia_build_main_dir () { + local ynh_media_release="v1.2" + local checksum="806a827ba1902d6911095602a9221181" + + # Download yunohost.multimedia scripts + wget -nv https://github.com/Yunohost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 2>&1 + + # Check the control sum + echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ + || ynh_die "Corrupt source" + + # Check if the package acl is installed. Or install it. + ynh_package_is_installed 'acl' \ + || ynh_package_install acl + + # Extract + mkdir yunohost.multimedia-master + tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1 + ./yunohost.multimedia-master/script/ynh_media_build.sh +} + +# Add a directory in yunohost.multimedia +# This "directory" will be a symbolic link to a existing directory. +# +# usage: ynh_multimedia_addfolder "Source directory" "Destination directory" +# +# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. +# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia" +ynh_multimedia_addfolder () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= ) + local source_dir + local dest_dir + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir" +} + +# Move a directory in yunohost.multimedia, and replace by a symbolic link +# +# usage: ynh_multimedia_movefolder "Source directory" "Destination directory" +# +# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. +# It will be moved to "Destination directory" +# A symbolic link will replace it. +# | arg: -d, --dest_dir= - Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia" +ynh_multimedia_movefolder () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= ) + local source_dir + local dest_dir + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir" +} + +# Allow an user to have an write authorisation in multimedia directories +# +# usage: ynh_multimedia_addaccess user_name +# +# | arg: -u, --user_name= - The name of the user which gain this access. +ynh_multimedia_addaccess () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [u]=user_name=) + local user_name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + groupadd -f multimedia + usermod -a -G multimedia $user_name +} + + diff --git a/scripts/install b/scripts/install index ed82fc0..5044e17 100755 --- a/scripts/install +++ b/scripts/install @@ -61,7 +61,6 @@ ynh_install_nodejs --nodejs_version=10 ynh_use_nodejs ynh_npm install -g coffeescript - ynh_install_app_dependencies $pkg_dependencies #================================================= @@ -80,13 +79,33 @@ rm $final_path/retroarch.7z rm -r $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 +#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 chmod +x $final_path/indexer +#================================================= +#SETTING MULTIMEDIA DIRECTORY +#================================================= +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="/share/Game" + +# 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" + #================================================= # NGINX CONFIGURATION #================================================= @@ -111,18 +130,6 @@ ynh_add_nginx_config # Set permissions to app files chown -R root: $final_path -#================================================= -# SETUP INDEX -#================================================= -#indexer use the current directory to run #https://github.com/libretro/RetroArch/tree/master/pkg/emscripten -#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 - #================================================= # SETUP SSOWAT #================================================= @@ -134,6 +141,19 @@ then ynh_permission_update --permission "main" --add visitors fi +#================================================= +# 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 + #================================================= # RELOAD NGINX #================================================= @@ -142,7 +162,6 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 4c1b3b0..08bbceb 100755 --- a/scripts/restore +++ b/scripts/restore @@ -67,14 +67,6 @@ ynh_script_progression --message="Restoring the app main directory..." --time -- ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # RESTORE USER RIGHTS #================================================= @@ -97,7 +89,18 @@ ynh_script_progression --message="Reinstalling dependencies..." --time --weight= #ynh_install_nodejs --nodejs_version=14 #ynh_use_nodejs #ynh_npm install -g coffeescript -npm install -g coffeescript +ynh_use_nodejs +ynh_npm install -g coffeescript + + +#================================================= +#SETTING MULTIMEDIA DIRECTORY +#================================================= +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" + #================================================= # RESTORE THE CRON FILE diff --git a/scripts/upgrade b/scripts/upgrade index 7d5a629..0935c48 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -108,13 +108,6 @@ ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app #================================================= # SPECIFIC UPGRADE @@ -122,6 +115,16 @@ ynh_system_user_create --username=$app # ... #================================================= + +#================================================= +#SETTING MULTIMEDIA DIRECTORY +#================================================= +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" + + #================================================= # STORE THE CONFIG FILE CHECKSUM #=================================================