diff --git a/ALL_README.md b/ALL_README.md index 3d6c579..77b7509 100644 --- a/ALL_README.md +++ b/ALL_README.md @@ -1,6 +1,6 @@ # All available README files by language - [Read the README in English](README.md) +- [Irakurri README euskaraz](README_eu.md) - [Lire le README en français](README_fr.md) - [Le o README en galego](README_gl.md) -- [Leggi il “README” in italiano](README_it.md) diff --git a/README.md b/README.md index f7ce0f4..7f5a9f0 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ It shall NOT be edited by hand. [![Install Sonarr with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=sonarr) -*[Read this README is other languages.](./ALL_README.md)* +*[Read this README in other languages.](./ALL_README.md)* > *This package allows you to install Sonarr quickly and simply on a YunoHost server.* > *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.* @@ -19,21 +19,12 @@ It shall NOT be edited by hand. Sonarr is a PVR for Usenet and BitTorrent users. It can monitor multiple RSS feeds for new episodes of your favorite shows and will grab, sort and rename them. It can also be configured to automatically upgrade the quality of files already downloaded when a better quality format becomes available. -**Shipped version:** 3.0.6.1196~ynh3 +**Shipped version:** 4.0.1.929~ynh1 ## Screenshots ![Screenshot of Sonarr](./doc/screenshots/screenshot.jpg) -## Disclaimers / important information - -* Sonarr developper's repository only allows to download the very latest version. - * The version displayed here may be different from the one actually installed. -* Supported architectures are `arm`, `armhf`, `arm64`, and `amd64` -* Access control is done with YunoHost's permissions system. - * API (`domain.tld/path/api`) can be accessed by visitors to allow control by remote clients. -* The app uses YunoHost's multimedia directories, hence it has write access to users' and shared directories in `/home/yunohost.multimedia`. After installation, you can choose these directories to store your media. - ## Documentation and resources - Official app website: diff --git a/README_eu.md b/README_eu.md new file mode 100644 index 0000000..251c518 --- /dev/null +++ b/README_eu.md @@ -0,0 +1,48 @@ + + +# Sonarr YunoHost-erako + +[![Integrazio maila](https://dash.yunohost.org/integration/sonarr.svg)](https://dash.yunohost.org/appci/app/sonarr) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/sonarr.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/sonarr.maintain.svg) + +[![Instalatu Sonarr YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=sonarr) + +*[Irakurri README hau beste hizkuntzatan.](./ALL_README.md)* + +> *Pakete honek Sonarr YunoHost zerbitzari batean azkar eta zailtasunik gabe instalatzea ahalbidetzen dizu.* +> *YunoHost ez baduzu, kontsultatu [gida](https://yunohost.org/install) nola instalatu ikasteko.* + +## Aurreikuspena + +Sonarr is a PVR for Usenet and BitTorrent users. It can monitor multiple RSS feeds for new episodes of your favorite shows and will grab, sort and rename them. It can also be configured to automatically upgrade the quality of files already downloaded when a better quality format becomes available. + + +**Paketatutako bertsioa:** 4.0.1.929~ynh1 + +## Pantaila-argazkiak + +![Sonarr(r)en pantaila-argazkia](./doc/screenshots/screenshot.jpg) + +## Dokumentazioa eta baliabideak + +- Aplikazioaren webgune ofiziala: +- Administratzaileen dokumentazio ofiziala: +- Jatorrizko aplikazioaren kode-gordailua: +- YunoHost Denda: +- Eman errore baten berri: + +## Garatzaileentzako informazioa + +Bidali `pull request`a [`testing` abarrera](https://github.com/YunoHost-Apps/sonarr_ynh/tree/testing). + +`testing` abarra probatzeko, ondorengoa egin: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/sonarr_ynh/tree/testing --debug +edo +sudo yunohost app upgrade sonarr -u https://github.com/YunoHost-Apps/sonarr_ynh/tree/testing --debug +``` + +**Informazio gehiago aplikazioaren paketatzeari buruz:** diff --git a/README_fr.md b/README_fr.md index 7f4c7c5..ab4b742 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,21 +19,12 @@ Il NE doit PAS être modifié à la main. Sonarr est un PVR pour les utilisateurs Usenet et BitTorrent. Il peut surveiller plusieurs flux RSS pour les nouveaux épisodes de vos émissions préférées et les récupérer, les trier et les renommer. Il peut également être configuré pour mettre à niveau automatiquement la qualité des fichiers déjà téléchargés lorsqu'un format de meilleure qualité devient disponible. -**Version incluse :** 3.0.6.1196~ynh3 +**Version incluse :** 4.0.1.929~ynh1 ## Captures d’écran ![Capture d’écran de Sonarr](./doc/screenshots/screenshot.jpg) -## Avertissements / informations importantes - -* Le dépôt des développeurs de Sonarr ne permet de télécharger que la toute dernière version. - * La version annoncée ici peut être différente de celle réellement installée. -* Les architectures compatibles sont `arm`, `armhf`, `arm64`, et `amd64` -* Le contrôle de l'accès se fait avec le système de permissions de YunoHost. - * L'API (`domain.tld/path/api`) est accessible aux visiteurs pour permettre le contrôle via des clients externes. -* L'application utilise les dossiers multimédia de YunoHost, elle a donc accès en écriture aux dossiers utilisateurs et communs de `/home/yunohost.multimedia`. Après installation, vous pourrez choisir ces dossiers pour y stocker vos médias. - ## Documentations et ressources - Site officiel de l’app : diff --git a/README_gl.md b/README_gl.md index 31a4081..2e3b307 100644 --- a/README_gl.md +++ b/README_gl.md @@ -19,21 +19,12 @@ NON debe editarse manualmente. Sonarr is a PVR for Usenet and BitTorrent users. It can monitor multiple RSS feeds for new episodes of your favorite shows and will grab, sort and rename them. It can also be configured to automatically upgrade the quality of files already downloaded when a better quality format becomes available. -**Versión proporcionada:** 3.0.6.1196~ynh3 +**Versión proporcionada:** 4.0.1.929~ynh1 ## Capturas de pantalla ![Captura de pantalla de Sonarr](./doc/screenshots/screenshot.jpg) -## Avisos / información importante - -* Sonarr developper's repository only allows to download the very latest version. - * The version displayed here may be different from the one actually installed. -* Supported architectures are `arm`, `armhf`, `arm64`, and `amd64` -* Access control is done with YunoHost's permissions system. - * API (`domain.tld/path/api`) can be accessed by visitors to allow control by remote clients. -* The app uses YunoHost's multimedia directories, hence it has write access to users' and shared directories in `/home/yunohost.multimedia`. After installation, you can choose these directories to store your media. - ## Documentación e recursos - Web oficial da app: diff --git a/README_it.md b/README_it.md index 31e5f6e..50ea087 100644 --- a/README_it.md +++ b/README_it.md @@ -19,21 +19,12 @@ NON DEVE essere modificato manualmente. Sonarr is a PVR for Usenet and BitTorrent users. It can monitor multiple RSS feeds for new episodes of your favorite shows and will grab, sort and rename them. It can also be configured to automatically upgrade the quality of files already downloaded when a better quality format becomes available. -**Versione pubblicata:** 3.0.6.1196~ynh3 +**Versione pubblicata:** 4.0.1.929~ynh1 ## Screenshot ![Screenshot di Sonarr](./doc/screenshots/screenshot.jpg) -## Attenzione/informazioni importanti - -* Sonarr developper's repository only allows to download the very latest version. - * The version displayed here may be different from the one actually installed. -* Supported architectures are `arm`, `armhf`, `arm64`, and `amd64` -* Access control is done with YunoHost's permissions system. - * API (`domain.tld/path/api`) can be accessed by visitors to allow control by remote clients. -* The app uses YunoHost's multimedia directories, hence it has write access to users' and shared directories in `/home/yunohost.multimedia`. After installation, you can choose these directories to store your media. - ## Documentazione e risorse - Sito web ufficiale dell’app: diff --git a/check_process b/check_process deleted file mode 100644 index d41ffe8..0000000 --- a/check_process +++ /dev/null @@ -1,30 +0,0 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - admin="john" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - #upgrade=1 from_commit=CommitHash - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER& diff --git a/conf/config.xml b/conf/config.xml index 1dc6255..a717392 100644 --- a/conf/config.xml +++ b/conf/config.xml @@ -6,7 +6,13 @@ __PATH__ 127.0.0.1 __API_KEY__ - None + External BuiltIn main + False + False + Sonarr + DisabledForLocalAddresses + + diff --git a/conf/nginx.conf b/conf/nginx.conf index b374ab5..4195917 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -9,6 +9,7 @@ location __PATH__ { proxy_no_cache $cookie_session; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; + # Allow the Radarr API location __PATH__/api { auth_request off; diff --git a/conf/systemd.service b/conf/systemd.service index afb4b3f..39c9c46 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,7 +8,7 @@ Group=__APP__ UMask=0002 Type=simple -ExecStart=/usr/bin/mono --debug /usr/lib/sonarr/bin/Sonarr.exe -nobrowser -data=/var/lib/__APP__ +ExecStart=__INSTALL_DIR__/Sonarr -nobrowser -data=__DATA_DIR__ TimeoutStopSec=20 KillMode=process Restart=on-failure @@ -34,7 +34,8 @@ ProtectKernelModules=yes ProtectKernelTunables=yes LockPersonality=yes SystemCallArchitectures=native -SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation @privileged +# Removing @privileged to allow self-update +SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation # Denying access to capabilities that should not be relevant for webapps # Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..9e8f155 --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,4 @@ +* Sonarr has an internal self-upgrade system that has proven to be reliable with YunoHost's package. You may use it, though remember that there will be a discrepancy between Sonarr's actual version and the one known by YunoHost. +* Access control is done with YunoHost's permissions system. + * API (`__DOMAIN__/__PATH__/api`) can be accessed by visitors to allow control by remote clients. +* The app uses YunoHost's multimedia directories, hence it has write access to users' and shared directories in `/home/yunohost.multimedia`. After installation, you can choose these directories to store your media. diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md new file mode 100644 index 0000000..fec126c --- /dev/null +++ b/doc/ADMIN_fr.md @@ -0,0 +1,4 @@ +* Sonarr a un système de mise à jour interne qui s'est montré compatible avec le package YunoHost. Vous pouvez l'utiliser, mais rappelez-vous que la version de Sonarr sera différente de celle connue de YunoHost. +* Le contrôle de l'accès se fait avec le système de permissions de YunoHost. + * L'API (`__DOMAIN__/__PATH__/api`) est accessible aux visiteurs pour permettre le contrôle via des clients externes. +* L'application utilise les dossiers multimédia de YunoHost, elle a donc accès en écriture aux dossiers utilisateurs et communs de `/home/yunohost.multimedia`. Après installation, vous pourrez choisir ces dossiers pour y stocker vos médias. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 3b68602..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,6 +0,0 @@ -* Sonarr developper's repository only allows to download the very latest version. - * The version displayed here may be different from the one actually installed. -* Supported architectures are `arm`, `armhf`, `arm64`, and `amd64` -* Access control is done with YunoHost's permissions system. - * API (`domain.tld/path/api`) can be accessed by visitors to allow control by remote clients. -* The app uses YunoHost's multimedia directories, hence it has write access to users' and shared directories in `/home/yunohost.multimedia`. After installation, you can choose these directories to store your media. diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md deleted file mode 100644 index 64a0d4f..0000000 --- a/doc/DISCLAIMER_fr.md +++ /dev/null @@ -1,6 +0,0 @@ -* Le dépôt des développeurs de Sonarr ne permet de télécharger que la toute dernière version. - * La version annoncée ici peut être différente de celle réellement installée. -* Les architectures compatibles sont `arm`, `armhf`, `arm64`, et `amd64` -* Le contrôle de l'accès se fait avec le système de permissions de YunoHost. - * L'API (`domain.tld/path/api`) est accessible aux visiteurs pour permettre le contrôle via des clients externes. -* L'application utilise les dossiers multimédia de YunoHost, elle a donc accès en écriture aux dossiers utilisateurs et communs de `/home/yunohost.multimedia`. Après installation, vous pourrez choisir ces dossiers pour y stocker vos médias. diff --git a/doc/POST_UPGRADE.d/4.0.1.929~ynh1.md b/doc/POST_UPGRADE.d/4.0.1.929~ynh1.md new file mode 100644 index 0000000..6f244af --- /dev/null +++ b/doc/POST_UPGRADE.d/4.0.1.929~ynh1.md @@ -0,0 +1,5 @@ +The app's `__DATA_DIR__/config.xml` will now be overidden upon every upgrade. This is to make sure the internal authentication system is disabled, since you can benefit from YunoHost's permission system. + +In most use cases it should be fine. If you do need to alter the file, refer to the hooks system. + +If you altered the file, a backup has been made in `__DATA_DIR__`. diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 5701027..0000000 --- a/manifest.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "Sonarr", - "id": "sonarr", - "packaging_format": 1, - "description": { - "en": "A series collection manager for Usenet and BitTorrent users", - "fr": "Gestionnaire de collection de séries pour utilisateurs de Usenet et BitTorrent" - }, - "version": "3.0.6.1196~ynh3", - "url": "https://sonarr.tv", - "upstream": { - "license": "GPL-3.0-only", - "website": "https://sonarr.tv", - "admindoc": "https://wiki.servarr.com/Sonarr", - "code": "https://github.com/Sonarr/Sonarr" - }, - "license": "GPL-3.0-only", - "maintainer": { - "name": "tituspijean", - "email": "tituspijean@outlook.com" - }, - "requirements": { - "yunohost": ">= 11.2" - }, - "multi_instance": true, - "services": [ - "nginx", - "mysql" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/sonarr", - "default": "/sonarr" - }, - { - "name": "admin", - "type": "user" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..a222bd4 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,77 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "sonarr" +name = "Sonarr" +description.en = "Series collection manager for Usenet and BitTorrent users" +description.fr = "Gestionnaire de collection de séries pour utilisateurs de Usenet et BitTorrent" + +version = "4.0.1.929~ynh1" + +maintainers = ["tituspijean"] + +[upstream] +license = "GPL-3.0-only" +website = "https://sonarr.tv" +admindoc = "https://wiki.servarr.com/Sonarr" +code = "https://github.com/Sonarr/Sonarr" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = true + +ldap = false + +sso = false + +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/sonarr" + +[resources] + [resources.sources.main] + amd64.url = "https://github.com/Sonarr/Sonarr/releases/download/v4.0.1.929/Sonarr.main.4.0.1.929.linux-x64.tar.gz" + amd64.sha256 = "f58361ca1c679e7d827ac5cb247e42b3bc81f70db76140193eb93dbc41ef7af9" + arm64.url = "https://github.com/Sonarr/Sonarr/releases/download/v4.0.1.929/Sonarr.main.4.0.1.929.linux-arm64.tar.gz" + arm64.sha256 = "4410b27e8ce60695ab9ac7cc71d6f506a7015e3eb808c0eb8293194f38fce594" + armhf.url = "https://github.com/Sonarr/Sonarr/releases/download/v4.0.1.929/Sonarr.main.4.0.1.929.linux-arm.tar.gz" + armhf.sha256 = "8cea527a1d3414c9ee0ddcde76b3fd009c4d087b3a82d701f32e50797019cb93" + + autoupdate.strategy = "latest_github_release" + autoupdate.asset.amd64 = ".*\\.linux-x64.tar.gz" + autoupdate.asset.arm64 = ".*\\.linux-arm64.tar.gz" + autoupdate.asset.armhf = ".*\\.linux-arm.tar.gz" + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + dir = "/var/lib/__APP__" + + [resources.ports] + + [resources.permissions] + main.url = "/" + main.allowed = "admins" + api.url = "/api" + api.allowed = "visitors" + api.show_tile = false + api.protected = true + + [resources.apt] + packages = [ + "sqlite3", + "dirmngr", + "mediainfo", + ] diff --git a/scripts/_common.sh b/scripts/_common.sh index d9b08ae..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="apt-transport-https dirmngr gnupg ca-certificates mediainfo mono-devel sonarr" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index bfc28b4..289c38f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,27 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -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 #================================================= @@ -40,27 +19,29 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$data_dir" + +#================================================= +# SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= +ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= -# BACKUP SYSTEMD +# BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/var/log/$app/" #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index f2e412b..0b00c85 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,61 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -port=$(ynh_app_setting_get --app=$app --key=port) -api_key=$(ynh_app_setting_get --app=$app --key=api_key) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # 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 WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -78,29 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi +ynh_change_url_nginx_config #================================================= # SPECIFIC MODIFICATIONS @@ -108,11 +31,12 @@ fi # UPDATE CONFIGURATION FILE #================================================= -path=$new_path +# Add newline at end of file if required +sed -i -e '$a\' "$data_dir/config.xml" -ynh_exec_warn_less ynh_add_config --template="../conf/config.xml" --destination="$final_path/config.xml" +ynh_add_config --template="config.xml" --destination="$data_dir/config.xml" -chown $app:$app "$final_path/config.xml" +chown "$app:$app" "$data_dir/config.xml" #================================================= # GENERIC FINALISATION @@ -121,14 +45,8 @@ chown $app:$app "$final_path/config.xml" #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Starting Web Server" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +# Start a systemd service +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Application started." #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 8939659..1c52387 100755 --- a/scripts/install +++ b/scripts/install @@ -10,110 +10,38 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# INITIALIZE AND STORE SETTINGS #================================================= -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +# Generate API key for configuration later +api_key=$(ynh_string_random --length=32) +ynh_app_setting_set --app=$app --key="api_key" --value="$api_key" #================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST +# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) #================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_ADMIN - -app=$YNH_APP_INSTANCE_NAME - +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +ynh_script_progression --message="Setting up source files..." --weight=1 -final_path=/var/lib/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# Download, check integrity, uncompress and patch the source from manifest.toml +ynh_setup_source --dest_dir="$install_dir" -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -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=admin --value=$admin - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -port=$(ynh_find_port --port=8095) -ynh_app_setting_set --app=$app --key=port --value=$port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=4 - -ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://download.mono-project.com/repo/debian stable-buster main" --package="mono-devel" --key="https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" - -ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://apt.sonarr.tv/debian buster main" --package="sonarr" --key="https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2009837CBFFD68F45BC180471F4F90DE2A9B4BF8" - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 - -# Create a dedicated NGINX config -ynh_add_nginx_config - -#================================================= -# SPECIFIC SETUP -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -# Stop the service automatically created upon installation of the package -ynh_systemd_action --service_name=sonarr --action="stop" - -# Create a dedicated systemd config, it will override the one in /lib/systemd/system/sonarr.service -ynh_add_systemd_config +chown -R "$app:$app" "$install_dir" #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Configuring Radarr..." --weight=2 -api_key=$(ynh_string_random --length=32) -ynh_app_setting_set --app=$app --key=api_key --value=$api_key +mkdir -p "/var/log/$app" +ln -s "/var/log/$app" "$data_dir/logs" -# Create $final_path and its logs subdirectory -mkdir -p "$final_path/logs" -chmod 750 "$final_path" +ynh_add_config --template="config.xml" --destination="$data_dir/config.xml" -ynh_add_config --template="../conf/config.xml" --destination="$final_path/config.xml" - -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R "$app:$app" "$data_dir" #================================================= # YUNOHOST MULTIMEDIA INTEGRATION @@ -123,24 +51,22 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=2 # Build YunoHost multimedia directories ynh_multimedia_build_main_dir # Enable writing into these directories -ynh_multimedia_addaccess $app +ynh_multimedia_addaccess "$app" #================================================= -# GENERIC FINALIZATIONs +# NGINX CONFIGURATION #================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." + +# Create a dedicated NGINX config +ynh_add_nginx_config + +# Create a dedicated systemd config, it will override the one in /lib/systemd/system/sonarr.service +ynh_add_systemd_config +yunohost service add "$app" --description="Sonarr daemon" --log="/var/log/$app/sonarr.txt" # Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile="$final_path/logs/" - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Sonarr daemon" --log="$final_path/logs/sonarr.txt" +ynh_use_logrotate --logfile="/var/log/$app/" #================================================= # START SYSTEMD SERVICE @@ -148,30 +74,7 @@ yunohost service add $app --description="Sonarr daemon" --log="$final_path/logs/ ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30 - -# If a first Sonarr app was running before installing this one, -# it may have been stopped by the installation of the dependencies. -# Let's restart it. -if [[ $(systemctl list-units -all | grep 'sonarr.service' | grep 'inactive') ]]; then - ynh_exec_fully_quiet ynh_systemd_action --service_name=sonarr --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30 -fi - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -ynh_permission_update --permission="main" --add="$admin" --remove="all_users" - -ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Application started." --timeout=30 #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 93ff07a..8999ab4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,78 +10,25 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +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 -then - ynh_script_progression --message="Removing $app service integration..." --weight=1 - yunohost service remove $app +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=3 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app +ynh_secure_remove --file="/var/log/$app" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index d67f847..cc68b8e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,69 +10,23 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=2 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +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 + +chown -R "$app:$app" "$data_dir" #================================================= # YUNOHOST MULTIMEDIA INTEGRATION @@ -82,64 +36,35 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=2 # Build YunoHost multimedia directories ynh_multimedia_build_main_dir # Enable writing into these directories -ynh_multimedia_addaccess $app +ynh_multimedia_addaccess "$app" #================================================= -# SPECIFIC RESTORATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=4 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 -# Define and install dependencies -ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://download.mono-project.com/repo/debian stable-buster main" --package="mono-devel" --key="https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" - -ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://apt.sonarr.tv/debian buster main" --package="sonarr" --key="https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2009837CBFFD68F45BC180471F4F90DE2A9B4BF8" - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Sonarr daemon" --log="$final_path/logs/sonarr.txt" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=2 - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30 - -# If a first Sonarr app was running before installing this one, -# it may have been stopped by the installation of the dependencies. -# Let's restart it. -if [[ $(systemctl list-units -all | grep 'sonarr.service' | grep 'inactive') ]]; then - ynh_exec_fully_quiet ynh_systemd_action --service_name=sonarr --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30 -fi - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 +systemctl enable "$app.service" --quiet +yunohost service add "$app" --description="Sonarr daemon" --log="/var/log/$app/sonarr.txt" ynh_restore_file --origin_path="/etc/logrotate.d/$app" +#================================================= +# RESTORE VARIOUS FILES +#================================================= + +ynh_restore_file --origin_path="/var/log/$app/" + #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Application started." --timeout=30 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 4c3ed1c..7ae6a1c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,46 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) -port=$(ynh_app_setting_get --app=$app --key=port) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -api_key=$(ynh_app_setting_get --app=$app --key=api_key) - -#================================================= -# CHECK VERSION -#================================================= - -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### 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) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -56,92 +16,65 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Create a permission if needed -if ! ynh_permission_exists --permission="api"; then - ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" +if [ ! -L "$data_dir/logs" ]; then + ynh_secure_remove --file="$data_dir/logs" + ln -s "/var/log/$app" "$data_dir/logs" fi #================================================= -# CREATE DEDICATED USER +# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +# Download, check integrity, uncompress and patch the source from manifest.toml +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 + +chown -R "$app:$app" "$install_dir" #================================================= -# NGINX CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=4 - -ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://download.mono-project.com/repo/debian stable-buster main" --package="mono-devel" --key="https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" - -ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://apt.sonarr.tv/debian buster main" --package="sonarr" --key="https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2009837CBFFD68F45BC180471F4F90DE2A9B4BF8" - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# SPECIFIC UPGRADE -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 - # Create a dedicated systemd config ynh_add_systemd_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +yunohost service add "$app" --description="Sonarr daemon" --log="/var/log/$app/sonarr.txt" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append --logfile="$final_path/logs" +ynh_use_logrotate --non-append --logfile="/var/log/$app/" #================================================= -# INTEGRATE SERVICE IN YUNOHOST +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Configuring Radarr..." --weight=2 -yunohost service add $app --description="Sonarr daemon" --log="$final_path/logs/sonarr.txt" +# Add newline at end of file if required +sed -i -e '$a\' "$data_dir/config.xml" + +ynh_add_config --template="config.xml" --destination="$data_dir/config.xml" + +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R "$app:$app" "$data_dir" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30 - -# If a first Sonarr app was running before installing this one, -# it may have been stopped by the installation of the dependencies. -# Let's restart it. -if [[ $(systemctl list-units -all | grep 'sonarr.service' | grep 'inactive') ]]; then - ynh_exec_fully_quiet ynh_systemd_action --service_name=sonarr --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30 -fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Application started." --timeout=30 #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..eecb3cf --- /dev/null +++ b/tests.toml @@ -0,0 +1,15 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + args.admin="john" + + # ------------ + # Tests to run + # ------------