2023-12-30 19:24:43 +01:00
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2024-01-15 08:09:25 +01:00
source _common.sh
2023-12-30 19:24:43 +01:00
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
2024-01-15 08:09:25 +01:00
get__botname() {
botname=$(ynh_app_setting_get --app $app --key botname)
echo "${botname}"
}
2023-12-30 19:24:43 +01:00
2024-01-15 08:09:25 +01:00
get__listuser() {
existingUsers=$(grep -- "\".*: user" "$install_dir/config.yaml" | sed -r 's/: user//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
cat <<EOF
"$existingUsers"
2023-12-30 19:24:43 +01:00
EOF
}
2024-01-15 08:09:25 +01:00
get__listrelay() {
existingRelayUsers=$(grep -- "\".*: relay" "$install_dir/config.yaml" | sed -r 's/: relay//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
cat <<EOF
"$existingRelayUsers"
EOF
2023-12-30 19:24:43 +01:00
}
2024-01-15 08:09:25 +01:00
get__listadmin() {
existingAdmins=$(grep -- "\".*: admin" "$install_dir/config.yaml" | sed -r 's/: admin//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
cat <<EOF
"$existingAdmins"
EOF
}
2023-12-30 19:24:43 +01:00
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
2024-01-15 08:09:25 +01:00
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/username:.*/username: $botname/" "$install_dir/config.yaml"
"$install_dir/$APP_BIN" -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"
2023-12-30 19:24:43 +01:00
}
ynh_app_config_run $1