mirror of
https://github.com/YunoHost-Apps/mautrix_signal_ynh.git
synced 2024-09-03 19:46:07 +02:00
chg: continue to make needed changes for
this python-->go upgrade
This commit is contained in:
parent
3f2db7ea34
commit
5a2771bd00
9 changed files with 61 additions and 83 deletions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -4,10 +4,6 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
signald_data="/var/lib/signald"
|
||||
signald_exe="/usr/bin/signald"
|
||||
signald_user="signald"
|
||||
|
||||
enable_relaybot=true
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -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/"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=2
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir/src" --full_replace=1
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
fi
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue