2018-08-03 16:06:29 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Stop script if errors
|
|
|
|
ynh_abort_if_errors
|
2023-04-18 22:48:23 +02:00
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
|
|
|
|
|
|
get__max_upload_size() {
|
|
|
|
max_upload_size=$(ynh_app_setting_get --app $app --key max_upload_size)
|
|
|
|
echo "${max_upload_size}"
|
|
|
|
}
|
|
|
|
|
|
|
|
set__max_upload_size() {
|
|
|
|
ynh_write_var_in_file --file=/etc/matrix-$app/homeserver.yaml --key=max_upload_size --value="${max_upload_size}"
|
2023-06-29 10:39:25 +02:00
|
|
|
sed -i -r "s|client_max_body_size\s[[:digit:]]*[GMK]?;|client_max_body_size ${max_upload_size};|g" "/etc/nginx/conf.d/$domain.d/$app.conf
|
2023-04-18 22:48:23 +02:00
|
|
|
ynh_add_nginx_conf
|
|
|
|
}
|
2018-08-03 16:06:29 +02:00
|
|
|
|
2023-06-29 16:09:16 +02:00
|
|
|
get__registrations_require_3pid() {
|
|
|
|
max_upload_size=$(ynh_app_setting_get --app $app --key registrations_require_3pid)
|
|
|
|
echo "${registrations_require_3pid}"
|
|
|
|
}
|
|
|
|
|
|
|
|
set__registrations_require_3pid() {
|
2023-07-01 10:25:47 +02:00
|
|
|
# sed -z do the trick on this king of multline replacement
|
2023-06-29 16:09:16 +02:00
|
|
|
case ${registrations_require_3pid} in
|
|
|
|
email)
|
2023-07-01 10:25:47 +02:00
|
|
|
|
|
|
|
sed -i -z -r "s|#?([^\S\n]*registrations_require_3pid:\n)#?([^\S\n]*-[^\S\n]*email\n)#?([^\S\n]*-[^\S\n]*msisdn)|\1\2#\3|" "/etc/matrix-$app/homeserver.yaml"
|
2023-06-29 16:09:16 +02:00
|
|
|
;;
|
|
|
|
msisdn)
|
2023-07-01 10:25:47 +02:00
|
|
|
sed -i -z -r "s|#?([^\S\n]*registrations_require_3pid:\n)#?([^\S\n]*-[^\S\n]*email\n)#?([^\S\n]*-[^\S\n]*msisdn)|\1#\2\3|" "/etc/matrix-$app/homeserver.yaml"
|
2023-06-29 16:09:16 +02:00
|
|
|
;;
|
|
|
|
email&msisdn)
|
2023-07-01 10:25:47 +02:00
|
|
|
sed -i -z -r "s|#?([^\S\n]*registrations_require_3pid:\n)#?([^\S\n]*-[^\S\n]*email\n)#?([^\S\n]*-[^\S\n]*msisdn)|\1\2\3|" "/etc/matrix-$app/homeserver.yaml"
|
2023-06-29 16:09:16 +02:00
|
|
|
;;
|
|
|
|
*)
|
2023-07-01 10:25:47 +02:00
|
|
|
sed -i -z -r "s|#?([^\S\n]*registrations_require_3pid:\n)#?([^\S\n]*-[^\S\n]*email\n)#?([^\S\n]*-[^\S\n]*msisdn)|#\1#\2#\3|" "/etc/matrix-$app/homeserver.yaml"
|
2023-06-29 16:09:16 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
ynh_app_setting_set --app=$app --key=registrations_require_3pid --value="${registrations_require_3pid}"
|
|
|
|
}
|
|
|
|
|
|
|
|
get__allowed_local_3pids_email() {
|
|
|
|
max_upload_size=$(ynh_app_setting_get --app $app --key allowed_local_3pids_email)
|
|
|
|
echo "${allowed_local_3pids_email}"
|
|
|
|
}
|
|
|
|
|
|
|
|
set__allowed_local_3pids_email() {
|
2023-07-01 11:27:41 +02:00
|
|
|
if [ -z ${registrations_require_3pid} ] ; then
|
|
|
|
sed -i -z -r "s|#?([^\S\n]*allowed_local_3pids:\n)#?([^\S\n]*-[^\S\n]*medium: email\n)#?([^\S\n]*pattern:[^\S\n]*')([^']*)('\n)#?([^\S\n]*-[^\S\n]*medium: msisdn\n)#?([^\S\n]*pattern: ')([^']*)('?)|#\1#\2#\3\4\5#\6#\7\8\9|" "/etc/matrix-$app/homeserver.yaml"
|
|
|
|
else
|
|
|
|
sed -i -z -r "s|#?([^\S\n]*allowed_local_3pids:\n)#?([^\S\n]*-[^\S\n]*medium: email\n)#?([^\S\n]*pattern:[^\S\n]*')([^']*)('\n)#?([^\S\n]*-[^\S\n]*medium: msisdn\n)#?([^\S\n]*pattern: ')([^']*)('?)|\1#\2#\3EMAIL\5#\6#\7\8\9|" "/etc/matrix-$app/homeserver.yaml"
|
2023-07-02 20:47:44 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
ynh_app_setting_set --app=$app --key=allowed_local_3pids_email --value="${allowed_local_3pids_email}"
|
2023-07-01 11:27:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
get__allowed_local_3pids_msisdn() {
|
|
|
|
max_upload_size=$(ynh_app_setting_get --app $app --key allowed_local_3pids_msisdn)
|
|
|
|
echo "${allowed_local_3pids_msisdn}"
|
|
|
|
}
|
2023-06-29 16:09:16 +02:00
|
|
|
|
2023-07-01 11:27:41 +02:00
|
|
|
set__allowed_local_3pids_msisdn() {
|
|
|
|
if [ -z ${registrations_require_3pid} ] ; then
|
|
|
|
sed -i -z -r "s|#?([^\S\n]*allowed_local_3pids:\n)#?([^\S\n]*-[^\S\n]*medium: email\n)#?([^\S\n]*pattern:[^\S\n]*')([^']*)('\n)#?([^\S\n]*-[^\S\n]*medium: msisdn\n)#?([^\S\n]*pattern: ')([^']*)('?)|#\1#\2#\3\4\5#\6#\7\8\9|" "/etc/matrix-$app/homeserver.yaml"
|
|
|
|
else
|
|
|
|
sed -i -z -r "s|#?([^\S\n]*allowed_local_3pids:\n)#?([^\S\n]*-[^\S\n]*medium: email\n)#?([^\S\n]*pattern:[^\S\n]*')([^']*)('\n)#?([^\S\n]*-[^\S\n]*medium: msisdn\n)#?([^\S\n]*pattern: ')([^']*)('?)|\1#\2#\3\4\5#\6#\7MSISDN\9|" "/etc/matrix-$app/homeserver.yaml"
|
2023-07-02 20:47:44 +02:00
|
|
|
fi
|
|
|
|
ynh_app_setting_set --app=$app --key=allowed_local_3pids_msisdn --value="${allowed_local_3pids_msisdn}"
|
2023-06-29 16:09:16 +02:00
|
|
|
}
|
|
|
|
|
2023-07-01 16:07:50 +02:00
|
|
|
get__auto_join_rooms() {
|
|
|
|
max_upload_size=$(ynh_app_setting_get --app $app --key auto_join_rooms)
|
|
|
|
echo "${auto_join_rooms}"
|
|
|
|
}
|
|
|
|
|
|
|
|
set__auto_join_rooms() {
|
2023-06-29 16:09:16 +02:00
|
|
|
|
2023-07-01 16:07:50 +02:00
|
|
|
if [ -z ${auto_join_rooms} ] ; then
|
|
|
|
# remove all values comment header ans example value
|
|
|
|
sed -i -z -r "s|#?([^\S\n]*auto_join_rooms:\n)#?([^\S\n]*-[^\S\n]*"[^\"]*"\n)*|#\1# - "#example:example.com"\n\n|" "/etc/matrix-$app/homeserver.yaml"
|
|
|
|
else
|
|
|
|
|
|
|
|
IFS=' ' read -r -a arrroom <<< "${auto_join_rooms}";
|
|
|
|
|
|
|
|
# print header then all space separated values
|
|
|
|
myregex='s|#?([^\S\n]*auto_join_rooms:)#?([^\S\n]*-[^\S\n]*"[^\"]*"\n)*|#\1';
|
|
|
|
for room in "${arrroom[@]}"; do
|
|
|
|
myregex="${myregex}\n - ${room}";
|
|
|
|
done;
|
|
|
|
myregex="${myregex}\n\n|";
|
|
|
|
sed -i -z -r "${myregex}" "/etc/matrix-$app/homeserver.yaml"
|
|
|
|
fi
|
2023-07-02 20:47:44 +02:00
|
|
|
|
|
|
|
ynh_app_setting_set --app=$app --key=auto_join_rooms --value="${auto_join_rooms}"
|
2023-07-01 16:07:50 +02:00
|
|
|
}
|
2023-07-01 10:25:47 +02:00
|
|
|
|
2018-08-03 16:06:29 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
|
|
|
|
#=================================================
|
2023-01-11 15:02:48 +01:00
|
|
|
ynh_app_config_run $1
|