mirror of
https://github.com/YunoHost-Apps/mautrix_telegram_ynh.git
synced 2024-09-03 19:45:55 +02:00
Merge pull request #62 from YunoHost-Apps/testing
Testing to master [Config panel]
This commit is contained in:
commit
2695958e13
9 changed files with 576 additions and 9 deletions
|
@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
|||
A puppeting bridge between Matrix and Telegram packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Telegram user and a Matrix user. Currently the Matrix user can NOT invite other Matrix user in a bridged Telegram room, so only someone with a Telegram account can participate to Telegram group conversations. The ["Mautrix-Telegram"](https://docs.mau.fi/bridges/python/telegram/index.html) bridge is a Synapse App Service and relies on postgresql. Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand.
|
||||
|
||||
|
||||
**Shipped version:** 0.15.1~ynh1
|
||||
**Shipped version:** 0.15.1~ynh2
|
||||
## Documentation and resources
|
||||
|
||||
* Official app website: <https://docs.mau.fi/bridges/python/telegram/index.html>
|
||||
|
|
|
@ -22,7 +22,7 @@ La passerelle ["Mautrix-Telegram"](https://docs.mau.fi/bridges/python/telegram/i
|
|||
** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix-synapse et mautrix_telegram en même temps!**
|
||||
|
||||
|
||||
**Version incluse :** 0.15.1~ynh1
|
||||
**Version incluse :** 0.15.1~ynh2
|
||||
## Documentations et ressources
|
||||
|
||||
* Site officiel de l’app : <https://docs.mau.fi/bridges/python/telegram/index.html>
|
||||
|
|
|
@ -500,9 +500,9 @@ bridge:
|
|||
# domain - All users on that homeserver
|
||||
# mxid - Specific user
|
||||
permissions:
|
||||
"*": "relaybot"
|
||||
"__BOTUSERS__": "puppeting"
|
||||
"__BOTADMIN__": "admin"
|
||||
"__LISTRELAYBOT__": "relaybot"
|
||||
"__LISTPUPPETING__": "puppeting"
|
||||
"__LISTADMIN__": "admin"
|
||||
# Options related to the message relay Telegram bot.
|
||||
relaybot:
|
||||
private_chat:
|
||||
|
|
200
config_panel.toml
Normal file
200
config_panel.toml
Normal file
|
@ -0,0 +1,200 @@
|
|||
version = "1.0"
|
||||
|
||||
[main]
|
||||
name = "Main Settings"
|
||||
services = ["__APP__"]
|
||||
|
||||
[main.permissions]
|
||||
name = "Permissions for using the bridge"
|
||||
|
||||
[main.permissions.helptext]
|
||||
ask = '''
|
||||
Roles with Increasing Power: Relaybot<User<Puppeting<Full<Admin
|
||||
Allowed values for roles:
|
||||
- * : All Matrix users
|
||||
- domain.tld : All users on a given homeserver
|
||||
- mxid (@user:matrix.org) : Specific Matrix user
|
||||
'''
|
||||
type = "markdown"
|
||||
|
||||
[main.permissions.listrelaybot]
|
||||
ask = "Users bridged thanks to Relay Mode"
|
||||
type = "tags"
|
||||
help = "Relay Role: Talk on Telegram through the RelayBot in a room. No access to commands."
|
||||
|
||||
[main.permissions.listuser]
|
||||
ask = "Bridge Users"
|
||||
type = "tags"
|
||||
help = "User Role: Relaybot level + access to commands to create bridges."
|
||||
|
||||
[main.permissions.listpuppeting]
|
||||
ask = "Bridge Puppeting"
|
||||
type = "tags"
|
||||
help = "Puppeting Role: User level + logging in with a Telegram account."
|
||||
|
||||
[main.permissions.listfull]
|
||||
ask = "Bridge Full"
|
||||
type = "tags"
|
||||
help = "Full Role: Full access to use the bridge, i.e. previous levels + Matrix login."
|
||||
|
||||
[main.permissions.listadmin]
|
||||
ask = "Bridge Administrators"
|
||||
type = "tags"
|
||||
help = "Admin Role: Full access to use the bridge and some extra administration commands."
|
||||
|
||||
[main.bot]
|
||||
name = "Bot Settings"
|
||||
|
||||
[main.bot.bot_username]
|
||||
ask = "Username of the AppService Bot"
|
||||
type = "string"
|
||||
help = "Sets bot username. Please keep in mind that the bot admin room for previous bot username will stop working so you may need to create a new one using the new username"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[main.bot.bot_displayname]
|
||||
ask = "Display name for Bot"
|
||||
type = "string"
|
||||
help = "Set to 'remove' to remove display name, leave empty to set default 'Telegram bridge bot'"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[main.bot.bot_avatar]
|
||||
ask = "Avatar for Bot"
|
||||
type = "string"
|
||||
help = "Should be in format 'mxc://server_name/NeXNQarUbrlYBiPCpprYsRqr', see README for tutorial. Set to 'remove' to remove avatar, leave empty to use standard Telegram logo."
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[privacy]
|
||||
name = "Privacy"
|
||||
services = ["__APP__"]
|
||||
|
||||
[privacy.portal_rooms]
|
||||
name = "Portal Rooms & Encryption Settings"
|
||||
|
||||
[privacy.portal_rooms.text]
|
||||
ask = '''
|
||||
!! Inviting the Bridge in an encrypted room !!
|
||||
!! breaks real End-to-End Encryption (e2ee) !!
|
||||
!! Messages will be unencrypted on the Bridge Server !!
|
||||
'''
|
||||
type = "markdown"
|
||||
|
||||
[privacy.portal_rooms.encryption]
|
||||
ask = "Allow Encryption between Matrix Client and Bridge Server?"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "Enable so-called End-to-Bridge (e2b) Encryption. For the Bridge to work in group chat Rooms with End-to-End Encryption (e2ee) enabled."
|
||||
bind = "encryption>allow:__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[privacy.portal_rooms.encryption_default]
|
||||
ask = "Force-enable Encryption in all Portal Rooms the Bridge creates?"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "This will cause the Bridge Bot to be in private chats for the Encryption to work properly."
|
||||
bind = "encryption>default:__INSTALL_DIR__/config.yaml"
|
||||
visible = "encryption"
|
||||
|
||||
[privacy.portal_rooms.encryption_require]
|
||||
ask = "Require encryption?"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "Require encryption, drop any unencrypted messages."
|
||||
bind = "encryption>require:__INSTALL_DIR__/config.yaml"
|
||||
visible = "encryption"
|
||||
|
||||
[privacy.config]
|
||||
name = "Privacy Settings"
|
||||
|
||||
[privacy.config.delivery_receipts]
|
||||
ask = "Enable Delivery Receipts?"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "Should the bridge send a read Receipt from the bridge bot when a message has been sent to Telegram?"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[privacy.config.telegram_link_preview]
|
||||
ask = "Enable URL Preview?"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "Should the Bridge detect URLs in outgoing messages, ask the HomeServer to generate a Preview, and send it to Telegram?"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced]
|
||||
name = "Advanced Settings"
|
||||
services = ["__APP__"]
|
||||
|
||||
[advanced.help]
|
||||
name = "SETTINGS FOR EXPERTS IN SERVER ADMINISTRATION"
|
||||
|
||||
[advanced.help.text]
|
||||
ask = "!! There are **security and privacy risks** if you change these settings without knowing what you do !!"
|
||||
type = "markdown"
|
||||
|
||||
[advanced.telegram]
|
||||
name = "Telegram API MetaData"
|
||||
|
||||
[advanced.telegram.username_template]
|
||||
ask = "Localpart template of MXIDs for Telegram users"
|
||||
type = "string"
|
||||
help = "Defaults to 'telegram_{userid}'. '{userid}' is replaced with the user ID of the Telegram user"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.telegram.alias_template]
|
||||
ask = "Localpart template of room aliases for Telegram portal rooms"
|
||||
type = "string"
|
||||
help = "Defaults to 'telegram_{groupname}'. '{groupname}' is replaced with the name part of the public channel/group invite link"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.telegram.displayname_template]
|
||||
ask = "Displayname template for Telegram users"
|
||||
type = "string"
|
||||
help = "Defaults to '{displayname} (Telegram)'. '{displayname}' is replaced with the display name of the Telegram user"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.telegram.device_model]
|
||||
ask = "Device info sent to Telegram"
|
||||
type = "string"
|
||||
help = "Defaults to 'mautrix-telegram'. 'auto' would set OS name+version"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.appservice]
|
||||
name = "HomeServer Application Service"
|
||||
|
||||
[advanced.appservice.async_media]
|
||||
ask = "Enable asynchronous media uploads?"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "Enable only if HomeServer supports https://github.com/matrix-org/matrix-spec-proposals/pull/2246"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.appservice.ephemeral_events]
|
||||
ask = "Receive Ephemeral Events via AppService transactions?"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "Enable only if HomeServer supports MSC2409 (i.e. Synapse 1.22+). If enabled, you should disable bridge -> 'sync_with_custom_puppets'."
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.metrics]
|
||||
name = "Prometheus Metrics"
|
||||
|
||||
[advanced.metrics.enable_metrics]
|
||||
ask = "Enable Prometheus Metrics?"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "Requires prometheus-client to be installed"
|
||||
bind = "metrics>enabled:__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.metrics.listen_port]
|
||||
ask = "Port for the Metrics listener?"
|
||||
type = "string"
|
||||
help = "Defaults to: '8000'. The path is always /metrics"
|
||||
bind = "metrics>listen_port:__INSTALL_DIR__/config.yaml"
|
||||
visible = "enable_metrics"
|
||||
|
|
@ -4,9 +4,7 @@ id = "mautrix_telegram"
|
|||
name = "Matrix-Telegram bridge"
|
||||
description.en = "Telegram puppeting bridge for Matrix/Synapse"
|
||||
description.fr = "Passerelle Telegram pour Matrix/Synapse"
|
||||
|
||||
version = "0.15.1~ynh1"
|
||||
|
||||
version = "0.15.1~ynh2"
|
||||
maintainers = ["thardev"]
|
||||
|
||||
[upstream]
|
||||
|
|
|
@ -1,5 +1,76 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# CONFIG PANEL SETTERS
|
||||
#=================================================
|
||||
|
||||
apply_permissions() {
|
||||
set -o noglob # Disable globbing to avoid expansions when passing * as value.
|
||||
declare values="list$role"
|
||||
newValues="${!values}" # Here we expand the dynamic variable we created in the previous line. ! Does the trick
|
||||
newValues="${newValues//\"}"
|
||||
usersArray=(${newValues//,/ }) # Split the values using comma (,) as separator.
|
||||
|
||||
if [ -n "$newValues" ]
|
||||
then
|
||||
#ynh_systemd_action --service_name="$app" --action=stop
|
||||
# Get all entries between "permissions:" and "relay:" keys, remove the role part, remove commented parts, format it with newlines and clean whitespaces and double quotes.
|
||||
allDefinedEntries=$(awk '/permissions:/{flag=1; next} /relaybot:/{flag=0} flag' "$install_dir/config.yaml" | sed "/: $role/d" | sed -r 's/: (admin|user|relaybot|full|puppeting)//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr ',' '\n' )
|
||||
# Delete everything from the corresponding role to insert the new defined values. This way we also handle deletion of users.
|
||||
sed -i "/permissions:/,/relaybot:/{/: $role/d;}" "$install_dir/config.yaml"
|
||||
# Ensure that entries with value surrounded with quotes are deleted too. E.g. "users".
|
||||
sed -i "/permissions:/,/relaybot:/{/: \"$role\"/d;}" "$install_dir/config.yaml"
|
||||
for user in "${usersArray[@]}"
|
||||
do
|
||||
if grep -q -x "${user}" <<< "$allDefinedEntries"
|
||||
then
|
||||
ynh_print_info "User $user already defined in another role."
|
||||
else
|
||||
sed -i "/permissions:/a \ \\\"$user\": $role" "$install_dir/config.yaml" # Whitespaces are needed so that the file can be correctly parsed
|
||||
fi
|
||||
done
|
||||
fi
|
||||
set +o noglob
|
||||
|
||||
ynh_print_info "Users with role $role added in $install_dir/config.yaml"
|
||||
}
|
||||
|
||||
|
||||
set__listrelaybot() {
|
||||
role="relaybot"
|
||||
ynh_app_setting_set --app=$app --key=listrelaybot --value="$listrelaybot"
|
||||
apply_permissions
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
}
|
||||
|
||||
set__listuser() {
|
||||
role="user"
|
||||
ynh_app_setting_set --app=$app --key=listuser --value="$listuser"
|
||||
apply_permissions
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
}
|
||||
|
||||
set__listpuppeting() {
|
||||
role="puppeting"
|
||||
ynh_app_setting_set --app=$app --key=listpuppeting --value="$listpuppeting"
|
||||
apply_permissions
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
}
|
||||
|
||||
set__listfull() {
|
||||
role="full"
|
||||
ynh_app_setting_set --app=$app --key=listfull --value="$listfull"
|
||||
apply_permissions
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
}
|
||||
|
||||
set__listadmin() {
|
||||
role="admin"
|
||||
ynh_app_setting_set --app=$app --key=listadmin --value="$listadmin"
|
||||
apply_permissions
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
|
91
scripts/config
Normal file
91
scripts/config
Normal file
|
@ -0,0 +1,91 @@
|
|||
#!/bin/bash
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||
#=================================================
|
||||
|
||||
get_config_permission() {
|
||||
result=$(grep -- ".*: $role" "$install_dir/config.yaml" | sed -r "s/: $role//" | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr -d "'" | tr '\n' ',')
|
||||
echo $result
|
||||
}
|
||||
|
||||
get__botname() {
|
||||
botname=$(ynh_app_setting_get --app $app --key botname)
|
||||
echo "${botname}"
|
||||
}
|
||||
|
||||
get__listrelaybot() {
|
||||
role="relaybot"
|
||||
existingRelaybotUsers=$(get_config_permission)
|
||||
|
||||
cat <<EOF
|
||||
"$existingRelaybotUsers"
|
||||
EOF
|
||||
}
|
||||
|
||||
get__listuser() {
|
||||
role="user"
|
||||
existingUsers=$(get_config_permission)
|
||||
|
||||
cat <<EOF
|
||||
"$existingUsers"
|
||||
EOF
|
||||
}
|
||||
|
||||
get__listpuppeting() {
|
||||
role="puppeting"
|
||||
existingPuppeting=$(get_config_permission)
|
||||
|
||||
cat <<EOF
|
||||
"$existingPuppeting"
|
||||
EOF
|
||||
}
|
||||
|
||||
get__listfull() {
|
||||
role="full"
|
||||
existingFull=$(get_config_permission)
|
||||
|
||||
cat <<EOF
|
||||
"$existingFull"
|
||||
EOF
|
||||
}
|
||||
|
||||
get__listadmin() {
|
||||
role="admin"
|
||||
existingAdmins=$(get_config_permission)
|
||||
|
||||
cat <<EOF
|
||||
"$existingAdmins"
|
||||
EOF
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
|
||||
set__botname() {
|
||||
old_botname=$(ynh_app_setting_get --app $app --key botname)
|
||||
if [ "$botname" -eq "$old_botname" ] # Check to avoid updating botname when it's not needed.
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
ynh_app_setting_set --app=$app --key=botname --value="$botname"
|
||||
synapse_instance=$(ynh_app_setting_get --app $app --key synapse_instance)
|
||||
|
||||
sed -i "s/bot_username:.*/bot_username: $botname/" "$install_dir/config.yaml"
|
||||
"$install_dir/mautrix-whatsapp" -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"
|
||||
}
|
||||
|
||||
ynh_app_config_run $1
|
|
@ -21,6 +21,50 @@ ynh_app_setting_set --app=$app --key=server_name --value=$server_name
|
|||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=appserviceid --value=$appserviceid
|
||||
|
||||
#=================================================
|
||||
# SET STANDARD SETTINGS FROM DEFAULT CONFIG
|
||||
#=================================================
|
||||
|
||||
appserviceid=$app
|
||||
async_media="false"
|
||||
bot_username="$botname"
|
||||
bot_displayname="Telegram bridge bot"
|
||||
bot_avatar="mxc://maunium.net/tJCRmUyJDsgRNgqhOgoiHWbX"
|
||||
device_model="mautrix-telegram"
|
||||
ephemeral_events="false"
|
||||
enable_metrics="false"
|
||||
listen_port="8000"
|
||||
alias_template="telegram_{userid}"
|
||||
displayname_template="{displayname} (Telegram)"
|
||||
username_template="telegram_{userid}"
|
||||
delivery_receipts="false"
|
||||
telegram_link_preview="false"
|
||||
encryption_default="false"
|
||||
encryption_require="false"
|
||||
listrelaybot="*"
|
||||
listuser=""
|
||||
listpuppeting="$botusers"
|
||||
listfull=""
|
||||
listadmin="$botadmin"
|
||||
|
||||
ynh_app_setting_set --app=$app --key=appserviceid --value=$appserviceid
|
||||
ynh_app_setting_set --app=$app --key=async_media --value=$async_media
|
||||
ynh_app_setting_set --app=$app --key=bot_displayname --value=$bot_displayname
|
||||
ynh_app_setting_set --app=$app --key=bot_username --value=$bot_username
|
||||
ynh_app_setting_set --app=$app --key=bot_avatar --value=$bot_avatar
|
||||
ynh_app_setting_set --app=$app --key=device_model --value=$device_model
|
||||
ynh_app_setting_set --app=$app --key=ephemeral_events --value=$ephemeral_events
|
||||
ynh_app_setting_set --app=$app --key=enable_metrics --value=$enable_metrics
|
||||
ynh_app_setting_set --app=$app --key=listen_port --value=$listen_port
|
||||
ynh_app_setting_set --app=$app --key=alias_template --value=$alias_template
|
||||
ynh_app_setting_set --app=$app --key=displayname_template --value=$displayname_template
|
||||
ynh_app_setting_set --app=$app --key=username_template --value=$username_template
|
||||
ynh_app_setting_set --app=$app --key=delivery_receipts --value=$delivery_receipts
|
||||
ynh_app_setting_set --app=$app --key=telegram_link_preview --value=$telegram_link_preview
|
||||
ynh_app_setting_set --app=$app --key=encryption_default --value=$encryption_default
|
||||
ynh_app_setting_set --app=$app --key=encryption_require --value=$encryption_require
|
||||
ynh_app_setting_set --app=$app --key=listrelaybot --value=$listrelaybot
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -60,6 +104,13 @@ ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
|
|||
chmod 400 "$install_dir/config.yaml"
|
||||
chown $app:$app "$install_dir/config.yaml"
|
||||
|
||||
# This calls allows to set multiple users during install question "botusers" specifying them separated by a comma
|
||||
set__listrelaybot
|
||||
set__listuser
|
||||
set__listpuppeting
|
||||
set__listfull
|
||||
set__listadmin
|
||||
|
||||
#=================================================
|
||||
# INSTALL MAUTRIX-BRIDGE PYTHON MODULE
|
||||
#=================================================
|
||||
|
@ -70,7 +121,7 @@ mkdir -p /var/log/$app
|
|||
python3 -m venv $install_dir
|
||||
export HOME=$install_dir
|
||||
$install_dir/bin/pip3 install --upgrade pip setuptools wheel
|
||||
$install_dir/bin/pip3 install --upgrade $install_dir/src/mautrix-telegram.tar.gz[e2be,speedups,qr_login] # metrics,hq_thumbnails,sqlite,formattednumbers
|
||||
$install_dir/bin/pip3 install --upgrade $install_dir/src/mautrix-telegram.tar.gz[e2be,speedups] # metrics,hq_thumbnails,sqlite,formattednumbers
|
||||
|
||||
#=================================================
|
||||
# REGISTER SYNAPSE APP-SERVICE
|
||||
|
|
156
scripts/upgrade
156
scripts/upgrade
|
@ -12,6 +12,31 @@ source /usr/share/yunohost/helpers
|
|||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
|
||||
#=================================================
|
||||
# GET CONFIG PANEL SETTINGS
|
||||
#=================================================
|
||||
async_media=$(ynh_app_setting_get --app=$app --key=async_media)
|
||||
bot_displayname=$(ynh_app_setting_get --app=$app --key=bot_displayname)
|
||||
bot_username=$(ynh_app_setting_get --app=$app --key=bot_username)
|
||||
bot_avatar=$(ynh_app_setting_get --app=$app --key=bot_avatar)
|
||||
device_model=$(ynh_app_setting_get --app=$app --key=device_model)
|
||||
ephemeral_events=$(ynh_app_setting_get --app=$app --key=ephemeral_events)
|
||||
enable_metrics=$(ynh_app_setting_get --app=$app --key=enable_metrics)
|
||||
listen_port=$(ynh_app_setting_get --app=$app --key=listen_port)
|
||||
alias_template=$(ynh_app_setting_get --app=$app --key=alias_template)
|
||||
displayname_template=$(ynh_app_setting_get --app=$app --key=displayname_template)
|
||||
username_template=$(ynh_app_setting_get --app=$app --key=username_template)
|
||||
delivery_receipts=$(ynh_app_setting_get --app=$app --key=delivery_receipts)
|
||||
telegram_link_preview=$(ynh_app_setting_get --app=$app --key=telegram_link_preview)
|
||||
encryption_default=$(ynh_app_setting_get --app=$app --key=encryption_default)
|
||||
encryption_require=$(ynh_app_setting_get --app=$app --key=encryption_require)
|
||||
|
||||
listrelaybot=$(ynh_app_setting_get --app=$app --key=listrelaybot)
|
||||
listuser=$(ynh_app_setting_get --app=$app --key=listuser)
|
||||
listpuppeting=$(ynh_app_setting_get --app=$app --key=listpuppeting)
|
||||
listfull=$(ynh_app_setting_get --app=$app --key=listfull)
|
||||
listadmin=$(ynh_app_setting_get --app=$app --key=listadmin)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
@ -56,6 +81,112 @@ then
|
|||
ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SET STANDARD SETTINGS FROM DEFAULT CONFIG
|
||||
#=================================================
|
||||
|
||||
if [ -z "$async_media" ]
|
||||
then
|
||||
async_media="false"
|
||||
ynh_app_setting_set --app=$app --key=async_media --value=$async_media
|
||||
fi
|
||||
if [ -z "$bot_username" ]
|
||||
then
|
||||
bot_username="$botname"
|
||||
ynh_app_setting_set --app=$app --key=bot_username --value=$bot_username
|
||||
fi
|
||||
if [ -z "$bot_displayname" ]
|
||||
then
|
||||
bot_displayname="Telegram bridge bot"
|
||||
ynh_app_setting_set --app=$app --key=bot_displayname --value=$bot_displayname
|
||||
fi
|
||||
if [ -z "$bot_avatar" ]
|
||||
then
|
||||
bot_avatar="mxc://maunium.net/tJCRmUyJDsgRNgqhOgoiHWbX"
|
||||
ynh_app_setting_set --app=$app --key=bot_avatar --value=$bot_avatar
|
||||
fi
|
||||
if [ -z "$device_model" ]
|
||||
then
|
||||
device_model="mautrix-telegram"
|
||||
ynh_app_setting_set --app=$app --key=device_model --value=$device_model
|
||||
fi
|
||||
if [ -z "$ephemeral_events" ]
|
||||
then
|
||||
ephemeral_events="false"
|
||||
ynh_app_setting_set --app=$app --key=ephemeral_events --value=$ephemeral_events
|
||||
fi
|
||||
if [ -z "$enable_metrics" ]
|
||||
then
|
||||
enable_metrics="false"
|
||||
ynh_app_setting_set --app=$app --key=enable_metrics --value=$enable_metrics
|
||||
fi
|
||||
if [ -z "$listen_port" ]
|
||||
then
|
||||
listen_port="8000"
|
||||
ynh_app_setting_set --app=$app --key=listen_port --value=$listen_port
|
||||
fi
|
||||
if [ -z "$alias_template" ]
|
||||
then
|
||||
alias_template="telegram_{userid}"
|
||||
ynh_app_setting_set --app=$app --key=alias_template --value=$alias_template
|
||||
fi
|
||||
if [ -z "$displayname_template" ]
|
||||
then
|
||||
displayname_template="{displayname} (Telegram)"
|
||||
ynh_app_setting_set --app=$app --key=displayname_template --value=$displayname_template
|
||||
fi
|
||||
if [ -z "$username_template" ]
|
||||
then
|
||||
username_template="telegram_{userid}"
|
||||
ynh_app_setting_set --app=$app --key=username_template --value=$username_template
|
||||
fi
|
||||
if [ -z "$delivery_receipts" ]
|
||||
then
|
||||
delivery_receipts="false"
|
||||
ynh_app_setting_set --app=$app --key=delivery_receipts --value=$delivery_receipts
|
||||
fi
|
||||
if [ -z "$telegram_link_preview" ]
|
||||
then
|
||||
telegram_link_preview="false"
|
||||
ynh_app_setting_set --app=$app --key=telegram_link_preview --value=$telegram_link_preview
|
||||
fi
|
||||
if [ -z "$encryption_default" ]
|
||||
then
|
||||
encryption_default="false"
|
||||
ynh_app_setting_set --app=$app --key=encryption_default --value=$encryption_default
|
||||
fi
|
||||
if [ -z "$encryption_require" ]
|
||||
then
|
||||
encryption_require="false"
|
||||
ynh_app_setting_set --app=$app --key=encryption_require --value=$encryption_require
|
||||
fi
|
||||
if [ -z "$listrelaybot" ]
|
||||
then
|
||||
listrelaybot="*"
|
||||
ynh_app_setting_set --app=$app --key=listrelaybot --value=$listrelaybot
|
||||
fi
|
||||
if [ -z "$listuser" ]
|
||||
then
|
||||
listuser=""
|
||||
ynh_app_setting_set --app=$app --key=listuser --value=$listuser
|
||||
fi
|
||||
if [ -z "$listpuppeting" ]
|
||||
then
|
||||
listpuppeting=$(ynh_app_setting_get --app=$app --key=botusers)
|
||||
ynh_app_setting_set --app=$app --key=listpuppeting --value=$listpuppeting
|
||||
ynh_app_setting_delete --app=$app --key=botusers
|
||||
fi
|
||||
if [ -z "$listfull" ]
|
||||
then
|
||||
listfull=""
|
||||
ynh_app_setting_set --app=$app --key=listfull --value=$listfull
|
||||
fi
|
||||
if [ -z "$listadmin" ]
|
||||
then
|
||||
listadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
|
||||
ynh_app_setting_set --app=$app --key=listadmin --value=$listadmin
|
||||
ynh_app_setting_delete --app=$app --key=botadmin
|
||||
fi
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -79,6 +210,18 @@ chown -R $app:$app "$install_dir"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=2
|
||||
|
||||
# reset permissions to be able to apply_permissions with app_setting values after upgrade
|
||||
listrelaybot_=$listrelaybot
|
||||
listuser_=$listuser
|
||||
listpuppeting_=$listpuppeting
|
||||
listfull_=$listfull
|
||||
listadmin_=$listadmin
|
||||
listrelaybot="*"
|
||||
listuser="@user:domain.tld"
|
||||
listpuppeting="@puppet:domain.tld"
|
||||
listfull="@full:domain.tld"
|
||||
listadmin="@admin:domain.tld"
|
||||
|
||||
# main configuration
|
||||
ynh_backup_if_checksum_is_different --file="$install_dir/config.yaml"
|
||||
# as_token hs_token are autogenerated, save them before regenerating the config
|
||||
|
@ -95,6 +238,19 @@ ynh_add_config --template="../conf/config.yaml" --destination="$install_dir/conf
|
|||
chmod 400 "$install_dir/config.yaml"
|
||||
chown $app:$app "$install_dir/config.yaml"
|
||||
|
||||
listrelaybot=$listrelaybot_
|
||||
listuser=$listuser_
|
||||
listpuppeting=$listpuppeting_
|
||||
listfull=$listfull_
|
||||
listadmin=$listadmin_
|
||||
|
||||
# apply_permissions to have correct syntax in config file
|
||||
set__listrelaybot
|
||||
set__listuser
|
||||
set__listpuppeting
|
||||
set__listfull
|
||||
set__listadmin
|
||||
|
||||
#=================================================
|
||||
# UPGRADE MAUTRIX-BRIDGE PYTHON MODULE
|
||||
#=================================================
|
||||
|
|
Loading…
Reference in a new issue