mirror of
https://github.com/YunoHost-Apps/synapse_ynh.git
synced 2024-09-03 20:26:38 +02:00
Factorize variable initalization
This commit is contained in:
parent
5cfb69ce78
commit
4a5841baff
3 changed files with 170 additions and 199 deletions
|
@ -92,28 +92,170 @@ configure_nginx() {
|
|||
ynh_add_nginx_config
|
||||
}
|
||||
|
||||
set_permissions() {
|
||||
chown $app:$app -R $code_dir
|
||||
chmod o= -R $code_dir
|
||||
ensure_vars_set() {
|
||||
if [ -z "${report_stats:-}" ]; then
|
||||
report_stats=false
|
||||
ynh_app_setting_set --app="$app" --key=report_stats --value="$report_stats"
|
||||
fi
|
||||
if [ -z "${e2e_enabled_by_default:-}" ] ; then
|
||||
e2e_enabled_by_default=invite
|
||||
ynh_app_setting_set --app="$app" --key=e2e_enabled_by_default --value="$e2e_enabled_by_default"
|
||||
fi
|
||||
|
||||
chmod 770 $code_dir/Coturn_config_rotate.sh
|
||||
chmod 700 $code_dir/update_synapse_for_appservice.sh
|
||||
chmod 700 $code_dir/set_admin_user.sh
|
||||
if [ -z "${web_client_location:-}" ]
|
||||
then
|
||||
web_client_location="https://matrix.to/"
|
||||
|
||||
element_instance=element
|
||||
if yunohost --output-as plain app list | grep -q "^$element_instance"'$'; then
|
||||
element_domain=$(ynh_app_setting_get --app $element_instance --key domain)
|
||||
element_path=$(ynh_app_setting_get --app $element_instance --key path)
|
||||
web_client_location="https://""$element_domain""$element_path"
|
||||
fi
|
||||
ynh_app_setting_set --app="$app" --key=web_client_location --value="$web_client_location"
|
||||
fi
|
||||
if [ -z "${client_base_url:-}" ]
|
||||
then
|
||||
client_base_url="$web_client_location"
|
||||
ynh_app_setting_set --app="$app" --key=client_base_url --value="$client_base_url"
|
||||
fi
|
||||
if [ -z "${invite_client_location:-}" ]
|
||||
then
|
||||
invite_client_location="$web_client_location"
|
||||
ynh_app_setting_set --app="$app" --key=invite_client_location --value="$invite_client_location"
|
||||
fi
|
||||
|
||||
if [ -z "${allow_public_rooms_without_auth:-}" ]
|
||||
then
|
||||
allow_public_rooms_without_auth=${allow_public_rooms:-false}
|
||||
ynh_app_setting_set --app="$app" --key=allow_public_rooms_without_auth --value="$allow_public_rooms_without_auth"
|
||||
fi
|
||||
if [ -z "${allow_public_rooms_over_federation:-}" ]
|
||||
then
|
||||
allow_public_rooms_over_federation=${allow_public_rooms:-false}
|
||||
ynh_app_setting_set --app="$app" --key=allow_public_rooms_over_federation --value="$allow_public_rooms_over_federation"
|
||||
fi
|
||||
if [ -z "${max_upload_size:-}" ]
|
||||
then
|
||||
max_upload_size=100M
|
||||
ynh_app_setting_set --app="$app" --key=max_upload_size --value="$max_upload_size"
|
||||
fi
|
||||
if [ -z "${disable_msisdn_registration:-}" ]
|
||||
then
|
||||
disable_msisdn_registration=true
|
||||
ynh_app_setting_set --app="$app" --key=disable_msisdn_registration --value=$disable_msisdn_registration
|
||||
fi
|
||||
if [ -z "${account_threepid_delegates_msisdn:-}" ]
|
||||
then
|
||||
account_threepid_delegates_msisdn=''
|
||||
ynh_app_setting_set --app="$app" --key=account_threepid_delegates_msisdn --value="$account_threepid_delegates_msisdn"
|
||||
fi
|
||||
|
||||
if [ -z "${registrations_require_3pid:-}" ]
|
||||
then
|
||||
registrations_require_3pid=email
|
||||
ynh_app_setting_set --app="$app" --key=registrations_require_3pid --value="$registrations_require_3pid"
|
||||
fi
|
||||
if [ -z "${allowed_local_3pids_email:-}" ]
|
||||
then
|
||||
allowed_local_3pids_email=''
|
||||
ynh_app_setting_set --app="$app" --key=allowed_local_3pids_email --value="$allowed_local_3pids_email"
|
||||
fi
|
||||
if [ -z "${allowed_local_3pids_msisdn:-}" ]
|
||||
then
|
||||
allowed_local_3pids_msisdn=''
|
||||
ynh_app_setting_set --app="$app" --key=allowed_local_3pids_msisdn --value="$allowed_local_3pids_msisdn"
|
||||
fi
|
||||
if [ -z "${account_threepid_delegates_msisdn:-}" ]
|
||||
then
|
||||
account_threepid_delegates_msisdn=""
|
||||
ynh_app_setting_set --app="$app" --key=account_threepid_delegates_msisdn --value="$account_threepid_delegates_msisdn"
|
||||
fi
|
||||
|
||||
if [ -z "${allow_guest_access:-}" ]
|
||||
then
|
||||
allow_guest_access=false
|
||||
ynh_app_setting_set --app="$app" --key=allow_guest_access --value="$allow_guest_access"
|
||||
fi
|
||||
if [ -z "${default_identity_server:-}" ]
|
||||
then
|
||||
default_identity_server='https://matrix.org'
|
||||
ynh_app_setting_set --app=$app --key=default_identity_server --value="$default_identity_server"
|
||||
fi
|
||||
|
||||
if [ -z "${auto_join_rooms:-}" ]
|
||||
then
|
||||
auto_join_rooms=''
|
||||
ynh_app_setting_set --app="$app" --key=auto_join_rooms --value="$auto_join_rooms"
|
||||
fi
|
||||
if [ -z "${autocreate_auto_join_rooms:-}" ]
|
||||
then
|
||||
autocreate_auto_join_rooms=false
|
||||
ynh_app_setting_set --app="$app" --key=autocreate_auto_join_rooms --value="$autocreate_auto_join_rooms"
|
||||
fi
|
||||
if [ -z "${auto_join_rooms_for_guests:-}" ]
|
||||
then
|
||||
auto_join_rooms_for_guests=true
|
||||
ynh_app_setting_set --app="$app" --key=auto_join_rooms_for_guests --value="$auto_join_rooms_for_guests"
|
||||
fi
|
||||
|
||||
if [ -z "${enable_notifs:-}" ]
|
||||
then
|
||||
enable_notifs=true
|
||||
ynh_app_setting_set --app="$app" --key=enable_notifs --value="$enable_notifs"
|
||||
fi
|
||||
if [ -z "${notif_for_new_users:-}" ]
|
||||
then
|
||||
notif_for_new_users=true
|
||||
ynh_app_setting_set --app="$app" --key=notif_for_new_users --value="$notif_for_new_users"
|
||||
fi
|
||||
if [ -z "${enable_group_creation:-}" ]
|
||||
then
|
||||
enable_group_creation=true
|
||||
ynh_app_setting_set --app="$app" --key=enable_group_creation --value="$enable_group_creation"
|
||||
fi
|
||||
|
||||
if [ -z "${enable_3pid_lookup:-}" ]
|
||||
then
|
||||
enable_3pid_lookup=false
|
||||
ynh_app_setting_set --app="$app" --key=enable_3pid_lookup --value="$enable_3pid_lookup"
|
||||
fi
|
||||
|
||||
if [ -z "${push_include_content:-}" ]
|
||||
then
|
||||
push_include_content=true
|
||||
ynh_app_setting_set --app="$app" --key=push_include_content --value="$push_include_content"
|
||||
fi
|
||||
|
||||
if [ -z "${enable_dtls_for_audio_video_turn_call:-}" ]
|
||||
then
|
||||
enable_dtls_for_audio_video_turn_call=true
|
||||
ynh_app_setting_set --app="$app" --key=enable_dtls_for_audio_video_turn_call --value="$enable_dtls_for_audio_video_turn_call"
|
||||
fi
|
||||
}
|
||||
|
||||
set_permissions() {
|
||||
chown $app:$app -R "$code_dir"
|
||||
chmod o= -R "$code_dir"
|
||||
|
||||
chmod 770 "$code_dir"/Coturn_config_rotate.sh
|
||||
chmod 700 "$code_dir"/update_synapse_for_appservice.sh
|
||||
chmod 700 "$code_dir"/set_admin_user.sh
|
||||
|
||||
if [ "${1:-}" == data ]; then
|
||||
find $data_dir \( \! -perm -o= \
|
||||
-o \! -user $app \
|
||||
-o \! -group $app \) \
|
||||
-exec chown $app:$app {} \; \
|
||||
find "$data_dir" \( \! -perm -o= \
|
||||
-o \! -user "$app" \
|
||||
-o \! -group "$app" \) \
|
||||
-exec chown "$app:$app" {} \; \
|
||||
-exec chmod o= {} \;
|
||||
fi
|
||||
|
||||
chown $app:$app -R /etc/matrix-$app
|
||||
chmod u=rwX,g=rX,o= -R /etc/matrix-$app
|
||||
setfacl -R -m user:turnserver:rX /etc/matrix-$app
|
||||
chown "$app:$app" -R /etc/matrix-"$app"
|
||||
chmod u=rwX,g=rX,o= -R /etc/matrix-"$app"
|
||||
setfacl -R -m user:turnserver:rX /etc/matrix-"$app"
|
||||
|
||||
chmod 600 /etc/matrix-$app/$server_name.signing.key
|
||||
chmod 600 /etc/matrix-"$app"/"$server_name".signing.key
|
||||
|
||||
chown $app:root -R /var/log/matrix-$app
|
||||
setfacl -R -m user:turnserver:rwX /var/log/matrix-$app
|
||||
chown "$app":root -R /var/log/matrix-"$app"
|
||||
setfacl -R -m user:turnserver:rwX /var/log/matrix-"$app"
|
||||
}
|
||||
|
|
|
@ -23,76 +23,19 @@ fi
|
|||
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
|
||||
report_stats="false"
|
||||
e2e_enabled_by_default="off"
|
||||
allow_public_rooms_without_auth="false"
|
||||
allow_public_rooms_over_federation="false"
|
||||
max_upload_size="100M"
|
||||
disable_msisdn_registration="true"
|
||||
registrations_require_3pid=email
|
||||
allowed_local_3pids_email=""
|
||||
allowed_local_3pids_msisdn=""
|
||||
allow_guest_access="false"
|
||||
account_threepid_delegates_msisdn=""
|
||||
default_identity_server="https://matrix.org"
|
||||
auto_join_rooms=""
|
||||
autocreate_auto_join_rooms="false"
|
||||
auto_join_rooms_for_guests="true"
|
||||
enable_notifs="true"
|
||||
notif_for_new_users="true"
|
||||
enable_group_creation="true"
|
||||
push_include_content="true"
|
||||
enable_3pid_lookup=false
|
||||
enable_dtls_for_audio_video_turn_call=true
|
||||
ensure_vars_set
|
||||
|
||||
if [ "$is_free_registration" -eq 0 ]
|
||||
then
|
||||
enable_registration="false"
|
||||
password_enabled="false"
|
||||
enable_registration=false
|
||||
password_enabled=false
|
||||
else
|
||||
enable_registration="true"
|
||||
password_enabled="true"
|
||||
enable_registration=true
|
||||
password_enabled=true
|
||||
fi
|
||||
|
||||
element_ynh_url="https://matrix.to/"
|
||||
# Get app name of first Element Instance (can be changed later in Config Panel)
|
||||
element_instance="element"
|
||||
if yunohost --output-as plain app list | grep -q "^$element_instance$"; then
|
||||
element_domain=$(ynh_app_setting_get --app $element_instance --key domain)
|
||||
element_path=$(ynh_app_setting_get --app $element_instance --key path)
|
||||
element_ynh_url="https://""$element_domain""$element_path"
|
||||
fi
|
||||
web_client_location=$element_ynh_url
|
||||
client_base_url=$element_ynh_url
|
||||
invite_client_location=$element_ynh_url
|
||||
|
||||
ynh_app_setting_set --app=$app --key=report_stats --value=$report_stats
|
||||
ynh_app_setting_set --app=$app --key=e2e_enabled_by_default --value=$e2e_enabled_by_default
|
||||
ynh_app_setting_set --app=$app --key=web_client_location --value=$web_client_location
|
||||
ynh_app_setting_set --app=$app --key=client_base_url --value=$client_base_url
|
||||
ynh_app_setting_set --app=$app --key=invite_client_location --value=$invite_client_location
|
||||
ynh_app_setting_set --app=$app --key=allow_public_rooms_without_auth --value=$allow_public_rooms_without_auth
|
||||
ynh_app_setting_set --app=$app --key=allow_public_rooms_over_federation --value=$allow_public_rooms_over_federation
|
||||
ynh_app_setting_set --app=$app --key=max_upload_size --value=$max_upload_size
|
||||
ynh_app_setting_set --app=$app --key=disable_msisdn_registration --value=$disable_msisdn_registration
|
||||
ynh_app_setting_set --app=$app --key=registrations_require_3pid --value=$registrations_require_3pid
|
||||
ynh_app_setting_set --app=$app --key=allowed_local_3pids_email --value=$allowed_local_3pids_email
|
||||
ynh_app_setting_set --app=$app --key=allowed_local_3pids_msisdn --value=$allowed_local_3pids_msisdn
|
||||
ynh_app_setting_set --app=$app --key=account_threepid_delegates_msisdn --value=$account_threepid_delegates_msisdn
|
||||
ynh_app_setting_set --app=$app --key=allow_guest_access --value=$allow_guest_access
|
||||
ynh_app_setting_set --app=$app --key=default_identity_server --value=$default_identity_server
|
||||
ynh_app_setting_set --app=$app --key=auto_join_rooms --value=$auto_join_rooms
|
||||
ynh_app_setting_set --app=$app --key=autocreate_auto_join_rooms --value=$autocreate_auto_join_rooms
|
||||
ynh_app_setting_set --app=$app --key=auto_join_rooms_for_guests --value=$auto_join_rooms_for_guests
|
||||
ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled
|
||||
ynh_app_setting_set --app=$app --key=enable_notifs --value=$enable_notifs
|
||||
ynh_app_setting_set --app=$app --key=notif_for_new_users --value=$notif_for_new_users
|
||||
ynh_app_setting_set --app=$app --key=enable_group_creation --value=$enable_group_creation
|
||||
ynh_app_setting_set --app=$app --key=push_include_content --value=$push_include_content
|
||||
ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration
|
||||
ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled
|
||||
ynh_app_setting_set --app=$app --key=enable_3pid_lookup --value=$enable_3pid_lookup
|
||||
ynh_app_setting_set --app=$app --key=enable_dtls_for_audio_video_turn_call --value=$enable_dtls_for_audio_video_turn_call
|
||||
ynh_app_setting_set --app="$app" --key=password_enabled --value="$password_enabled"
|
||||
ynh_app_setting_set --app="$app" --key=enable_registration --value="$enable_registration"
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
|
124
scripts/upgrade
124
scripts/upgrade
|
@ -33,6 +33,8 @@ if [ -z "${domain:-}" ]; then
|
|||
ynh_app_setting_set --app=$app --key=no_sso --value true
|
||||
fi
|
||||
|
||||
ensure_vars_set
|
||||
|
||||
# Define $server_name if not already defined
|
||||
if [ -z "${server_name:-}" ]; then
|
||||
server_name=$domain
|
||||
|
@ -45,135 +47,30 @@ if [ -z "${jitsi_server:-}" ]; then
|
|||
ynh_app_setting_set --app=$app --key=jitsi_server --value=$jitsi_server
|
||||
fi
|
||||
|
||||
# Define $e2e_enabled_by_default if not already defined
|
||||
if [ -z "${e2e_enabled_by_default:-}" ] ; then
|
||||
e2e_enabled_by_default="invite"
|
||||
ynh_app_setting_set --app=$app --key=e2e_enabled_by_default --value=$e2e_enabled_by_default
|
||||
fi
|
||||
|
||||
if [ "$e2e_enabled_by_default" = "true" ] ; then
|
||||
e2e_enabled_by_default="all"
|
||||
ynh_app_setting_set --app=$app --key=e2e_enabled_by_default --value=$e2e_enabled_by_default
|
||||
fi
|
||||
|
||||
if [ "$e2e_enabled_by_default" = "false" ]; then
|
||||
e2e_enabled_by_default="off"
|
||||
ynh_app_setting_set --app=$app --key=e2e_enabled_by_default --value=$e2e_enabled_by_default
|
||||
fi
|
||||
|
||||
if [ -z "${report_stats:-}" ]; then
|
||||
report_stats="false"
|
||||
ynh_app_setting_set --app=$app --key=report_stats --value=$report_stats
|
||||
fi
|
||||
|
||||
if [ -z "${web_client_location:-}" ]
|
||||
then
|
||||
web_client_location="https://matrix.to/"
|
||||
|
||||
element_instance="element"
|
||||
if yunohost --output-as plain app list | grep -q "^$element_instance"'$'; then
|
||||
element_domain=$(ynh_app_setting_get --app $element_instance --key domain)
|
||||
element_path=$(ynh_app_setting_get --app $element_instance --key path)
|
||||
web_client_location="https://""$element_domain""$element_path"
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=web_client_location --value=$web_client_location
|
||||
fi
|
||||
if [ -z "${client_base_url:-}" ]
|
||||
then
|
||||
client_base_url=$web_client_location
|
||||
ynh_app_setting_set --app=$app --key=client_base_url --value=$client_base_url
|
||||
fi
|
||||
if [ -z "${invite_client_location:-}" ]
|
||||
then
|
||||
invite_client_location=$web_client_location
|
||||
ynh_app_setting_set --app=$app --key=invite_client_location --value=$invite_client_location
|
||||
fi
|
||||
if [ -z "${allow_public_rooms_without_auth:-}" ]
|
||||
then
|
||||
allow_public_rooms_without_auth=${allow_public_rooms:-false}
|
||||
ynh_app_setting_set --app=$app --key=allow_public_rooms_without_auth --value=$allow_public_rooms_without_auth
|
||||
fi
|
||||
if [ -z "${allow_public_rooms_over_federation:-}" ]
|
||||
then
|
||||
allow_public_rooms_over_federation=${allow_public_rooms:-false}
|
||||
ynh_app_setting_set --app=$app --key=allow_public_rooms_over_federation --value=$allow_public_rooms_over_federation
|
||||
fi
|
||||
if [ -z "${max_upload_size:-}" ]
|
||||
then
|
||||
max_upload_size="100M"
|
||||
ynh_app_setting_set --app=$app --key=max_upload_size --value=$max_upload_size
|
||||
fi
|
||||
if [ -z "${disable_msisdn_registration:-}" ]
|
||||
then
|
||||
disable_msisdn_registration="true"
|
||||
ynh_app_setting_set --app=$app --key=disable_msisdn_registration --value=$disable_msisdn_registration
|
||||
fi
|
||||
if [ -z "${registrations_require_3pid:-}" ] || [ "${registrations_require_3pid}" == none ]
|
||||
if [ "${registrations_require_3pid}" == none ]
|
||||
then
|
||||
registrations_require_3pid=email
|
||||
ynh_app_setting_set --app=$app --key=registrations_require_3pid --value=$registrations_require_3pid
|
||||
fi
|
||||
if [ -z "${allowed_local_3pids_email:-}" ] || [[ "${allowed_local_3pids_email}" =~ \'.*\' ]] # Also remove shit value from previous config panel
|
||||
if [[ "${allowed_local_3pids_email}" =~ \'.*\' ]] # Also remove shit value from previous config panel
|
||||
then
|
||||
allowed_local_3pids_email=''
|
||||
ynh_app_setting_set --app=$app --key=allowed_local_3pids_email --value=$allowed_local_3pids_email
|
||||
fi
|
||||
if [ -z "${allowed_local_3pids_msisdn:-}" ] || [[ "${allowed_local_3pids_msisdn}" =~ \'.*\' ]] # Also remove shit value from previous config panel
|
||||
if [[ "${allowed_local_3pids_msisdn}" =~ \'.*\' ]] # Also remove shit value from previous config panel
|
||||
then
|
||||
allowed_local_3pids_msisdn=''
|
||||
ynh_app_setting_set --app=$app --key=allowed_local_3pids_msisdn --value=$allowed_local_3pids_msisdn
|
||||
fi
|
||||
if [ -z "${account_threepid_delegates_msisdn:-}" ]
|
||||
then
|
||||
account_threepid_delegates_msisdn=""
|
||||
ynh_app_setting_set --app=$app --key=account_threepid_delegates_msisdn --value=$account_threepid_delegates_msisdn
|
||||
fi
|
||||
if [ -z "${allow_guest_access:-}" ]
|
||||
then
|
||||
allow_guest_access="false"
|
||||
ynh_app_setting_set --app=$app --key=allow_guest_access --value=$allow_guest_access
|
||||
fi
|
||||
if [ -z "${default_identity_server:-}" ]
|
||||
then
|
||||
default_identity_server="https://matrix.org"
|
||||
ynh_app_setting_set --app=$app --key=default_identity_server --value=$default_identity_server
|
||||
fi
|
||||
if [ -z "${auto_join_rooms:-}" ]
|
||||
then
|
||||
auto_join_rooms=""
|
||||
ynh_app_setting_set --app=$app --key=auto_join_rooms --value=$auto_join_rooms
|
||||
fi
|
||||
if [ -z "${autocreate_auto_join_rooms:-}" ]
|
||||
then
|
||||
autocreate_auto_join_rooms="false"
|
||||
ynh_app_setting_set --app=$app --key=autocreate_auto_join_rooms --value=$autocreate_auto_join_rooms
|
||||
fi
|
||||
if [ -z "${auto_join_rooms_for_guests:-}" ]
|
||||
then
|
||||
auto_join_rooms_for_guests="true"
|
||||
ynh_app_setting_set --app=$app --key=auto_join_rooms_for_guests --value=$auto_join_rooms_for_guests
|
||||
fi
|
||||
if [ -z "${enable_notifs:-}" ]
|
||||
then
|
||||
enable_notifs="true"
|
||||
ynh_app_setting_set --app=$app --key=enable_notifs --value=$enable_notifs
|
||||
fi
|
||||
if [ -z "${notif_for_new_users:-}" ]
|
||||
then
|
||||
notif_for_new_users="true"
|
||||
ynh_app_setting_set --app=$app --key=notif_for_new_users --value=$notif_for_new_users
|
||||
fi
|
||||
if [ -z "${enable_group_creation:-}" ]
|
||||
then
|
||||
enable_group_creation="true"
|
||||
ynh_app_setting_set --app=$app --key=enable_group_creation --value=$enable_group_creation
|
||||
fi
|
||||
if [ -z "${enable_3pid_lookup:-}" ]
|
||||
then
|
||||
enable_3pid_lookup=false
|
||||
ynh_app_setting_set --app=$app --key=enable_3pid_lookup --value=$enable_3pid_lookup
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "${enable_registration:-}" ]
|
||||
then
|
||||
|
@ -194,17 +91,6 @@ then
|
|||
ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled
|
||||
fi
|
||||
|
||||
if [ -z "${push_include_content:-}" ]
|
||||
then
|
||||
push_include_content="true"
|
||||
ynh_app_setting_set --app=$app --key=push_include_content --value=$push_include_content
|
||||
fi
|
||||
if [ -z "${enable_dtls_for_audio_video_turn_call:-}" ]
|
||||
then
|
||||
enable_dtls_for_audio_video_turn_call=true
|
||||
ynh_app_setting_set --app=$app --key=enable_dtls_for_audio_video_turn_call --value=$enable_dtls_for_audio_video_turn_call
|
||||
fi
|
||||
|
||||
# remove legacy env file into /etc/default
|
||||
ynh_secure_remove --file=/etc/default/coturn-$app
|
||||
|
||||
|
|
Loading…
Reference in a new issue