1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/invidious_ynh.git synced 2024-09-03 19:15:55 +02:00

Version 2 (#112)

* v2

* v2

* Auto-update README

* Update manifest.toml

Co-authored-by: Alexandre Aubin <alex.aubin@mailoo.org>

* Update install

* fix

* Update manifest.toml

* Fix

* Fix

* Auto-update README

* Update manifest.toml

* Update manifest.toml

* Update tests.toml

* Update upgrade

* Fix

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: Alexandre Aubin <alex.aubin@mailoo.org>
This commit is contained in:
Éric Gaspar 2023-03-11 22:28:46 +01:00 committed by GitHub
parent 8bfe64801f
commit 70956d4063
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 172 additions and 617 deletions

View file

@ -17,7 +17,10 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## Overview
Invidious is an interface allowing access to Youtube videos without going through youtube.com Invidious is an interface allowing access to Youtube videos without going through youtube.com
In addition to constituting an advantage in terms of confidentiality (the data does not pass directly through the services of the giant), this interface offers several features: In addition to constituting an advantage in terms of confidentiality (the data does not pass directly through the services of the giant).
### Features:
- Audio only mode, - Audio only mode,
- Dark mode, - Dark mode,
- Ability to display Reddit comments instead of YouTube comments, - Ability to display Reddit comments instead of YouTube comments,
@ -32,22 +35,13 @@ In addition to constituting an advantage in terms of confidentiality (the data d
![Screenshot of Invidious](./doc/screenshots/screenshot.png) ![Screenshot of Invidious](./doc/screenshots/screenshot.png)
## Disclaimers / important information
## Configuration
You can configure Invidious by modifying the configuration file `/var/www/invidious/config/config.yml` with the help of this [documentation](https://docs.invidious.io/Configuration.md).
## Limitations
* Invidious needs more than 2GB of RAM to build.
## :red_circle: Antifeatures ## :red_circle: Antifeatures
- **Non-free Network Services**: Promotes or depends entirely on a non-free network service. - **Non-free Network Services**: Promotes or depends entirely on a non-free network service.
## Documentation and resources ## Documentation and resources
* Official app website: <https://invidio.us/>
* Official user documentation: <https://github.com/iv-org/documentation> * Official user documentation: <https://github.com/iv-org/documentation>
* Official admin documentation: <https://docs.invidious.io/> * Official admin documentation: <https://docs.invidious.io/>
* Upstream app code repository: <https://github.com/iv-org/invidious> * Upstream app code repository: <https://github.com/iv-org/invidious>

View file

@ -17,7 +17,9 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
## Vue densemble ## Vue densemble
Invidious est une interface permettant d'accéder aux vidéos Youtube sans passer par youtube.com Invidious est une interface permettant d'accéder aux vidéos Youtube sans passer par youtube.com
En plus de constituer un avantage sur le plan de la confidentialité (les données ne transitent pas directement par les services du géant), cette interface offre plusieurs fonctionnalités : En plus de constituer un avantage sur le plan de la confidentialité (les données ne transitent pas directement par les services du géant).
### Fonctionnalités :
- Mode audio seul, - Mode audio seul,
- Mode sombre, - Mode sombre,
- Possibilité d'afficher les commentaires Reddit plutôt que les commentaires YouTube, - Possibilité d'afficher les commentaires Reddit plutôt que les commentaires YouTube,
@ -31,22 +33,13 @@ En plus de constituer un avantage sur le plan de la confidentialité (les donné
![Capture décran de Invidious](./doc/screenshots/screenshot.png) ![Capture décran de Invidious](./doc/screenshots/screenshot.png)
## 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://docs.invidious.io/Configuration.md).
## Limitations
* Invidious a besoin de plus de 3Go de RAM pour être installé.
## :red_circle: Fonctions indésirables ## :red_circle: Fonctions indésirables
- **Non-free Network Services**: Promotes or depends entirely on a non-free network service. - **Non-free Network Services**: Promotes or depends entirely on a non-free network service.
## Documentations et ressources ## Documentations et ressources
* Site officiel de lapp : <https://invidio.us/>
* Documentation officielle utilisateur : <https://github.com/iv-org/documentation> * Documentation officielle utilisateur : <https://github.com/iv-org/documentation>
* Documentation officielle de ladmin : <https://docs.invidious.io/> * Documentation officielle de ladmin : <https://docs.invidious.io/>
* Dépôt de code officiel de lapp : <https://github.com/iv-org/invidious> * Dépôt de code officiel de lapp : <https://github.com/iv-org/invidious>

View file

@ -1,25 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
path="/"
is_public=1
language="fr"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
#upgrade=1 from_commit=d0b65b69558b6a1a98761eb7be0b34b4ccb7d6b3
backup_restore=1
multi_instance=0
change_url=0
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=d0b65b69558b6a1a98761eb7be0b34b4ccb7d6b3
name=Testing (#36)
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Invidious: Alternative YouTube front-end Description=Invidious: alternative YouTube front-end
After=syslog.target After=syslog.target
After=network.target After=network.target
@ -7,8 +7,8 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__ WorkingDirectory=__INSTALL_DIR__
ExecStart=__FINALPATH__/invidious -o invidious.log ExecStart=__INSTALL_DIR__/invidious -o invidious.log
RestartSec=2s RestartSec=2s
Restart=always Restart=always

View file

@ -13,7 +13,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "Allow/Forbid Invidious (local) account creation" help = "Allow/Forbid Invidious (local) account creation"
bind = "registration_enabled:__FINALPATH__/config/config.yml" bind = "registration_enabled:__INSTALL_DIR__/config/config.yml"
[main.config.login_enabled] [main.config.login_enabled]
ask = "Enable login" ask = "Enable login"
@ -21,7 +21,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "Allow/Forbid users to log-in" help = "Allow/Forbid users to log-in"
bind = "login_enabled:__FINALPATH__/config/config.yml" bind = "login_enabled:__INSTALL_DIR__/config/config.yml"
[main.config.captcha_enabled] [main.config.captcha_enabled]
ask = "Enable captcha" ask = "Enable captcha"
@ -29,4 +29,4 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "Enable/Disable the captcha challenge on the login page" help = "Enable/Disable the captcha challenge on the login page"
bind = "captcha_enabled:__FINALPATH__/config/config.yml" bind = "captcha_enabled:__INSTALL_DIR__/config/config.yml"

View file

@ -1,7 +1 @@
## Configuration
You can configure Invidious by modifying the configuration file `/var/www/invidious/config/config.yml` with the help of this [documentation](https://docs.invidious.io/Configuration.md). You can configure Invidious by modifying the configuration file `/var/www/invidious/config/config.yml` with the help of this [documentation](https://docs.invidious.io/Configuration.md).
## Limitations
* Invidious needs more than 2GB of RAM to build.

View file

@ -1,7 +1 @@
## Configuration
Vous pouvez configurer Invidious en modifiant le fichier de configuration `/var/www/invidious/config/config.yaml` avec l'aide de cette [documentation](https://docs.invidious.io/Configuration.md). Vous pouvez configurer Invidious en modifiant le fichier de configuration `/var/www/invidious/config/config.yaml` avec l'aide de cette [documentation](https://docs.invidious.io/Configuration.md).
## Limitations
* Invidious a besoin de plus de 3Go de RAM pour être installé.

View file

@ -1,5 +1,8 @@
Invidious is an interface allowing access to Youtube videos without going through youtube.com Invidious is an interface allowing access to Youtube videos without going through youtube.com
In addition to constituting an advantage in terms of confidentiality (the data does not pass directly through the services of the giant), this interface offers several features: In addition to constituting an advantage in terms of confidentiality (the data does not pass directly through the services of the giant).
### Features:
- Audio only mode, - Audio only mode,
- Dark mode, - Dark mode,
- Ability to display Reddit comments instead of YouTube comments, - Ability to display Reddit comments instead of YouTube comments,

View file

@ -1,5 +1,7 @@
Invidious est une interface permettant d'accéder aux vidéos Youtube sans passer par youtube.com Invidious est une interface permettant d'accéder aux vidéos Youtube sans passer par youtube.com
En plus de constituer un avantage sur le plan de la confidentialité (les données ne transitent pas directement par les services du géant), cette interface offre plusieurs fonctionnalités : En plus de constituer un avantage sur le plan de la confidentialité (les données ne transitent pas directement par les services du géant).
### Fonctionnalités :
- Mode audio seul, - Mode audio seul,
- Mode sombre, - Mode sombre,
- Possibilité d'afficher les commentaires Reddit plutôt que les commentaires YouTube, - Possibilité d'afficher les commentaires Reddit plutôt que les commentaires YouTube,

View file

@ -1,60 +0,0 @@
{
"name": "Invidious",
"id": "invidious",
"packaging_format": 1,
"description": {
"en": "Alternative front-end to YouTube",
"fr": "Front-end alternatif à YouTube"
},
"version": "23.02.14~ynh1",
"url": "https://invidio.us/",
"upstream": {
"license": "GPL-3.0-only",
"demo": "https://invidious.site/",
"admindoc": "https://docs.invidious.io/",
"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": ">= 11.0.9"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain"
},
{
"name": "admin",
"type": "user"
},
{
"name": "is_public",
"type": "boolean",
"help": {
"en": "If enabled, Invidious will be accessible by people who do not have an account. This can be changed later via the webadmin.",
"fr": "Si cette case est cochée, Invidious sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."
},
"default": true
},
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose the application language",
"fr": "Choisissez la langue de l'application"
},
"choices": ["de", "en-US", "es", "fr", "it", "nl", "pt-PT"],
"default": "fr"
}
]
}
}

70
manifest.toml Normal file
View file

@ -0,0 +1,70 @@
packaging_format = 2
id = "invidious"
name = "Invidious"
description.en = "Alternative front-end to YouTube"
description.fr = "Front-end alternatif à YouTube"
version = "23.02.14~ynh1"
maintainers = ["eric_G"]
[upstream]
license = "GPL-3.0-only"
demo = "https://invidious.site/"
admindoc = "https://docs.invidious.io/"
userdoc = "https://github.com/iv-org/documentation"
code = "https://github.com/iv-org/invidious"
website = "https://invidio.us/"
[integration]
yunohost = ">= 11.1.15"
architectures = ["amd64"]
multi_instance = false
ldap = false
sso = false
disk = "50M"
ram.build = "2G"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
full_domain = true
[install.admin]
type = "user"
[install.init_main_permission]
help.en = "If enabled, Invidious will be accessible by people who do not have an account. This can be changed later via the webadmin."
help.fr = "Si cette case est cochée, Invidious sera accessible aux personnes nayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin."
type = "group"
default = "visitors"
[install.language]
ask.en = "Choose the application language"
ask.fr = "Choisissez la langue de l'application"
type = "string"
choices = ["de", "en-US", "es", "fr", "it", "nl", "pt-PT"]
default = "fr"
[resources]
[resources.system_user]
[resources.install_dir]
[resources.ports]
[resources.permissions]
main.url = "/"
api.url = "/api"
api.show_tile = false
api.allowed = ["visitors"]
api.protected = true
[resources.apt]
packages = "apt-transport-https libssl-dev libxml2-dev libyaml-dev libgmp-dev libreadline-dev postgresql librsvg2-bin imagemagick libsqlite3-dev zlib1g-dev libevent-dev pkg-config libpcre3-dev"
[resources.database]
type = "postgresql"

View file

@ -5,8 +5,6 @@
#================================================= #=================================================
version_commit=7993784701686c057b85c57704537135e6326de9 version_commit=7993784701686c057b85c57704537135e6326de9
# dependencies used by the app
pkg_dependencies="apt-transport-https libssl-dev libxml2-dev libyaml-dev libgmp-dev libreadline-dev postgresql librsvg2-bin imagemagick libsqlite3-dev zlib1g-dev libevent-dev pkg-config libpcre3-dev"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS

View file

@ -9,27 +9,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# 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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -39,7 +18,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -9,60 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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)
#=================================================
# 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 # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -77,29 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
# 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 # GENERIC FINALISATION
@ -110,13 +34,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,124 +9,58 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE
admin=$YNH_APP_ARG_ADMIN
email=$(ynh_user_get_info --username=$admin --key=mail) email=$(ynh_user_get_info --username=$admin --key=mail)
app=$YNH_APP_INSTANCE_NAME
registration_enabled="true" registration_enabled="true"
login_enabled="true" login_enabled="true"
captcha_enabled="true" captcha_enabled="true"
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2 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=language --value=$language
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=email --value=$email ynh_app_setting_set --app=$app --key=email --value=$email
ynh_app_setting_set --app=$app --key=registration_enabled --value=$registration_enabled ynh_app_setting_set --app=$app --key=registration_enabled --value=$registration_enabled
ynh_app_setting_set --app=$app --key=login_enabled --value=$login_enabled ynh_app_setting_set --app=$app --key=login_enabled --value=$login_enabled
ynh_app_setting_set --app=$app --key=captcha_enabled --value=$captcha_enabled ynh_app_setting_set --app=$app --key=captcha_enabled --value=$captcha_enabled
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=0
# Find an available port
port=$(ynh_find_port --port=3000)
ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=15 ynh_script_progression --message="Installing dependencies..." --weight=15
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
#=================================================
# 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
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
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_user --db_name=$db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=4 ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set --app=$app --key=final_path --value=$final_path mkdir -p "$install_dir"
chown -R $app:www-data "$install_dir"
mkdir -p "$final_path" git config --system --add safe.directory $install_dir
chown -R $app:www-data "$final_path"
git config --system --add safe.directory $final_path
# Download, check integrity, uncompress and patch the source from GitHub # Download, check integrity, uncompress and patch the source from GitHub
ynh_exec_as $app git clone https://github.com/iv-org/invidious "$final_path" --quiet #ynh_exec_as $app
git clone https://github.com/iv-org/invidious "$install_dir" --quiet
pushd "$final_path" pushd "$install_dir"
ynh_exec_as $app git reset --hard --quiet $version_commit #ynh_exec_as $app
git reset --hard --quiet $version_commit
popd popd
for i in $final_path/config/sql/*.sql ; do for i in $install_dir/config/sql/*.sql ; do
ynh_replace_string --match_string="kemal" --replace_string=$db_user --target_file="$i" ; ynh_replace_string --match_string="kemal" --replace_string=$db_user --target_file="$i" ;
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < "$i" ; ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < "$i" ;
done done
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R $app:www-data "$install_dir"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -143,51 +77,35 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Building Invidious.. (this will take some time and resources!)" --weight=60 ynh_script_progression --message="Building Invidious.. (this will take some time and resources!)" --weight=60
pushd "$final_path" pushd "$install_dir"
ynh_exec_warn_less shards install --production ynh_exec_warn_less shards install --production
ynh_exec_warn_less crystal build $final_path/src/invidious.cr --release ynh_exec_warn_less crystal build $install_dir/src/invidious.cr --release
popd popd
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app ..." --weight=10
ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
ynh_use_logrotate
ynh_add_systemd_config
yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1 ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_add_config --template="../conf/config.yml" --destination="$final_path/config/config.yml" ynh_add_config --template="../conf/config.yml" --destination="$install_dir/config/config.yml"
chmod 600 "$final_path/config/config.yml" chmod 600 "$install_dir/config/config.yml"
chown $app:$app "$final_path/config/config.yml" chown $app:$app "$install_dir/config/config.yml"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_add_systemd_config
#=================================================
# SETUP CRON
#=================================================
ynh_script_progression --message="Setuping a cron..." --weight=1
ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -197,26 +115,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd ynh_systemd_action --service_name=$app --action=start --log_path=systemd
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission="main" --add="visitors"
fi
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=2
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,19 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
@ -36,73 +23,24 @@ then
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 ynh_script_progression --message="Removing system configurations related to $app..." --weight=10
dpkg --remove crystal
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
dpkg --remove crystal
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing Invidious main directory..." --weight=6
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing the cron file..." --weight=1
# Remove a cron file # Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# 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
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,37 +9,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading 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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
@ -49,24 +18,16 @@ ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" 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 # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring Invidious main directory..." --weight=4 ynh_script_progression --message="Restoring the app main directory..." --weight=4
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -75,9 +36,6 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=7 ynh_script_progression --message="Reinstalling dependencies..." --weight=7
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
#================================================= #=================================================
@ -85,54 +43,32 @@ ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- -
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=5 ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app" chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log" yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path=systemd
#================================================= #=================================================
# GENERIC FINALIZATION # 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
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -9,48 +9,12 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
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)
admin=$(ynh_app_setting_get --app=$app --key=admin)
port=$(ynh_app_setting_get --app=$app --key=port)
language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
email=$(ynh_app_setting_get --app=$app --key=email)
registration_enabled=$(ynh_app_setting_get --app=$app --key=registration_enabled)
login_enabled=$(ynh_app_setting_get --app=$app --key=login_enabled)
captcha_enabled=$(ynh_app_setting_get --app=$app --key=captcha_enabled)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up Invidious before upgrading..." --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 # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -65,43 +29,26 @@ ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if [ -z "$registration_enabled" ]; then if [ -z "${registration_enabled:-}" ]; then
registration_enabled="true" registration_enabled="true"
ynh_app_setting_set --app=$app --key=registration_enabled --value=$registration_enabled ynh_app_setting_set --app=$app --key=registration_enabled --value=$registration_enabled
fi fi
if [ -z "$login_enabled" ]; then if [ -z "${login_enabled:-}" ]; then
login_enabled="true" login_enabled="true"
ynh_app_setting_set --app=$app --key=login_enabled --value=$login_enabled ynh_app_setting_set --app=$app --key=login_enabled --value=$login_enabled
fi fi
if [ -z "$captcha_enabled" ]; then if [ -z "${captcha_enabled:-}" ]; then
captcha_enabled="true" captcha_enabled="true"
ynh_app_setting_set --app=$app --key=captcha_enabled --value=$captcha_enabled ynh_app_setting_set --app=$app --key=captcha_enabled --value=$captcha_enabled
fi fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# 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"
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=8 ynh_script_progression --message="Upgrading dependencies..." --weight=8
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
#================================================= #=================================================
@ -112,72 +59,47 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --weight=5 ynh_script_progression --message="Upgrading source files..." --weight=5
pushd $final_path pushd $install_dir
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
git config --system --add safe.directory $final_path git config --system --add safe.directory $install_dir
ynh_exec_as $app git fetch ynh_exec_as $app git fetch
#git checkout master #git checkout master
ynh_exec_as $app git reset --hard --quiet $version_commit ynh_exec_as $app git reset --hard --quiet $version_commit
ynh_exec_as $app git pull ynh_exec_as $app git pull
ynh_exec_warn_less shards install --production ynh_exec_warn_less shards install --production
ynh_exec_warn_less crystal build $final_path/src/invidious.cr --release ynh_exec_warn_less crystal build $install_dir/src/invidious.cr --release
popd popd
fi fi
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R $app:www-data "$install_dir"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
ynh_add_systemd_config
ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
ynh_use_logrotate --non-append
yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Modifying a config file..." ynh_script_progression --message="Modifying a config file..."
ynh_add_config --template="../conf/config.yml" --destination="$final_path/config/config.yml" ynh_add_config --template="../conf/config.yml" --destination="$install_dir/config/config.yml"
chmod 600 $final_path/config/config.yml chmod 600 $install_dir/config/config.yml
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# SETUP CRON
#=================================================
ynh_script_progression --message="Setuping a cron..." --weight=1
ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=3
yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -186,13 +108,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=restart --log_path=systemd ynh_systemd_action --service_name=$app --action=restart --log_path=systemd
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

9
tests.toml Normal file
View file

@ -0,0 +1,9 @@
test_format = 1.0
[default]
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.f468e338.name = "Upgrade from #111"