diff --git a/conf/cinny.json b/conf/config.json similarity index 66% rename from conf/cinny.json rename to conf/config.json index fd4370e..498322e 100644 --- a/conf/cinny.json +++ b/conf/config.json @@ -1,7 +1,7 @@ { "defaultHomeserver": 0, "homeserverList": [ - "__DEFAULT_HOME_SERVER__" + __DEFAULT_HOME_SERVER_LIST__"matrix.org" ], "allowCustomHomeservers": true } diff --git a/config_panel b/config_panel new file mode 100644 index 0000000..e69de29 diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..1458f83 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,19 @@ # PERSONAL HELPERS #================================================= +cinny_install_config_file() { + # This helper detects if default_home_server is matrix.org to prevent duplicates in the list. + + # Add a Json element in the config file + if [[ "$default_home_server" == "matrix.org" ]]; then + default_home_server_list="" + else + default_home_server_list="\"$default_home_server\",\n " + fi + + ynh_add_config --template="../conf/config.json" --destination="$install_dir/config.json" +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 688be5f..9589a38 100755 --- a/scripts/install +++ b/scripts/install @@ -29,14 +29,12 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ynh_add_nginx_config #================================================= -# CINNY CONFIGURATION +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Configuring Cinny..." --weight=1 +ynh_script_progression --message="Adding a configuration file..." --weight=1 -# Copy over the Cinny configuration file -ynh_add_config --template="../conf/cinny.json" --destination="$install_dir/config.json" +cinny_install_config_file -# Fix any permissions in the install dir chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" diff --git a/scripts/upgrade b/scripts/upgrade index 504b079..48ddf7b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,8 +16,17 @@ source /usr/share/yunohost/helpers upgrade_type=$(ynh_check_app_version_changed) #================================================= -# STANDARD UPGRADE STEPS +# ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# If default_home_server doesn't exist, create it +if [ -z "${default_home_server:-}" ]; then + default_home_server="matrix.org" + ynh_app_setting_set --app=$app --key=default_home_server --value=$default_home_server + + cinny_install_config_file +fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE