2020-11-09 22:28:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
|
2024-01-04 22:10:47 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action=stop --log_path=systemd
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2021-10-04 00:01:07 +02:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
if [ -z "${registration_enabled:-}" ]; then
|
2022-01-20 15:40:49 +01:00
|
|
|
registration_enabled="true"
|
2024-01-04 22:10:47 +01:00
|
|
|
ynh_app_setting_set --app="$app" --key=registration_enabled --value=$registration_enabled
|
2022-01-20 15:40:49 +01:00
|
|
|
fi
|
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
if [ -z "${login_enabled:-}" ]; then
|
2022-01-20 15:40:49 +01:00
|
|
|
login_enabled="true"
|
2024-01-04 22:10:47 +01:00
|
|
|
ynh_app_setting_set --app="$app" --key=login_enabled --value=$login_enabled
|
2022-01-20 15:40:49 +01:00
|
|
|
fi
|
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
if [ -z "${captcha_enabled:-}" ]; then
|
2022-01-20 15:40:49 +01:00
|
|
|
captcha_enabled="true"
|
2024-01-04 22:10:47 +01:00
|
|
|
ynh_app_setting_set --app="$app" --key=captcha_enabled --value=$captcha_enabled
|
2022-01-20 15:40:49 +01:00
|
|
|
fi
|
|
|
|
|
2023-05-20 18:09:04 +02:00
|
|
|
if [ -z "${key:-}" ]; then
|
|
|
|
key=$(ynh_string_random --length=24)
|
2024-01-04 22:10:47 +01:00
|
|
|
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"
|
2023-05-20 18:09:04 +02:00
|
|
|
fi
|
|
|
|
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
|
|
|
# UPGRADE DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading dependencies..." --weight=8
|
|
|
|
|
2021-10-04 00:01:07 +02:00
|
|
|
ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
|
2021-05-23 12:01:50 +02:00
|
|
|
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2024-06-17 22:05:21 +02:00
|
|
|
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 config pull.rebase false
|
|
|
|
|
|
|
|
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
|
2020-11-09 22:28:22 +01:00
|
|
|
|
|
|
|
|
2023-03-12 08:58:03 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
2024-01-04 22:10:47 +01:00
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2021-05-23 12:01:50 +02:00
|
|
|
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
2023-03-12 08:58:03 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
2023-03-12 08:58:03 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2022-03-04 10:56:48 +01:00
|
|
|
# Create a dedicated NGINX config
|
2020-11-09 22:28:22 +01:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
2024-01-04 22:10:47 +01:00
|
|
|
ynh_add_config --template="cron_invidious" --destination="/etc/cron.d/$app"
|
2021-10-04 00:01:07 +02:00
|
|
|
chown root: "/etc/cron.d/$app"
|
|
|
|
chmod 644 "/etc/cron.d/$app"
|
|
|
|
|
2020-11-09 22:28:22 +01:00
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
2024-01-04 22:10:47 +01:00
|
|
|
yunohost service add "$app" --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log"
|
2023-03-12 08:58:03 +01:00
|
|
|
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
2023-03-12 08:58:03 +01:00
|
|
|
# MODIFY A CONFIG FILE
|
2020-11-09 22:28:22 +01:00
|
|
|
#=================================================
|
2023-08-03 09:49:34 +02:00
|
|
|
ynh_script_progression --message="Modifying a config file..." --weight=1
|
2020-11-09 22:28:22 +01:00
|
|
|
|
2024-01-04 22:10:47 +01:00
|
|
|
ynh_add_config --template="config.yml" --destination="$install_dir/config/config.yml"
|
2023-08-03 09:49:34 +02:00
|
|
|
|
2024-01-04 22:10:47 +01:00
|
|
|
chmod 600 "$install_dir/config/config.yml"
|
|
|
|
chown "$app:$app" "$install_dir/config/config.yml"
|
2020-11-09 22:28:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
|
2024-01-04 22:10:47 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action=restart --log_path=systemd
|
2020-11-09 22:28:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of Invidious completed" --last
|