From ae91cc2b2001aeb3ed5a38f9d2d90f7d8b18b838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 29 Oct 2023 19:35:47 +0100 Subject: [PATCH] cleaning --- conf/navidrome.toml | 4 ++-- conf/systemd.service | 6 +++--- doc/ADMIN.md | 2 +- doc/ADMIN_fr.md | 2 +- manifest.toml | 2 ++ scripts/backup | 13 +++++++------ scripts/install | 8 ++++---- scripts/remove | 8 +++----- scripts/restore | 12 +++++++++++- scripts/upgrade | 10 +++++----- 10 files changed, 39 insertions(+), 28 deletions(-) diff --git a/conf/navidrome.toml b/conf/navidrome.toml index 8891bcf..28a0085 100644 --- a/conf/navidrome.toml +++ b/conf/navidrome.toml @@ -1,5 +1,5 @@ # Load configurations from an external config file -ConfigFile = "/var/lib/__APP__/navidrome.toml" +ConfigFile = "__DATA_DIR__/navidrome.toml" # Log level. Useful for troubleshooting. Possible values: error, info, debug, trace LogLevel = "INFO" @@ -26,7 +26,7 @@ TranscodingCacheSize = "150MB" ImageCacheSize = "100MB" # Folder to store application data (DB, cache…) -DataFolder = "__CONFIG_PATH__" +DataFolder = "__DATA_DIR__" # Folder where your music library is stored. Can be read-only MusicFolder = "/home/yunohost.multimedia/share/Music" diff --git a/conf/systemd.service b/conf/systemd.service index d6004c8..9a97b21 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,12 +6,12 @@ After=remote-fs.target network.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/ -ExecStart=__INSTALL_DIR__/__APP__ --configfile "__INSTALL_DIR__/navidrome.toml" +WorkingDirectory=__DATA_DIR__/ +ExecStart=__INSTALL_DIR__/__APP__ --configfile "__DATA_DIR__/navidrome.toml" TimeoutStopSec=20 KillMode=process Restart=on-failure -ReadWritePaths=__INSTALL_DIR__/ +ReadWritePaths=__DATA_DIR__/ # Sandboxing options to harden security # Depending on specificities of your service/app, you may need to tweak these diff --git a/doc/ADMIN.md b/doc/ADMIN.md index ff1fcb8..a0247d9 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -2,4 +2,4 @@ Your music files are stored by default in your shared [multimedia folder](https://github.com/YunoHost-Apps/yunohost.multimedia) `/home/yunohost.multimedia/share/Music`. This folder is accessible from Nextcloud with *External Storages* enabled. This will allow you to easily upload your music files to the server. -You can configure an alternative path to you music files by editing the path `MusicFolder = "/home/yunohost.multimedia/share/Music"` in this file `/var/lib/navidrome/navidrome.toml` using the [documentation](https://www.navidrome.org/docs/usage/configuration-options/). Remember to restart Navidrome service if you change your configuration file. +You can configure an alternative path to you music files by editing the path `MusicFolder = "/home/yunohost.multimedia/share/Music"` in this file `__DATA_DIR__/navidrome.toml` using the [documentation](https://www.navidrome.org/docs/usage/configuration-options/). Remember to restart Navidrome service if you change your configuration file. diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index 68c9995..b46f4f9 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -2,4 +2,4 @@ Votre musique est a stockée par default dans le [dossier multimédia](https://github.com/YunoHost-Apps/yunohost.multimedia) partagé `/home/yunohost.multimedia/share/Music`. Ce dossier, facilement accessible depuis Nextcloud avec *Stockages externes* activée, vous permettra d'*uploader* facilement vos fichiers de musique sur votre server. -Vous pouvez personnaliser le dossier de stockage de vos fichiers de musique en éditant le fichier de configuration `/var/lib/navidrome/navidrome.toml` et rediriger la variable `MusicFolder = "/home/yunohost.multimedia/share/Music"`. Vous pouvez également changer d'autre réglage en vous aidant de la [documentation](https://www.navidrome.org/docs/usage/configuration-options/). Pensez à redémarrer le service de Navidrome si vous modifiez votre fichier de configuration. +Vous pouvez personnaliser le dossier de stockage de vos fichiers de musique en éditant le fichier de configuration `__DATA_DIR__/navidrome.toml` et rediriger la variable `MusicFolder = "/home/yunohost.multimedia/share/Music"`. Vous pouvez également changer d'autre réglage en vous aidant de la [documentation](https://www.navidrome.org/docs/usage/configuration-options/). Pensez à redémarrer le service de Navidrome si vous modifiez votre fichier de configuration. diff --git a/manifest.toml b/manifest.toml index 7e5e69d..616b83c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -64,6 +64,8 @@ ram.runtime = "50M" [resources.install_dir] + [resources.data_dir] + [resources.ports] [resources.permissions] diff --git a/scripts/backup b/scripts/backup index 39ebf6c..3240d7c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -21,6 +21,13 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$install_dir" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +# Only relevant if there is a "data_dir" resource for this app +ynh_backup --src_path="$data_dir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= @@ -35,12 +42,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# BACKUP VARIOUS FILES -#================================================= - -ynh_backup --src_path="/var/lib/$app" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index d28315d..a932746 100644 --- a/scripts/install +++ b/scripts/install @@ -54,7 +54,7 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -yunohost service add $app --description="Web-based music collection server and streamer" +yunohost service add $app --description="Web-based music collection server and streamer" --log="/var/log/$app/$app.log" #================================================= # SPECIFIC SETUP @@ -71,10 +71,10 @@ ynh_multimedia_build_main_dir ynh_script_progression --message="Adding a configuration file..." --weight=1 # Main config File -ynh_add_config --template="navidrome.toml" --destination="$install_dir/navidrome.toml" +ynh_add_config --template="navidrome.toml" --destination="$data_dir/navidrome.toml" -chmod 600 "$$install_dir/navidrome.toml" -chown -R $app:$app "$install_dir/navidrome.toml" +chmod 600 "$data_dir/navidrome.toml" +chown -R $app:$app "$data_dir/navidrome.toml" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index a104918..4c29204 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,10 +10,11 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# STANDARD REMOVE +# REMOVE SYSTEM CONFIGURATIONS #================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null @@ -28,9 +29,6 @@ ynh_remove_systemd_config # Remove the dedicated NGINX config ynh_remove_nginx_config -# Remove the config directory securely -ynh_secure_remove --file="/var/lib/$app" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index bf20493..651b589 100644 --- a/scripts/restore +++ b/scripts/restore @@ -20,6 +20,16 @@ ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." --weight=1 + +ynh_restore_file --origin_path="$data_dir" --not_mandatory + +# (Same as for install dir) +chown -R $app:www-data "$data_dir" + #================================================= # RESTORE SYSTEMD #================================================= @@ -30,7 +40,7 @@ systemctl enable $app.service --quiet ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -yunohost service add $app --description="Web-based music collection server and streamer" +yunohost service add $app --description="Web-based music collection server and streamer" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 87c07d2..c20ece4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -76,7 +76,7 @@ then ynh_secure_remove --file=$install_dir # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" --keep="nadidrome.toml" + ynh_setup_source --dest_dir="$install_dir" fi chmod -R o-rwx "$install_dir" @@ -93,7 +93,7 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -yunohost service add $app --description="Web-based music collection server and streamer" +yunohost service add $app --description="Web-based music collection server and streamer" --log="/var/log/$app/$app.log" #================================================= # UPDATE A CONFIG FILE @@ -101,10 +101,10 @@ yunohost service add $app --description="Web-based music collection server and s ynh_script_progression --message="Updating a configuration file..." # Uncomment when there is new options added upstream -ynh_add_config --template="navidrome.toml" --destination="$install_dir/navidrome.toml" +ynh_add_config --template="navidrome.toml" --destination="$data_dir/navidrome.toml" -chmod 600 "$install_dir/navidrome.toml" -chown -R $app:$app "$install_dir/navidrome.toml" +chmod 600 "$data_dir/navidrome.toml" +chown -R $app:$app "$data_dir/navidrome.toml" #================================================= # START SYSTEMD SERVICE