diff --git a/README.md b/README.md index 18bdea1..537e27e 100644 --- a/README.md +++ b/README.md @@ -37,19 +37,6 @@ The admin uses the login you provided at installation. The password is the same The admin interface is accessible at the address: `your.domain.fr/api/admin` -# State of this package - -* The following have been tested with this package and work fine: - - * [x] install/remove/backup/remove/upgrade with x86_64 and ARM - * [x] import file with web interface, imports from YouTube, interraction with MusicBrainz - * [x] [Subsonic API](https://docs.funkwhale.audio/users/apps.html) - * [x] [Federation](https://docs.funkwhale.audio/federation.html) tests - * [x] [CLI Import](https://docs.funkwhale.audio/importing-music.html#from-music-directory-on-the-server) Remember to `source $final_path/venv/bin/activate`, then `source $final_path/load_env` before typinh using manage.py. - -* to be added: - * [ ] Store files in HOME, see https://github.com/YunoHost-Apps/funkwhale_ynh/issues/15 - ## Documentation * Official documentation: https://docs.funkwhale.audio diff --git a/README_fr.md b/README_fr.md index 0cd2f70..3f7a8cc 100644 --- a/README_fr.md +++ b/README_fr.md @@ -31,19 +31,6 @@ L'administrateur utilise le login que vous avez fourni lors de l'installation. L L'interface d'administration est accessible à l'adresse : votre.domaine.fr/api/admin -# État de ce paquet - -* Les éléments suivants ont été testés avec ce paquet et fonctionnent : - - * [x] installer/supprimer/sauvegarder/supprimer/mettre à jour avec x86_64 - * [x] importation des fichiers avec l’interface web, importations depuis youtube, interraction avec MusicBrainz - * [x] [API Subsonic](https://docs.funkwhale.audio/users/apps.html) - * [x] Tests de [Fédération](https://docs.funkwhale.audio/federation.html) - * [x] [Import CLI](https://docs.funkwhale.audio/importing-music.html#from-music-directory-on-the-server) N'oubliez pas de `source $final_path/venv/bin/activate`, puis `source $final_path/load_env` avant de taper en utilisant manage.py. - -* à ajouter : - * [ ] Stocker les fichiers dans HOME, voir https://github.com/YunoHost-Apps/funkwhale_ynh/issues/15 - ## Documentation * Documentation officielle : https://docs.funkwhale.audio diff --git a/scripts/backup b/scripts/backup index d8b59c2..7f94b15 100644 --- a/scripts/backup +++ b/scripts/backup @@ -43,7 +43,7 @@ ynh_print_info --message="Declaring files to be backed up..." backup_core_only=$(ynh_app_setting_get --app="$app" --key=backup_core_only) # If backup_core_only have any value in the settings.yml file, do not backup the data directory -if [ "$backup_core_only" ] +if [ ! "$backup_core_only" ] then ynh_backup --src_path="$datadir" fi @@ -55,7 +55,6 @@ ynh_backup --src_path="$final_path" #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/nginx/conf.d/$domain.conf" #================================================= # BACKUP FAIL2BAN CONFIGURATION diff --git a/scripts/install b/scripts/install index 8bd2f96..af68acc 100644 --- a/scripts/install +++ b/scripts/install @@ -25,8 +25,8 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" -is_public=$YNH_APP_ARG_IS_PUBLIC admin=$YNH_APP_ARG_ADMIN +is_public=$YNH_APP_ARG_IS_PUBLIC admin_mail=$(ynh_user_get_info --username="$admin" --key="mail") @@ -114,7 +114,7 @@ popd ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_add_nginx_config "datadir" #================================================= # CREATE DEDICATED USER @@ -148,8 +148,8 @@ ynh_script_progression --message="Modifying a config file..." key=$(ynh_string_random --length=45 | base64) redis_db=$(ynh_redis_get_free_db) -ynh_app_setting_set --app="$app" --key=key --value="$key" -ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" +ynh_app_setting_set --app=$app --key=key --value=$key +ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db ynh_add_config --template="../conf/env.prod" --destination="$final_path/config/.env" @@ -190,11 +190,13 @@ ynh_add_systemd_config --service="$app-beat" --template="funkwhale-beat.servic ynh_script_progression --message="Securing files and directories..." # Set permissions to app files -chown -R "$app": $final_path +chown -R $app: $final_path chmod -R 755 "$final_path/front/dist/" +chown -R $app: $datadir + mkdir -p "/var/log/$app" -chown -R "$app": "/var/log/$app" +chown -R $app: "/var/log/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST @@ -220,7 +222,7 @@ ynh_systemd_action --service_name="${app}-worker" --action="start" --log_path="s #================================================= ynh_script_progression --message="Configuring Fail2Ban..." -# Create a dedicated fail2ban config +# Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=".* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5 #================================================= diff --git a/scripts/remove b/scripts/remove index 8ea1a3b..d059f68 100644 --- a/scripts/remove +++ b/scripts/remove @@ -30,21 +30,21 @@ redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #================================================= # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if yunohost service status "$app-server" >/dev/null +if ynh_exec_warn_less yunohost service status "$app-server" >/dev/null then - ynh_script_progression --message="Remove $app-server service integration..." + ynh_script_progression --message="Removing $app-server service integration..." yunohost service remove "$app-server" fi -if yunohost service status "$app-worker" >/dev/null +if ynh_exec_warn_less yunohost service status "$app-worker" >/dev/null then - ynh_script_progression --message="Remove $app-worker service integration..." + ynh_script_progression --message="Removing $app-worker service integration..." yunohost service remove "$app-worker" fi -if yunohost service status "$app-beat" >/dev/null +if ynh_exec_warn_less yunohost service status "$app-beat" >/dev/null then - ynh_script_progression --message="Remove $app-beat service integration..." + ynh_script_progression --message="Removing $app-beat service integration..." yunohost service remove "$app-beat" fi diff --git a/scripts/restore b/scripts/restore index 3d2cfc0..f7ca191 100644 --- a/scripts/restore +++ b/scripts/restore @@ -62,7 +62,7 @@ ynh_script_progression --message="Restoring the app main directory..." backup_core_only=$(ynh_app_setting_get --app=$app --key=backup_core_only) # If backup_core_only have any value, then restore only code -if [ "$backup_core_only" ] +if [ ! "$backup_core_only" ] then ynh_restore_file --origin_path="$datadir" fi @@ -70,8 +70,9 @@ fi ynh_restore_file --origin_path="$final_path" # Remove the option backup_core_only if it's in the settings.yml file -ynh_app_setting_delete --app="$app" --key=backup_core_only +ynh_app_setting_delete --app=$app --key=backup_core_only +mkdir -p $datadir pushd $datadir mkdir -p static media music popd @@ -91,10 +92,12 @@ ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R $app: $final_path -chmod -R 755 "$final_path/code/front/dist/" +chmod -R 755 "$final_path/front/dist/" + +chown -R $app: $datadir mkdir -p "/var/log/$app" -chown -R "$app": "/var/log/$app" +chown -R $app: "/var/log/$app" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 9451344..16f7ef1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,8 +21,8 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -port=$(ynh_app_setting_get --app=$app --key=port) db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +port=$(ynh_app_setting_get --app=$app --key=port) redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) key=$(ynh_app_setting_get --app=$app --key=key) @@ -33,8 +33,8 @@ ynh_script_progression --message="Ensuring downward compatibility..." # If redis_db doesn't exist, create it if [ -z "$redis_db" ]; then - redis_db=0 - ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" + redis_db=$(ynh_redis_get_free_db) + ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db fi # If db_pwd doesn't exist, create it @@ -50,20 +50,13 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Inform the backup/restore process that it should not save the data directory -ynh_app_setting_set --app="$app" --key=backup_core_only --value=1 +ynh_app_setting_set --app=$app --key=backup_core_only --value=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -130,7 +123,7 @@ fi ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_add_nginx_config "datadir" #================================================= # UPGRADE DEPENDENCIES @@ -203,7 +196,7 @@ pushd $final_path # https://docs.funkwhale.audio/changelog.html#increased-quality-of-jpeg-thumbnails-manual-action-required ynh_secure_remove --file="$final_path/media/__sized__" python api/manage.py fw media generate-thumbnails -) +popd #================================================= # SETUP SYSTEMD @@ -225,11 +218,13 @@ ynh_add_systemd_config --service="$app-beat" --template="funkwhale-beat.servic ynh_script_progression --message="Securing files and directories..." # Set permissions on app files -chown -R "$app": "$final_path" -chmod -R 755 "$final_path/code/front/dist/" +chown -R $app: "$final_path" +chmod -R 755 "$final_path/front/dist/" + +chown -R $app: $datadir mkdir -p "/var/log/$app" -chown -R "$app": "/var/log/$app" +chown -R $app: "/var/log/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST