2023-01-11 18:59:44 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
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="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
2024-01-05 16:20:44 +01:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
2023-01-11 18:59:44 +01:00
|
|
|
|
2024-01-05 19:04:33 +01:00
|
|
|
# Missing settings ?
|
2024-01-05 17:15:51 +01:00
|
|
|
if [ -z "${public_key+x}" ]; then
|
|
|
|
public_key=""
|
|
|
|
ynh_app_setting_set --app="$app" --key=public_key --value="$public_key"
|
|
|
|
fi
|
2024-01-05 19:04:33 +01:00
|
|
|
if [ -z "${install_chromium+x}" ]; then
|
|
|
|
install_chromium="false"
|
|
|
|
ynh_app_setting_set --app="$app" --key=install_chromium --value="$install_chromium"
|
|
|
|
fi
|
2024-01-05 17:15:51 +01:00
|
|
|
|
2023-01-11 18:59:44 +01:00
|
|
|
#=================================================
|
2024-01-05 16:20:44 +01:00
|
|
|
# INSTALL NODEJS
|
2023-01-11 18:59:44 +01:00
|
|
|
#=================================================
|
2024-01-05 16:20:44 +01:00
|
|
|
ynh_script_progression --message="Upgrading NodeJS..." --weight=3
|
2023-01-11 18:59:44 +01:00
|
|
|
|
|
|
|
ynh_install_nodejs --nodejs_version=$nodejs_version
|
|
|
|
ynh_use_nodejs
|
|
|
|
|
2023-02-15 16:25:40 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2024-01-05 16:20:44 +01:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
|
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=6
|
2023-01-11 18:59:44 +01:00
|
|
|
|
2024-01-05 16:20:44 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from amd64.src
|
2024-03-11 15:39:56 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir/package" --full_replace=1
|
2023-01-11 18:59:44 +01:00
|
|
|
fi
|
|
|
|
|
2024-01-05 16:20:44 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:$app "$install_dir"
|
2023-02-15 16:25:40 +01:00
|
|
|
|
2024-01-05 16:20:44 +01:00
|
|
|
if [ -n "$public_key" ]; then
|
|
|
|
ynh_script_progression --message="Enabling ssh access for dev..." --weight=1
|
|
|
|
# enable ssh access to the files for updates
|
|
|
|
# todo: Secure it more with https://github.com/YunoHost-Apps/ssh_chroot_dir_ynh
|
|
|
|
mkdir --parents "$install_dir/.ssh"
|
|
|
|
ynh_add_config --template="authorized_keys" --destination="$install_dir/.ssh/authorized_keys"
|
2023-02-15 16:25:40 +01:00
|
|
|
|
2024-01-05 16:20:44 +01:00
|
|
|
chown -R "$app:$app" "$install_dir/.ssh"
|
|
|
|
chmod 700 "$install_dir/.ssh"
|
|
|
|
chmod 600 "$install_dir/.ssh/authorized_keys"
|
2023-02-15 16:25:40 +01:00
|
|
|
|
2024-01-05 16:20:44 +01:00
|
|
|
_install_restart_script_and_sudoers
|
2023-02-15 16:25:40 +01:00
|
|
|
fi
|
|
|
|
|
2024-01-05 16:20:44 +01:00
|
|
|
|
2023-02-26 15:36:39 +01:00
|
|
|
#=================================================
|
|
|
|
# Install chromium
|
|
|
|
#=================================================
|
2024-01-05 19:04:33 +01:00
|
|
|
if [ "$install_chromium" -eq 1 ]; then
|
2024-01-05 16:20:44 +01:00
|
|
|
ynh_script_progression --message="Upgrading Chromium..." --weight=8
|
|
|
|
|
2023-02-26 15:36:39 +01:00
|
|
|
# Remove old versions of chrome
|
2024-01-05 16:20:44 +01:00
|
|
|
ynh_secure_remove --file="$install_dir/.cache/puppeteer/chrome"
|
2023-02-26 15:36:39 +01:00
|
|
|
|
2024-01-05 16:20:44 +01:00
|
|
|
pushd "$install_dir/package"
|
|
|
|
ynh_exec_as "$app" $ynh_node_load_PATH $ynh_node "./node_modules/puppeteer/install.js"
|
|
|
|
popd
|
2023-02-26 15:36:39 +01:00
|
|
|
fi
|
|
|
|
|
2023-01-11 18:59:44 +01:00
|
|
|
#=================================================
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
|
|
|
|
2024-01-05 16:20:44 +01:00
|
|
|
_generate_env_file
|
2023-01-11 18:59:44 +01:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-05 16:20:44 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2023-01-11 18:59:44 +01:00
|
|
|
#=================================================
|
2024-01-05 16:20:44 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2023-01-11 18:59:44 +01:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2024-01-05 16:20:44 +01:00
|
|
|
yunohost service add $app --description="A Cors proxy letting the browser manages cookies and redirects." --log="/var/log/$app/$app.log"
|
2023-01-11 18:59:44 +01:00
|
|
|
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|