diff --git a/scripts/upgrade b/scripts/upgrade old mode 100644 new mode 100755 index d5713e1..9af6cde --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,28 +38,13 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # TODO: check if there are some file that need some chown chmod # TODO: look at whatsapp to compare -#================================================= -# MIGRATION 1 : PYTHON TO GO BRIDGE -#================================================= - -# Version 0.5.1 of Mautrix Signal Bridge is written in Go, whereas previous versions -# were written in Python. Also signald data is not needed anymore. - -# Remove rustup -export PATH="$PATH:$install_dir/.cargo/bin:$install_dir/.local/bin:/usr/local/sbin" - -if [ -e "$install_dir/.rustup" ]; then - ynh_exec_as "$app" env "PATH=$PATH" rustup self uninstall +# Check if an old version of the bridge is in use +# In this case it needs to be upgraded from python to go +# Note that 0.5.0 was never released, but it makes for a good cut-off +if ynh_compare_current_package_version --comparison lt --version 0.5.0~ynh1 +then + source upgrade-pre-0.5.sh fi -# Remove signald executable -ynh_remove_systemd_config --service="signald" -ynh_secure_remove --file="$signald_exe" - -# Remove signald data -ynh_secure_remove --file="$signald_data" -# Remove signald system user -ynh_system_user_delete --username=$signald_user - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE diff --git a/scripts/upgrade-pre-0.5.sh b/scripts/upgrade-pre-0.5.sh new file mode 100755 index 0000000..6fcf1f9 --- /dev/null +++ b/scripts/upgrade-pre-0.5.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# This script is intended to handle the upgrade from python to go. +# It should be ran exactly once, when installing a post-v5.0 version onto a pre-v5.0 version. +# +# This script is intended to be sourced from the main upgrade script, in order to retain variables + +#================================================= +# MIGRATION 1 : PYTHON TO GO BRIDGE +#================================================= + +# Version 0.5.1 of Mautrix Signal Bridge is written in Go, whereas previous versions +# were written in Python. Also signald data is not needed anymore. + +# Remove rustup +export PATH="$PATH:$install_dir/.cargo/bin:$install_dir/.local/bin:/usr/local/sbin" + +if [ -e "$install_dir/.rustup" ]; then + ynh_exec_as "$app" env "PATH=$PATH" rustup self uninstall +fi + +# Remove signald executable +ynh_remove_systemd_config --service="signald" +ynh_secure_remove --file="$signald_exe" + +# Remove signald data +ynh_secure_remove --file="$signald_data" +# Remove signald system user +ynh_system_user_delete --username=$signald_user +