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

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-30 23:36:51 +02:00 committed by Alexandre Aubin
parent 3d152f7a59
commit dedaeb1d1f
9 changed files with 120 additions and 177 deletions

BIN
.DS_Store vendored

Binary file not shown.

View file

@ -17,7 +17,8 @@ admindoc = "https://docs.invidious.io/"
code = "https://github.com/iv-org/invidious"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["amd64"]
multi_instance = false

View file

@ -1,19 +1,7 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
version_commit=e319c35f097e08590e705378c7e5b479720deabc
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,46 +1,37 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup "/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/cron.d/$app"
ynh_backup "/etc/cron.d/$app"
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================
ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_print_info "Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
ynh_psql_dump_db > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for Invidious. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for Invidious. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,51 +1,41 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
ynh_systemctl --service="$app" --action="stop" --log_path="systemd"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_script_progression "Updating configuration..."
ynh_add_config --template="config.yml" --destination="$install_dir/config/config.yml"
ynh_config_add --template="config.yml" --destination="$install_dir/config/config.yml"
chmod 600 "$install_dir/config/config.yml"
chown "$app:$app" "$install_dir/config/config.yml"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/config/config.yml"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/config/config.yml"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd"
ynh_systemctl --service="$app" --action="start" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -23,30 +17,29 @@ banner=""
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_script_progression "Storing installation settings..."
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"
ynh_app_setting_set --key=key --value="$key"
ynh_app_setting_set --key=registration_enabled --value=$registration_enabled
ynh_app_setting_set --key=login_enabled --value=$login_enabled
ynh_app_setting_set --key=captcha_enabled --value=$captcha_enabled
ynh_app_setting_set --key=enable_user_notifications --value=$enable_user_notifications
ynh_app_setting_set --key=banner --value="$banner"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=15
ynh_script_progression "Installing dependencies..."
ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
ynh_hide_warnings curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=4
ynh_script_progression "Setting up source files..."
mkdir -p "$install_dir"
chown -R "$app:www-data" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
git config --system --add safe.directory "$install_dir"
# Download, check integrity, uncompress and patch the source from GitHub
@ -60,25 +53,24 @@ pushd "$install_dir"
make
popd
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_script_progression "Updating configuration..."
ynh_add_config --template="config.yml" --destination="$install_dir/config/config.yml"
ynh_config_add --template="config.yml" --destination="$install_dir/config/config.yml"
chmod 600 "$install_dir/config/config.yml"
chown "$app:$app" "$install_dir/config/config.yml"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/config/config.yml"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/config/config.yml"
#=================================================
# SPECIFIC SETUP
#=================================================
# INSTALL INVIDIOUS
#=================================================
ynh_script_progression --message="Building Invidious.. (this will take some time and resources!)" --weight=60
ynh_script_progression "Building Invidious.. (this will take some time and resources!)"
pushd "$install_dir"
./invidious --migrate
@ -87,31 +79,31 @@ popd
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app ..." --weight=10
ynh_script_progression "Adding system configurations related to $app ..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
ynh_add_config --template="cron_invidious" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
ynh_config_add --template="cron_invidious" --destination="/etc/cron.d/$app"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app"
ynh_use_logrotate
ynh_config_add_logrotate
ynh_add_systemd_config
ynh_config_add_systemd
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=2
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app" --action=start --log_path=systemd
ynh_systemctl --service="$app" --action=start --log_path=systemd
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of Invidious completed" --last
ynh_script_progression "Installation of Invidious completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -16,28 +10,28 @@ 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_hide_warnings yunohost service status "$app" >/dev/null
then
ynh_script_progression --message="Removing $app service..." --weight=1
ynh_script_progression "Removing $app service..."
yunohost service remove "$app"
fi
dpkg --remove crystal
# Remove the dedicated systemd config
ynh_remove_systemd_config
ynh_config_remove_systemd
# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx
# Remove the app-specific logrotate config
ynh_remove_logrotate
ynh_config_remove_logrotate
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
ynh_safe_rm "/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of Invidious completed" --last
ynh_script_progression "Removal of Invidious completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -14,65 +8,62 @@ source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_script_progression "Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=4
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
ynh_restore "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=7
ynh_script_progression "Reinstalling dependencies..."
ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
ynh_hide_warnings curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6
ynh_script_progression "Restoring the PostgreSQL database..."
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
ynh_psql_db_shell " < "./db.sql""
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable "$app.service" --quiet
ynh_restore_file --origin_path="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
ynh_restore "/etc/cron.d/$app"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore "/etc/logrotate.d/$app"
yunohost service add "$app" --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemd_action --service_name="$app" --action=start --log_path=systemd
ynh_systemctl --service="$app" --action=start --log_path=systemd
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for Invidious" --last
ynh_script_progression "Restoration completed for Invidious"

