From e32e33ed1d76bea6d493ec3ca9a24290aeeccc8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 23 May 2021 12:01:50 +0200 Subject: [PATCH] Testing (#23) * Fix Crystal install --- .../ISSUE_TEMPLATE.md | 33 +++-- .github/PULL_REQUEST_TEMPLATE.md | 16 +++ README.md | 66 +++++---- README_fr.md | 64 ++++----- check_process | 6 +- conf/config.yml | 1 - conf/crystal.src | 7 + conf/nginx.conf | 2 +- conf/systemd.service | 1 - doc/DISCLAIMER.md | 3 + doc/DISCLAIMER_fr.md | 3 + {sources => doc/screenshots}/screenshot.png | Bin manifest.json | 11 +- pull_request_template.md | 16 --- scripts/_common.sh | 15 +- scripts/change_url | 128 ++++++++++++++++++ scripts/install | 50 +++---- scripts/remove | 5 +- scripts/restore | 34 ++--- scripts/upgrade | 58 ++++---- 20 files changed, 318 insertions(+), 201 deletions(-) rename issue_template.md => .github/ISSUE_TEMPLATE.md (55%) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 conf/crystal.src create mode 100644 doc/DISCLAIMER.md create mode 100644 doc/DISCLAIMER_fr.md rename {sources => doc/screenshots}/screenshot.png (100%) delete mode 100644 pull_request_template.md create mode 100644 scripts/change_url diff --git a/issue_template.md b/.github/ISSUE_TEMPLATE.md similarity index 55% rename from issue_template.md rename to .github/ISSUE_TEMPLATE.md index 8d475a4..2729a6b 100644 --- a/issue_template.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,6 +1,6 @@ --- name: Bug report -about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all. +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. --- @@ -8,28 +8,30 @@ about: Create a report to help us debug, it would be nice to fill the template a 1. *Read this whole template first.* 2. *Determine if you are on the right place:* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* - - *Otherwise, the issue may be due to Invidious itself. Refer to its documentation or repository for help.* - - *If you have a doubt, post here, we will figure it out together.* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* 3. *Delete the italic comments as you write over them below, and remove this guide.* --- -**Describe the bug** +### Describe the bug + *A clear and concise description of what the bug is.* -**Versions** +### Context + - Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* - YunoHost version: x.x.x - I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* - Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* - If yes, please explain: - Using, or trying to install package version/branch: -- If upgrading, current package version: *can be found in the admin, or with `yunohost app info navidrome`* +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce -**To Reproduce** -*Steps to reproduce the behavior.* - *If you performed a command from the CLI, the command itself is enough. For example:* ```sh - sudo yunohost app install invidious + sudo yunohost app install the_app ``` - *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If the error occurs in your browser, explain what you did:* @@ -38,9 +40,16 @@ about: Create a report to help us debug, it would be nice to fill the template a 3. *Scroll down to '...'* 4. *See error* -**Expected behavior** +### Expected behavior + *A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* -**Logs** -*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.* +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + *If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/README.md b/README.md index 27fafd7..a7aed58 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,55 @@ + + +--- + + + # Invidious for YunoHost -[![Integration level](https://dash.yunohost.org/integration/invidious.svg)](https://dash.yunohost.org/appci/app/invidious) ![](https://ci-apps.yunohost.org/ci/badges/invidious.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/invidious.maintain.svg) -[![Install Invidious with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=invidious) +[![Integration level](https://dash.yunohost.org/integration/invidious.svg)](https://dash.yunohost.org/appci/app/invidious) ![](https://ci-apps.yunohost.org/ci/badges/invidious.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/invidious.maintain.svg) +[![Install invidious with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=invidious) *[Lire ce readme en français.](./README_fr.md)* -> *This package allows you to install Invidious quickly and simply on a YunoHost server. +> *This package allows you to install invidious 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.* ## Overview -Invidious is an alternative front-end for accessing YouTube videos without going through youtube.com. -**Shipped version:** 0.20.1 +Alternative front-end to YouTube + +**Shipped version:** 0.20.1~ynh9 + +**Demo:** https://invidious.site/ + ## Screenshots -![](sources/screenshot.png) -## Demo + ![](./doc/screenshots/screenshot.png) -* [Official demo](https://invidious.site/) + + + +## Disclaimers / important information ## Configuration -You can configure Invidious by modifying the configuration file `/var/www/invidious/config/config.yaml` with the help of this [documentation](https://github.com/iv-org/documentation/blob/master/Configuration.md). +You can configure Invidious by modifying the configuration file `/var/www/invidious/config/config.yml` with the help of this [documentation](https://github.com/iv-org/documentation/blob/master/Configuration.md). -## Documentation - * Official documentation: https://github.com/iv-org/documentation - * YunoHost documentation: https://yunohost.org/en/app_invidious -## YunoHost specific features +## Documentation and resources -#### Multi-user support -* Is LDAP supported? **No** -* Can the app be used by multiple users? **Yes** - -#### Supported architectures - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/invidious%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/invidious/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/invidious%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/invidious/) - -## Limitations - -Invidious require a dedicated root domain, ie. invidious.domain.tld -> :warning: To install Invidious you need at least 2GB of RAM available. - -## Links - - * Report a bug: https://github.com/YunoHost-Apps/invidious_ynh/issues - * Upstream app repository: https://github.com/iv-org/invidious - * YunoHost website: https://yunohost.org/ - ---- +* Official user documentation: https://github.com/iv-org/documentation +* Official admin documentation: https://yunohost.org/packaging_apps +* Upstream app code repository: https://github.com/iv-org/invidious +* YunoHost documentation for this app: https://yunohost.org/app_invidious +* Report a bug: https://github.com/YunoHost-Apps/invidious_ynh/issues ## Developer info @@ -65,3 +61,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/invidious_ynh/tree/te or sudo yunohost app upgrade invidious -u https://github.com/YunoHost-Apps/invidious_ynh/tree/testing --debug ``` + +**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/README_fr.md b/README_fr.md index cf20224..37f9f8f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,59 +1,47 @@ # Invidious pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/invidious.svg)](https://dash.yunohost.org/appci/app/invidious) ![](https://ci-apps.yunohost.org/ci/badges/invidious.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/invidious.maintain.svg) -[![Installer Invidious avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=invidious) +[![Niveau d'intégration](https://dash.yunohost.org/integration/invidious.svg)](https://dash.yunohost.org/appci/app/invidious) ![](https://ci-apps.yunohost.org/ci/badges/invidious.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/invidious.maintain.svg) +[![Installer invidious avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=invidious) -*[Read this readme in english.](./README.md)* +*[Read this readme in english.](./README.md)* +*[Lire ce readme en français.](./README_fr.md)* -> *Ce package vous permet d'installer Invidious rapidement et simplement sur un serveur YunoHost. -Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* +> *This package allows you to install invidious 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.* ## Vue d'ensemble -Invidious est une interface permettant d'accéder aux vidéos YouTube sans passer par youtube.com. -**Version incluse :** 0.20.1 +Front-end alternatif à YouTube + +**Version incluse:** 0.20.1~ynh9 + +**Démo:** https://invidious.site/ + ## Captures d'écran -![](sources/screenshot.png) -## Démo + ![](./doc/screenshots/screenshot.png) -* [Démo officielle](https://invidious.site/) + + + +## Avertissements / informations importantes ## Configuration Vous pouvez configurer Invidious en modifiant le fichier de configuration `/var/www/invidious/config/config.yaml` avec l'aide de cette [documentation](https://github.com/iv-org/documentation/blob/master/Configuration.md). -## Documentation - * Documentation officielle : https://github.com/iv-org/documentation - * Documentation YunoHost : https://yunohost.org/fr/app_invidious -## Caractéristiques spécifiques YunoHost +## Documentations et ressources -#### Support multi-utilisateur -* L'authentification LDAP est-elle prise en charge ? **Non** -* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** - -#### Architectures supportées - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/invidious%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/invidious/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/invidious%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/invidious/) - -## Limitations - -Invidious nécessite un domaine racine dédié, par exemple. invidious.domain.tld -> :warning: Pour installer Invidious, vous avez besoin d'au moins 2 Go de RAM disponible. - -## Liens - - * Signaler un bug : https://github.com/YunoHost-Apps/invidious_ynh/issues - * Dépôt de l'application principale : https://github.com/iv-org/invidious - * Site web YunoHost : https://yunohost.org/ - ---- +* Documentation officielle utilisateur: https://github.com/iv-org/documentation +* Documentation officielle de l'admin: https://yunohost.org/packaging_apps +* Dépôt de code officiel de l'app: https://github.com/iv-org/invidious +* Documentation YunoHost pour cette app: https://yunohost.org/app_invidious +* Signaler un bug: https://github.com/YunoHost-Apps/invidious_ynh/issues ## Informations pour les développeurs @@ -61,7 +49,9 @@ Merci de faire vos pull request sur la [branche testing](https://github.com/Yuno Pour essayer la branche testing, procédez comme suit. ``` -sudo yunohost app install https://github.com/YunoHost-Apps/navidrome_ynh/tree/testing --debug -ou +sudo yunohost app install https://github.com/YunoHost-Apps/invidious_ynh/tree/testing --debug +or sudo yunohost app upgrade invidious -u https://github.com/YunoHost-Apps/invidious_ynh/tree/testing --debug ``` + +**Plus d'infos sur le packaging d'applications:** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/check_process b/check_process index 47d4fda..564d32f 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,8 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/" (PATH) - is_public=1 (PUBLIC|public=1|private=0) + domain="domain.tld" + path="/" + is_public=1 language="fr" ; Checks pkg_linter=1 diff --git a/conf/config.yml b/conf/config.yml index ba89482..77c3ae5 100644 --- a/conf/config.yml +++ b/conf/config.yml @@ -20,4 +20,3 @@ default_user_preferences: local: true locale: "__LANGUAGE__" comments: ["youtube",""] - diff --git a/conf/crystal.src b/conf/crystal.src new file mode 100644 index 0000000..14ed0e2 --- /dev/null +++ b/conf/crystal.src @@ -0,0 +1,7 @@ +SOURCE_URL=https://github.com/crystal-lang/crystal/releases/download/0.36.1/crystal_0.36.1-1_amd64.deb +SOURCE_SUM=bac79d5513911fc6ad1cf9d05571132e36a139e7cf0808acee518c57ab1aa563 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=deb +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME=crystal_0.36.1-1_amd64.deb +SOURCE_EXTRACT=false diff --git a/conf/nginx.conf b/conf/nginx.conf index 0d65772..13cd907 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -27,7 +27,7 @@ location __PATH__/embed/ { rewrite ^ https://$server_name$request_uri? permanent; } - proxy_pass http://127.0.0.1:3000/embed/; + proxy_pass http://127.0.0.1:__PORT__/embed/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/conf/systemd.service b/conf/systemd.service index a54b01c..aeb78f0 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,4 +1,3 @@ - [Unit] Description=Invidious (An alternative YouTube front-end) After=syslog.target diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..8b1ef91 --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,3 @@ +## Configuration + +You can configure Invidious by modifying the configuration file `/var/www/invidious/config/config.yml` with the help of this [documentation](https://github.com/iv-org/documentation/blob/master/Configuration.md). diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..0a84926 --- /dev/null +++ b/doc/DISCLAIMER_fr.md @@ -0,0 +1,3 @@ +## Configuration + +Vous pouvez configurer Invidious en modifiant le fichier de configuration `/var/www/invidious/config/config.yaml` avec l'aide de cette [documentation](https://github.com/iv-org/documentation/blob/master/Configuration.md). diff --git a/sources/screenshot.png b/doc/screenshots/screenshot.png similarity index 100% rename from sources/screenshot.png rename to doc/screenshots/screenshot.png diff --git a/manifest.json b/manifest.json index dfb7c2c..a433a38 100644 --- a/manifest.json +++ b/manifest.json @@ -6,14 +6,21 @@ "en": "Alternative front-end to YouTube", "fr": "Front-end alternatif à YouTube" }, - "version": "0.20.1~ynh8", + "version": "0.20.1~ynh9", "url": "https://invidio.us/", + "upstream": { + "license": "GPL-3.0-only", + "demo": "https://invidious.site/", + "admindoc": "https://yunohost.org/packaging_apps", + "userdoc": "https://github.com/iv-org/documentation", + "code": "https://github.com/iv-org/invidious" + }, "license": "GPL-3.0-only", "maintainer": { "name": "eric_G" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.2.4" }, "multi_instance": false, "services": [ diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 6c28fc5..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,16 +0,0 @@ -## Problem -- *Description of why you made this PR* - -## Solution -- *And how do you fix that problem* - -## PR Status -- [ ] Code finished. -- [ ] Tested with Package_check. -- [ ] Fix or enhancement tested. -- [ ] Upgrade from last version tested. -- [ ] Can be reviewed and tested. - -## Package_check results ---- -* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/_common.sh b/scripts/_common.sh index 4aeb6e7..04a4ba1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="apt-transport-https libssl-dev libxml2-dev libyaml-dev libgmp-dev libreadline-dev postgresql librsvg2-bin libsqlite3-dev zlib1g-dev" #crystal +pkg_dependencies="apt-transport-https libssl-dev libxml2-dev libyaml-dev libgmp-dev libreadline-dev postgresql librsvg2-bin libsqlite3-dev zlib1g-dev libevent-dev pkg-config libpcre3-dev" #================================================= # PERSONAL HELPERS @@ -18,16 +18,3 @@ pkg_dependencies="apt-transport-https libssl-dev libxml2-dev libyaml-dev libgmp- #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -# Execute a command as another user -# usage: ynh_exec_as USER COMMAND [ARG ...] -ynh_exec_as() { - local USER=$1 - shift 1 - - if [[ $USER = $(whoami) ]]; then - eval "$@" - else - sudo -u "$USER" "$@" - fi -} \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..cf19a29 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,128 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +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="/" + +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) +# Add settings here as needed by your application +#db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#db_user=$db_name +#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + +#================================================= +# 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 +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 + +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 + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=3 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index c3ee073..eead517 100644 --- a/scripts/install +++ b/scripts/install @@ -46,8 +46,8 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= ynh_script_progression --message="Storing installation settings..." --weight=2 -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=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=language --value=$language #================================================= @@ -64,15 +64,22 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=9 - -#ynh_exec_warn_less apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 -#ynh_install_extra_repo --repo="deb https://dl.bintray.com/crystal/deb all stable" --append - -ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --crystal=0.36 +ynh_script_progression --message="Installing dependencies..." --weight=15 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +tempdir="$(mktemp -d)" +ynh_setup_source --dest_dir=$tempdir --source_id=crystal +ynh_exec_warn_less dpkg -i $tempdir/crystal_0.36.1-1_amd64.deb + +#================================================= +# 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" + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -84,14 +91,6 @@ ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_name --db_name=$db_name -#================================================= -# 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 - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -107,6 +106,10 @@ for i in $final_path/config/sql/*.sql ; do ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < "$i" ; done +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -120,7 +123,7 @@ ynh_add_nginx_config #================================================= # INSTALL INVIDIOUS #================================================= -ynh_script_progression --message="Building Invidious.. (this will take some time and resources!)" --weight=10 +ynh_script_progression --message="Building Invidious.. (this will take some time and resources!)" --weight=60 pushd "$final_path" || ynh_die shards update && shards install @@ -133,6 +136,7 @@ popd || ynh_die ynh_script_progression --message="Modifying a config file..." ynh_add_config --template="../conf/config.yml" --destination="$final_path/config/config.yml" +chmod 600 $final_path/config/config.yml #================================================= # SETUP SYSTEMD @@ -147,6 +151,7 @@ ynh_add_systemd_config ynh_script_progression --message="Setuping a cron..." --weight=1 ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app" +chmod 644 /etc/cron.d/$app #================================================= # SETUP LOGROTATE @@ -156,17 +161,6 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." --weight=1 - -# Set permissions to app files -chown -R $app: $final_path -chmod 0644 /etc/logrotate.d/$app - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/remove b/scripts/remove index 09d89e1..8566bf5 100644 --- a/scripts/remove +++ b/scripts/remove @@ -59,10 +59,7 @@ ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies ynh_remove_app_dependencies -ynh_remove_extra_repo - -dpkg --configure -a -apt-key del "379CE192D401AB61" +dpkg --remove crystal #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/restore b/scripts/restore index 73f870d..2d28806 100644 --- a/scripts/restore +++ b/scripts/restore @@ -52,6 +52,14 @@ ynh_script_progression --message="Restoring the NGINX configuration..." 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 #================================================= @@ -59,21 +67,9 @@ ynh_script_progression --message="Restoring Invidious main directory..." --weigh ynh_restore_file --origin_path="$final_path" -#================================================= -# 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 - -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." - -# Restore permissions on app files -chown -R $app: $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SPECIFIC RESTORATION @@ -82,12 +78,13 @@ chown -R $app: $final_path #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=7 -ynh_exec_warn_less apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 -ynh_install_extra_repo --repo="deb https://dl.bintray.com/crystal/deb all stable" --append - # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +tempdir="$(mktemp -d)" +ynh_setup_source --dest_dir=$tempdir --source_id=crystal +ynh_exec_warn_less dpkg -i $tempdir/crystal_0.36.1-1_amd64.deb + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= @@ -130,7 +127,6 @@ ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= ynh_restore_file --origin_path="/etc/logrotate.d/$app" -chmod 0644 /etc/logrotate.d/$app #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 1e734d1..160e85b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -44,6 +44,14 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -72,13 +80,12 @@ ynh_systemd_action --service_name=$app --action=stop --log_path=systemd #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=8 -#ynh_exec_warn_less apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 -#ynh_install_extra_repo --repo="deb https://dl.bintray.com/crystal/deb all stable" --append - -ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --crystal=0.36 - ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +tempdir="$(mktemp -d)" +ynh_setup_source --dest_dir=$tempdir --source_id=crystal +ynh_exec_warn_less dpkg -i $tempdir/crystal_0.36.1-1_amd64.deb + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -87,15 +94,32 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=5 + tmpdir="$(mktemp -d)" + + # Backup the config file in the temp dir + cp -a "$final_path/config/config.yml" "$tmpdir/config.yml" + # Remove the app directory securely ynh_secure_remove --file=$final_path + git clone https://github.com/iv-org/invidious "$final_path" --quiet pushd "$final_path" || ynh_die shards update && shards install crystal build $final_path/src/invidious.cr --release popd || ynh_die + + # Copy the admin saved settings from tmp directory to final path + cp -a "$tmpdir/config.yml" "$final_path/config/config.yml" + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod 600 $final_path/config/config.yml + #================================================= # NGINX CONFIGURATION #================================================= @@ -104,21 +128,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_script_progression --message="Modifying a config file..." --weight=3 - -ynh_add_config --template="../conf/config.yml" --destination="$final_path/config/config.yml" - #================================================= # SETUP SYSTEMD #================================================= @@ -137,15 +146,6 @@ ynh_script_progression --message="Upgrading logrotate configuration..." --weight # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." --weight=1 - -# Set permissions on app files -chown -R $app: $final_path -chmod 0644 /etc/logrotate.d/$app - #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================