diff --git a/conf/config.yaml b/conf/config.yaml index dd227f6..cbe23d0 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -91,7 +91,7 @@ signal: bridge: # Localpart template of MXIDs for Signal users. # {{.}} is replaced with the internal ID of the Signal user. - username_template: sg_{{.UUID}} + username_template: sg_{{.}} # Displayname template for Signal users. This is also used as the room name in DMs if private_chat_portal_meta is enabled. # {{.ProfileName}} - The Signal profile name set by the user. # {{.ContactName}} - The name for the user from your phone's contact list. This is not safe on multi-user instances. @@ -301,7 +301,7 @@ bridge: # Logging config. See https://github.com/tulir/zeroconfig for details. logging: - min_level: _PRINT_LEVEL__ + min_level: info writers: - type: stdout format: pretty-colored diff --git a/manifest.toml b/manifest.toml index 5d160cb..901bd92 100644 --- a/manifest.toml +++ b/manifest.toml @@ -13,7 +13,7 @@ maintainers = ["MayeulC"] [upstream] license = "AGPL-3.0-or-later" -userdoc = "https://docs.mau.fi/bridges/python/signal/index.html" +userdoc = "https://docs.mau.fi/bridges/go/signal/index.html" code = "https://github.com/mautrix/signal" fund = "https://github.com/sponsors/tulir" diff --git a/scripts/_common.sh b/scripts/_common.sh index a39c092..b8fe056 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,10 +4,6 @@ # COMMON VARIABLES #================================================= -signald_data="/var/lib/signald" -signald_exe="/usr/bin/signald" -signald_user="signald" - enable_relaybot=true #================================================= diff --git a/scripts/backup b/scripts/backup index 3486259..d70f34a 100755 --- a/scripts/backup +++ b/scripts/backup @@ -33,7 +33,7 @@ ynh_backup --src_path="/etc/logrotate.d/$app" # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="$signald_data" +# TODO: check if there are some files to backup ynh_backup --src_path="/var/log/$app/" diff --git a/scripts/install b/scripts/install index 93245d5..4244856 100755 --- a/scripts/install +++ b/scripts/install @@ -42,24 +42,17 @@ ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance ynh_app_setting_set --app=$app --key=server_name --value=$server_name ynh_app_setting_set --app=$app --key=mautrix_version --value=$mautrix_version - -# Add the user to the signald group. The signald group was created when the signald -# package was installed from the extra repository -# resolved by https://gitlab.com/signald/signald/-/commit/278240f3f1cc40a3b444c958b68ca3d6908e98a8 -usermod -a -G "$signald_user" "$app" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=3 +ynh_script_progression --message="Setting up source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/src" +ynh_setup_source --dest_dir="$install_dir" -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$install_dir" - -mkdir -p /var/log/$app +chmod 750 "$install_dir" +chmod -R 750 "$install_dir" +chown -R $app:$app "$install_dir" #================================================= # ADD A CONFIGURATION @@ -71,28 +64,15 @@ ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml" chmod 400 "$install_dir/config.yaml" chown "$app:$app" "$install_dir/config.yaml" -#================================================= -# INSTALL MAUTRIX-BRIDGE PYTHON MODULE -#================================================= -ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6 - -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 -fi - -_mautrix_signal_build_venv - #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= ynh_script_progression --message="Registering Synapse app-service" --weight=1 -"$install_dir/venv/bin/python3" -m mautrix_signal -g -c "$install_dir/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml" -"/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh" || ynh_die --message="Synapse can't restart with the appservice configuration" +$install_dir/mautrix-signal -g -c $install_dir/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml +/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration" -chown -R "$app:$app" "$install_dir" +chown -R $app:$app "$install_dir" ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" ynh_store_file_checksum --file="$install_dir/config.yaml" diff --git a/scripts/remove b/scripts/remove index 403f0c0..e1f2321 100755 --- a/scripts/remove +++ b/scripts/remove @@ -48,8 +48,7 @@ ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP OWNED BY \"$a #================================================= ynh_script_progression --message="Removing various files..." --weight=6 -ynh_secure_remove --file="$signald_data" -ynh_secure_remove --file="$signald_exe" +# TODO: check if there is a data dir or some files to remove # Remove a directory securely ynh_secure_remove --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" diff --git a/scripts/restore b/scripts/restore index 778dce8..adcf9e2 100755 --- a/scripts/restore +++ b/scripts/restore @@ -35,32 +35,22 @@ ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" # RESTORE VARIOUS FILES #================================================= -ynh_systemd_action --service_name=signald --action="stop" -ynh_restore_file --origin_path="$signald_data" -ynh_systemd_action --service_name=signald --action="start" +# TODO: check if there are some files to restore ynh_restore_file --origin_path="/var/log/$app/" -#================================================= -# INSTALL MAUTRIX-BRIDGE PYTHON MODULE -#================================================= -ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6 - -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 -fi - -_mautrix_signal_build_venv #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= ynh_script_progression --message="Registering Synapse app-service" --weight=1 -"$install_dir/venv/bin/python3" -m mautrix_signal -g -c "$install_dir/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml" -"/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh" || ynh_die "Synapse can't restart with the appservice configuration" +$install_dir/mautrix-signal -g -c $install_dir/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml +/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration" + +chown -R $app:$app "$install_dir" +ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" +ynh_store_file_checksum --file="$install_dir/config.yaml" #================================================= # RESTORE SYSTEM CONFIGURATIONS diff --git a/scripts/upgrade b/scripts/upgrade index ff3b0da..dc2a81b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,6 +14,13 @@ synapse_db_name="matrix_$synapse_instance" server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name) domain=$(ynh_app_setting_get --app $synapse_instance --key domain) +#================================================= +# CHECK VERSION +#================================================= +ynh_script_progression --message="Checking version..." --weight=1 + +upgrade_type=$(ynh_check_app_version_changed) + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -28,27 +35,47 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Fix possible permission issues with a previous signald version, esp. with stickers -mkdir -p /var/lib/signald/{avatars,attachments,stickers} -chown "$signald_user:$signald_user" /var/lib/signald/{avatars,attachments,stickers} -chmod -R g+rwX /var/lib/signald/{avatars,attachments,stickers} +# 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 + +# Remove signald and its repository + +# Remove signald data + +# Remove signald system user + + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=1 -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/src" --full_replace=1 +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --weight=2 -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$install_dir" + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$install_dir" +fi + +chmod 750 "$install_dir" +chmod -R 750 "$install_dir" +chown -R $app:$app "$install_dir" #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=2 - +echo "botusers=$botusers" if [[ -z "$botusers" ]] || [ "$botusers" == "admin" ]; then if_botusers="# " else @@ -60,29 +87,15 @@ ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml" chmod 400 "$install_dir/config.yaml" chown "$app:$app" "$install_dir/config.yaml" -#================================================= -# UPGRADE MAUTRIX-BRIDGE PYTHON MODULE -#================================================= -ynh_script_progression --message="Upgrading Mautrix-Bridge Python Module..." --weight=2 - -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 -fi - -_mautrix_signal_build_venv - #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= ynh_script_progression --message="Registering Synapse app-service" --weight=1 -"$install_dir/venv/bin/python3" -m mautrix_signal -g -c "$install_dir/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml" -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" +$install_dir/mautrix-signal -g -c $install_dir/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml +/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration" -# Set permissions on app files -chown -R "$app:$app" "$install_dir" +chown -R $app:$app "$install_dir" ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" ynh_store_file_checksum --file="$install_dir/config.yaml" diff --git a/tests.toml b/tests.toml index 07836c8..251be62 100644 --- a/tests.toml +++ b/tests.toml @@ -12,4 +12,4 @@ test_format = 1.0 args.botadmin = "@johndoe:synapsedomain.tld" args.botusers = "synapsedomain.tld" - test_upgrade_from.40c16d3c8898196c6e1a43e8f0af70c052dd41f6.name = "0.2.3~ynh1" + test_upgrade_from.76c28b29e4a9bfed0ef9765d08fc8f58fbd6dd2d.name = "0.4.3~ynh1"