2021-01-04 12:14:25 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2022-01-25 09:49:10 +01:00
|
|
|
mautrix_version=$(ynh_app_upstream_version)
|
2022-09-04 22:28:27 +02:00
|
|
|
synapse_db_name="matrix_$synapse_instance"
|
2024-02-26 14:56:12 +01:00
|
|
|
server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
|
|
|
|
domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
|
2021-01-04 12:14:25 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-01-25 09:49:10 +01:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2022-09-04 22:28:27 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
2021-01-04 12:14:25 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-01-25 09:49:10 +01:00
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
2021-01-04 12:14:25 +01:00
|
|
|
#=================================================
|
2022-01-25 09:49:10 +01:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2022-01-25 09:49:10 +01:00
|
|
|
# Fix possible permission issues with a previous signald version, esp. with stickers
|
|
|
|
mkdir -p /var/lib/signald/{avatars,attachments,stickers}
|
2024-02-26 13:49:53 +01:00
|
|
|
chown "$signald_user:$signald_user" /var/lib/signald/{avatars,attachments,stickers}
|
2022-01-25 09:49:10 +01:00
|
|
|
chmod -R g+rwX /var/lib/signald/{avatars,attachments,stickers}
|
2021-06-22 18:28:47 +02:00
|
|
|
|
2021-01-04 12:14:25 +01:00
|
|
|
#=================================================
|
2022-01-25 09:49:10 +01:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2021-01-04 12:14:25 +01:00
|
|
|
#=================================================
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source --dest_dir="$install_dir/src" --full_replace=1
|
2022-09-04 22:28:27 +02:00
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:$app" "$install_dir"
|
2021-06-22 18:28:47 +02:00
|
|
|
|
2022-01-25 09:49:10 +01:00
|
|
|
#=================================================
|
2022-09-04 22:28:27 +02:00
|
|
|
# UPDATE A CONFIG FILE
|
2022-01-25 09:49:10 +01:00
|
|
|
#=================================================
|
2022-09-04 22:28:27 +02:00
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=2
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
chmod 400 "$install_dir/config.yaml"
|
|
|
|
chown "$app:$app" "$install_dir/config.yaml"
|
2021-06-22 18:28:47 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# UPGRADE MAUTRIX-BRIDGE PYTHON MODULE
|
|
|
|
#=================================================
|
2022-09-04 23:58:20 +02:00
|
|
|
ynh_script_progression --message="Upgrading Mautrix-Bridge Python Module..." --weight=2
|
2021-06-22 18:28:47 +02:00
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
if [ "$YNH_ARCH" == "armhf" ] || [ "$YNH_ARCH" == "armel" ]; then
|
|
|
|
# Install rustup is not already installed
|
|
|
|
# We need this to be able to install cryptgraphy
|
|
|
|
_install_rustup
|
2023-09-05 22:32:28 +02:00
|
|
|
fi
|
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
_mautrix_signal_build_venv
|
2021-06-22 18:28:47 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REGISTER SYNAPSE APP-SERVICE
|
|
|
|
#=================================================
|
2022-09-04 23:58:20 +02:00
|
|
|
ynh_script_progression --message="Registering Synapse app-service" --weight=1
|
2021-06-22 18:28:47 +02:00
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
"$install_dir/venv/bin/python3" -m mautrix_signal -g -c "$install_dir/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
2022-09-04 22:28:27 +02:00
|
|
|
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2022-09-04 23:58:20 +02:00
|
|
|
# Set permissions on app files
|
2024-02-26 13:49:53 +01:00
|
|
|
chown -R "$app:$app" "$install_dir"
|
2022-09-04 23:58:20 +02:00
|
|
|
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
2022-09-04 22:28:27 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-02-26 13:49:53 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2022-09-04 22:28:27 +02:00
|
|
|
#=================================================
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
2022-09-04 22:28:27 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2024-02-26 13:49:53 +01:00
|
|
|
yunohost service add "$app" --description="$app daemon for bridging Signal and Matrix messages" --log="/var/log/$app/$app.log"
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2022-09-04 22:28:27 +02:00
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
2022-08-16 20:20:48 +02:00
|
|
|
ynh_use_logrotate --nonappend
|
2021-01-04 12:14:25 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-01-25 09:49:10 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2022-09-04 22:28:27 +02:00
|
|
|
# Start a systemd service
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="start"
|
2021-01-04 12:14:25 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-01-25 09:49:10 +01:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|