View file

@ -1,124 +1,120 @@
#!/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
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name="$app" --action=stop --log_path=systemd
ynh_systemctl --service="$app" --action=stop --log_path=systemd
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
ynh_script_progression "Ensuring downward compatibility..."
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=registration_enabled --value="true"
if [ -z "${registration_enabled:-}" ]; then
registration_enabled="true"
ynh_app_setting_set --app="$app" --key=registration_enabled --value=$registration_enabled
ynh_app_setting_set --key=registration_enabled --value=$registration_enabled
fi
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=login_enabled --value="true"
if [ -z "${login_enabled:-}" ]; then
login_enabled="true"
ynh_app_setting_set --app="$app" --key=login_enabled --value=$login_enabled
ynh_app_setting_set --key=login_enabled --value=$login_enabled
fi
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=captcha_enabled --value="true"
if [ -z "${captcha_enabled:-}" ]; then
captcha_enabled="true"
ynh_app_setting_set --app="$app" --key=captcha_enabled --value=$captcha_enabled
ynh_app_setting_set --key=captcha_enabled --value=$captcha_enabled
fi
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=key --value=$(ynh_string_random --length=24)
if [ -z "${key:-}" ]; then
key=$(ynh_string_random --length=24)
ynh_app_setting_set --app="$app" --key=key --value="$key"
ynh_app_setting_set --key=key --value="$key"
fi
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=enable_user_notifications --value="true"
if [ -z "${enable_user_notifications:-}" ]; then
enable_user_notifications="true"
ynh_app_setting_set --app="$app" --key=enable_user_notifications --value="$enable_user_notifications"
ynh_app_setting_set --key=enable_user_notifications --value="$enable_user_notifications"
fi
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=banner --value=""
if [ -z "${banner:-}" ]; then
banner=""
ynh_app_setting_set --app="$app" --key=banner --value="$banner"
ynh_app_setting_set --key=banner --value="$banner"
fi
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=8
ynh_script_progression "Upgrading dependencies..."
ynh_exec_warn_less curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
ynh_hide_warnings curl -fsSL https://crystal-lang.org/install.sh | bash -s -- --channel=stable
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=5
ynh_script_progression "Upgrading source files..."
pushd "$install_dir"
chown -R "$app:www-data" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | 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
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
ynh_exec_as_app git reset --hard --quiet "$version_commit"
ynh_exec_as_app git pull
ynh_hide_warnings shards install --production
ynh_hide_warnings crystal build "$install_dir/src/invidious.cr" --release
popd
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_script_progression "Upgrading system configurations related to $app..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
ynh_add_systemd_config
ynh_config_add_systemd
ynh_add_config --template="cron_invidious" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
ynh_config_add --template="cron_invidious" --destination="/etc/cron.d/$app"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app"
ynh_use_logrotate --non-append
ynh_config_add_logrotate
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_script_progression "Updating configuration..."
ynh_add_config --template="config.yml" --destination="$install_dir/config/config.yml"
ynh_config_add --template="config.yml" --destination="$install_dir/config/config.yml"
chmod 600 "$install_dir/config/config.yml"
chown "$app:$app" "$install_dir/config/config.yml"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/config/config.yml"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/config/config.yml"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action=restart --log_path=systemd
ynh_systemctl --service="$app" --action=restart --log_path=systemd
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of Invidious completed" --last
ynh_script_progression "Upgrade of Invidious completed"