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

2 new settings in the config panel (#144)

* Testing (#143)

* Thumbnails (#133)

* Update manifest.toml

* Update manifest.toml

* Update manifest.toml

* Auto-update README

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* fix

* Auto-update README

* Update manifest.toml

* Only build invidious once per install (#136)

* Thumbnails (#133) (#134)

* Thumbnails (#133)

* Update manifest.toml

* Update manifest.toml

* Update manifest.toml

* Auto-update README

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* fix

* Auto-update README

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* Only build invidious once per install

* Update manifest.toml

---------

Co-authored-by: Tagada <36127788+Tagadda@users.noreply.github.com>
Co-authored-by: eric_G <46165813+ericgaspar@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* Update manifest.toml

* fix

* Auto-update README

* Update manifest.toml

* Auto-update README

* Update manifest.toml

* cleaning

* Auto-update README

* update

* Auto-update README

* upgrade

* Auto-update README

* fix

* Auto-update README

* update to upstream

* Auto-update README

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: selfhoster1312 <121760708+selfhoster1312@users.noreply.github.com>
Co-authored-by: Tagada <36127788+Tagadda@users.noreply.github.com>

* implement new parameters

* add new parameters

* fix shellcheck SC2086

* typo

* sigh an omission

* add pre upgrade message about the 2 new settings

* simplify ynh_add_config templates paths

* bad copy paste :"3

* add how to find the config panel

* add a note about the fact we can't use resources.sources instead of git

* oupsi ^^"

---------

Co-authored-by: eric_G <46165813+ericgaspar@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: selfhoster1312 <121760708+selfhoster1312@users.noreply.github.com>
Co-authored-by: Tagada <36127788+Tagadda@users.noreply.github.com>
This commit is contained in:
OniriCorpe 2024-01-04 19:18:16 +01:00 committed by GitHub
parent 80fd6b8534
commit 94b961c27d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 113 additions and 70 deletions

View file

@ -216,7 +216,7 @@ hsts: true
## Accepted values: true, false
## Default: true
##
#popular_enabled: true
# popular_enabled: true
##
## Enable/Disable statstics (available at /api/v1/stats).
@ -305,7 +305,7 @@ admins: ["__ADMIN__"]
## Accepted values: true, false
## Default: true
##
#enable_user_notifications: true
enable_user_notifications: __ENABLE_USER_NOTIFICATIONS__
# -----------------------------
# Background jobs
@ -433,7 +433,7 @@ jobs:
## Accepted values: any string. HTML is accepted.
## Default: <none>
##
#banner:
banner: __BANNER__
##
## Subscribe to channels using PubSubHub (Google PubSubHubbub service).

View file

@ -4,29 +4,48 @@ version = "1.0"
name = "Invidious configuration"
services = ["__APP__"]
[main.config]
name = "Configuration Options"
[main.config.registration_enabled]
ask = "Enable registration"
type = "boolean"
yes = "true"
no = "false"
help = "Allow/Forbid Invidious (local) account creation"
bind = "registration_enabled:__INSTALL_DIR__/config/config.yml"
[main.users_accounts]
name = "Users and accounts configuration"
[main.config.login_enabled]
ask = "Enable login"
type = "boolean"
yes = "true"
no = "false"
help = "Allow/Forbid users to log-in"
bind = "login_enabled:__INSTALL_DIR__/config/config.yml"
[main.users_accounts.registration_enabled]
ask = "Enable registration"
type = "boolean"
yes = "true"
no = "false"
help = "Allow/Forbid Invidious (local) account creation"
bind = "registration_enabled:__INSTALL_DIR__/config/config.yml"
[main.config.captcha_enabled]
ask = "Enable captcha"
type = "boolean"
yes = "true"
no = "false"
help = "Enable/Disable the captcha challenge on the login page"
bind = "captcha_enabled:__INSTALL_DIR__/config/config.yml"
[main.users_accounts.login_enabled]
ask = "Enable login"
type = "boolean"
yes = "true"
no = "false"
help = "Allow/Forbid users to log-in"
bind = "login_enabled:__INSTALL_DIR__/config/config.yml"
[main.users_accounts.captcha_enabled]
ask = "Enable captcha"
type = "boolean"
yes = "true"
no = "false"
help = "Enable/Disable the captcha challenge on the login page"
bind = "captcha_enabled:__INSTALL_DIR__/config/config.yml"
[main.users_accounts.enable_user_notifications]
ask = "Enable user notifications"
type = "boolean"
yes = "true"
no = "false"
help = "Note: On large instances, it is recommended to set this option to 'false' in order to reduce the amount of data written to the database, and hence improve the overall performance of the instance."
bind = "enable_user_notifications:__INSTALL_DIR__/config/config.yml"
[main.miscellaneous]
name = "Miscellaneous configuration"
[main.miscellaneous.banner]
ask.en = "Text of the banner"
bind = "banner:__INSTALL_DIR__/config/config.yml"
help = "Custom banner displayed at the top of every page. This can used for instance announcements. Accepted values: any string. HTML is accepted. Empty by default."
type = "string"

View file

@ -0,0 +1,7 @@
Two new settings can now be configured in the app config panel:
- Enable/Disable the user notifications for all users: On large instances, it is recommended to set this option to 'false' in order to reduce the amount of data written to the database, and hence improve the overall performance of the instance.
- Banner: Custom banner displayed at the top of every page. This can used for instance announcements. Accepted values: any string. HTML is accepted. Empty by default.
To user either of these settings, go to the config panel:
Applications → Invidious → Invidious configuration

View file

@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers
#=================================================
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"
#=================================================
# MODIFY URL IN NGINX CONF
@ -30,10 +30,10 @@ ynh_change_url_nginx_config
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_add_config --template="../conf/config.yml" --destination="$install_dir/config/config.yml"
ynh_add_config --template="config.yml" --destination="$install_dir/config/config.yml"
chmod 600 $install_dir/config/config.yml
chown $app:$app "$install_dir/config/config.yml"
chmod 600 "$install_dir/config/config.yml"
chown "$app:$app" "$install_dir/config/config.yml"
#=================================================
# GENERIC FINALISATION
@ -42,7 +42,7 @@ chown $app:$app "$install_dir/config/config.yml"
#=================================================
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"
#=================================================
# END OF SCRIPT

View file

@ -17,16 +17,20 @@ key=$(ynh_string_random --length=24)
registration_enabled="true"
login_enabled="true"
captcha_enabled="true"
enable_user_notifications="true"
banner=""
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set --app=$app --key=key --value=$key
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=captcha_enabled --value=$captcha_enabled
ynh_app_setting_set --app="$app" --key=key --value="$key"
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=captcha_enabled --value=$captcha_enabled
ynh_app_setting_set --app="$app" --key=enable_user_notifications --value=$enable_user_notifications
ynh_app_setting_set --app="$app" --key=banner --value="$banner"
#=================================================
# INSTALL DEPENDENCIES
@ -41,30 +45,33 @@ ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- -
ynh_script_progression --message="Setting up source files..." --weight=4
mkdir -p "$install_dir"
chown -R $app:www-data "$install_dir"
chown -R "$app:www-data" "$install_dir"
git config --system --add safe.directory $install_dir
git config --system --add safe.directory "$install_dir"
# Download, check integrity, uncompress and patch the source from GitHub
# note: we can't use resources.sources instead of git because Invidious is
# expecting to be in a git environment for the building step...
# see: https://github.com/YunoHost-Apps/invidious_ynh/pull/127
git clone https://github.com/iv-org/invidious "$install_dir" --quiet
pushd "$install_dir"
git reset --hard --quiet $version_commit
git reset --hard --quiet "$version_commit"
make
popd
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_add_config --template="../conf/config.yml" --destination="$install_dir/config/config.yml"
ynh_add_config --template="config.yml" --destination="$install_dir/config/config.yml"
chmod 600 "$install_dir/config/config.yml"
chown $app:$app "$install_dir/config/config.yml"
chown "$app:$app" "$install_dir/config/config.yml"
#=================================================
# SPECIFIC SETUP
@ -85,7 +92,7 @@ ynh_script_progression --message="Adding system configurations related to $app .
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app"
ynh_add_config --template="cron_invidious" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
@ -93,7 +100,7 @@ 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"
yunohost service add "$app" --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
@ -101,7 +108,7 @@ yunohost service add $app --description="Invidious is an alternative front-end t
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
ynh_systemd_action --service_name="$app" --action=start --log_path=systemd
#=================================================
# END OF SCRIPT

View file

@ -16,10 +16,10 @@ source /usr/share/yunohost/helpers
#=================================================
# 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
if ynh_exec_warn_less yunohost service status "$app" >/dev/null
then
ynh_script_progression --message="Removing $app service..." --weight=1
yunohost service remove $app
yunohost service remove "$app"
fi
#=================================================

View file

@ -26,7 +26,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# SPECIFIC RESTORATION
@ -42,7 +42,7 @@ 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_psql_execute_file_as_root --file="./db.sql" --database=$db_name
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
@ -50,7 +50,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
systemctl enable "$app.service" --quiet
ynh_restore_file --origin_path="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
@ -58,7 +58,7 @@ chmod 644 "/etc/cron.d/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
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"
#=================================================
# GENERIC FINALIZATION
@ -67,7 +67,7 @@ yunohost service add $app --description="Invidious is an alternative front-end t
#=================================================
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="$app" --action=start --log_path=systemd
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -22,7 +22,7 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
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
@ -31,22 +31,32 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if [ -z "${registration_enabled:-}" ]; then
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
if [ -z "${login_enabled:-}" ]; then
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
if [ -z "${captcha_enabled:-}" ]; then
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
if [ -z "${key:-}" ]; then
key=$(ynh_string_random --length=24)
ynh_app_setting_set --app=$app --key=key --value=$key
ynh_app_setting_set --app="$app" --key=key --value="$key"
fi
if [ -z "${enable_user_notifications:-}" ]; then
enable_user_notifications="true"
ynh_app_setting_set --app="$app" --key=enable_user_notifications --value="$enable_user_notifications"
fi
if [ -z "${banner:-}" ]; then
banner=""
ynh_app_setting_set --app="$app" --key=banner --value="$banner"
fi
#=================================================
@ -64,21 +74,21 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=5
pushd $install_dir
chown -R $app:www-data "$install_dir"
git config --system --add safe.directory $install_dir
pushd "$install_dir"
chown -R "$app:www-data" "$install_dir"
git config --system --add safe.directory "$install_dir"
ynh_exec_as $app git fetch
ynh_exec_as "$app" git fetch
#git checkout master
ynh_exec_as $app git reset --hard --quiet $version_commit
ynh_exec_as $app git pull
ynh_exec_as "$app" git reset --hard --quiet "$version_commit"
ynh_exec_as "$app" git pull
ynh_exec_warn_less shards install --production
ynh_exec_warn_less crystal build $install_dir/src/invidious.cr --release
ynh_exec_warn_less crystal build "$install_dir/src/invidious.cr" --release
popd
fi
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
@ -90,30 +100,30 @@ ynh_add_nginx_config
ynh_add_systemd_config
ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app"
ynh_add_config --template="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"
yunohost service add "$app" --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_add_config --template="../conf/config.yml" --destination="$install_dir/config/config.yml"
ynh_add_config --template="config.yml" --destination="$install_dir/config/config.yml"
chmod 600 $install_dir/config/config.yml
chown $app:$app "$install_dir/config/config.yml"
chmod 600 "$install_dir/config/config.yml"
chown "$app:$app" "$install_dir/config/config.yml"
#=================================================
# START SYSTEMD SERVICE
#=================================================
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
#=================================================
# END OF SCRIPT