1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/invidious_ynh.git synced 2024-09-03 19:15:55 +02:00
invidious_ynh/scripts/upgrade
OniriCorpe 94b961c27d
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>
2024-01-04 19:18:16 +01:00

132 lines
4.3 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action=stop --log_path=systemd
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
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
fi
if [ -z "${login_enabled:-}" ]; then
login_enabled="true"
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
fi
if [ -z "${key:-}" ]; then
key=$(ynh_string_random --length=24)
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
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=8
ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
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"
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_warn_less shards install --production
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"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_add_systemd_config
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"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1
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"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action=restart --log_path=systemd
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of Invidious completed" --last