diff --git a/check_process b/check_process deleted file mode 100644 index 9c28469..0000000 --- a/check_process +++ /dev/null @@ -1,28 +0,0 @@ -;; General - ; Manifest - domain="domain.tld" - path="/_matrix/static/" - is_free_registration=1 - server_name="domain.tld" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=0 - setup_nourl=0 - setup_private=0 - setup_public=1 - upgrade=1 - upgrade=1 from_commit=0a485e0d6bcd14392b9203b3b27e7e1a7ba21d19 - upgrade=1 from_commit=6af39e6e086e70e2063eb8f63c48a1e4a597300d - backup_restore=1 - multi_instance=0 - incorrect_path=0 - port_already_use=1 (8448) - change_url=0 -;;; Levels - Level 5=auto -;;; Upgrade options - ; commit=0a485e0d6bcd14392b9203b3b27e7e1a7ba21d19 - name=Before permission implementation (branch old_version_for_CI_4) - ; commit=6af39e6e086e70e2063eb8f63c48a1e4a597300d - name=Before app user creation diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf index 940d2b8..f796032 100644 --- a/conf/extra_php-fpm.conf +++ b/conf/extra_php-fpm.conf @@ -1,4 +1,4 @@ ; Additional php.ini defines, specific to this pool of workers. -php_admin_value[upload_max_filesize] = 10M -php_admin_value[post_max_size] = 10M +php_admin_value[upload_max_filesize] = 100M +php_admin_value[post_max_size] = 100M diff --git a/manifest.toml b/manifest.toml index 4faec49..1188bb4 100644 --- a/manifest.toml +++ b/manifest.toml @@ -54,9 +54,9 @@ ram.runtime = "50M" [resources] [resources.sources] - [resources.sources.armv7_bookworm] - url = "https://github.com/YunoHost-Apps/synapse_python_build/releases/download/v1.84.1/matrix-synapse_1.84.1-bookworm-bin1_armv7l.tar.gz" - sha256 = "fd516b379687540aa74c828a8d93cb05e59a04c03508258cfb6b331cfb80ea18" + #[resources.sources.armv7_bookworm] + #url = "https://github.com/YunoHost-Apps/synapse_python_build/releases/download/v1.84.1/matrix-synapse_1.84.1-bookworm-bin1_armv7l.tar.gz" + #sha256 = "fd516b379687540aa74c828a8d93cb05e59a04c03508258cfb6b331cfb80ea18" [resources.sources.armv7_bullseye] url = "https://github.com/YunoHost-Apps/synapse_python_build/releases/download/v1.84.1/matrix-synapse_1.84.1-bullseye-bin1_armv7l.tar.gz" @@ -77,6 +77,8 @@ ram.runtime = "50M" [resources.install_dir] dir = "/opt/yunohost/matrix-__APP__" + [resources.install_dir] + [resources.permissions] main.url = "__DOMAIN__/_matrix/cas_server.php/login" main.show_tile=false diff --git a/scripts/install b/scripts/install index df9f1fc..4622ec3 100644 --- a/scripts/install +++ b/scripts/install @@ -17,9 +17,6 @@ source /usr/share/yunohost/helpers synapse_user="matrix-$app" synapse_user_app="$app" synapse_user_app_pwd="$(ynh_string_random --length=30)" -#synapse_db_name="matrix_$app" -#synapse_db_user="matrix_$app" -#synapse_db_name="matrix_$app" upstream_version=$(ynh_app_upstream_version) report_stats="false" allow_public_rooms="false" @@ -32,14 +29,10 @@ domain_whitelist_client=${domain_whitelist_client_%"\n"} # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= - -#REMOVEME? server_name=$YNH_APP_ARG_SERVER_NAME -#REMOVEME? is_free_registration=$YNH_APP_ARG_IS_FREE_REGISTRATION -#REMOVEME? jitsi_server=$YNH_APP_ARG_JITSI_SERVER path="/_matrix" -#REMOVEME? install_dir="/opt/yunohost/matrix-$app" + final_www_path="/var/www/$app" -data_path="/home/yunohost.app/matrix-$app" + main_domain=$(yunohost domain list --output-as json | jq -r .main) if [[ "$server_name" == "$default_domain_value" ]]; then @@ -53,23 +46,23 @@ ynh_script_progression --message="Validating installation parameters..." --weigh test ! -e "/etc/nginx/conf.d/$domain.d/synapse*.conf" || ynh_die --message="$domain is not available as domain, please use an other domain." -if [ -e "$data_path" ]; then - old_data_dir_path="$data_path$(date '+%Y%m%d.%H%M%S')" +if [ -e "$data_dir" ]; then + old_data_dir_path="$data_dir$(date '+%Y%m%d.%H%M%S')" ynh_print_warn "A data directory already exist. Data was renamed to $old_data_dir_path" - mv "$data_path" "$old_data_dir_path" + mv "$data_dir" "$old_data_dir_path" fi #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 +ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=no_sso --value true -ynh_app_setting_set --app=$app --key=server_name --value=$server_name -ynh_app_setting_set --app=$app --key=jitsi_server --value=$jitsi_server +#ynh_app_setting_set --app=$app --key=server_name --value=$server_name +#ynh_app_setting_set --app=$app --key=jitsi_server --value=$jitsi_server ynh_app_setting_set --app=$app --key=synapse_version --value=$upstream_version -ynh_app_setting_set --app=$app --key=is_free_registration --value=$is_free_registration -#REMOVEME? ynh_app_setting_set --app=$app --key=report_stats --value=$report_stats +#ynh_app_setting_set --app=$app --key=is_free_registration --value=$is_free_registration +ynh_app_setting_set --app=$app --key=report_stats --value=$report_stats ynh_app_setting_set --app=$app --key=allow_public_rooms --value=$allow_public_rooms ynh_app_setting_set --app=$app --key=e2e_enabled_by_default --value=$e2e_enabled_by_default ynh_app_setting_set --app=$app --key=synapse_user_app_pwd --value=$synapse_user_app_pwd @@ -112,7 +105,7 @@ adduser turnserver ssl-cert ynh_script_progression --message="Creating a PostgreSQL database..." --weight=4 ynh_psql_execute_as_root \ ---sql="CREATE DATABASE $synapse_db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $synapse_db_user;" +--sql="CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $db_user;" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -123,7 +116,6 @@ ynh_script_progression --message="Setting up source files..." --weight=50 # WARNING : theses command are used in INSTALL, UPGRADE # For any update do it in all files -mkdir -p $data_path mkdir -p /var/log/matrix-$app mkdir -p /etc/matrix-$app/conf.d mkdir -p /etc/matrix-$app/app-service @@ -146,7 +138,6 @@ chown $synapse_user:root -R $final_www_path #================================================= # CREATE SYNAPSE CONFIG #================================================= - ynh_script_progression --message="Creating Synapse config..." --weight=3 # Go in virtualenvironnement @@ -167,7 +158,7 @@ registration_shared_secret=$(egrep "^registration_shared_secret:" homeserver.yml form_secret=$(egrep "^form_secret:" homeserver.yml | cut -d'"' -f2) macaroon_secret_key=$(egrep "^macaroon_secret_key:" homeserver.yml | cut -d'"' -f2) -# store in yunohost settings +# store in YunoHost settings ynh_app_setting_set --app=$app --key=registration_shared_secret --value="$registration_shared_secret" ynh_app_setting_set --app=$app --key=form_secret --value="$form_secret" ynh_app_setting_set --app=$app --key=macaroon_secret_key --value="$macaroon_secret_key" @@ -177,7 +168,7 @@ ynh_app_setting_set --app=$app --key=macaroon_secret_key --value="$macaroon_secr #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=2 -# Create systemd service for synapse and turnserver +# Create systemd service for Synapse and Turnserver cp ../conf/default_matrix-synapse /etc/default/matrix-$app ynh_add_systemd_config --service=matrix-$app --template=matrix-synapse.service @@ -189,9 +180,6 @@ ynh_add_systemd_config --service=coturn-$app --template=coturn-synapse.service #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=2 -# Create a dedicated php-fpm config -ynh_script_progression --message="Configuring application..." - ynh_add_fpm_config --usage=low --footprint=low # Create .well-known redirection for access by federation @@ -305,7 +293,7 @@ ynh_replace_string __DOMAIN__ $domain ../hooks/post_cert_update chown $synapse_user:root -R $install_dir chmod 770 $install_dir/Coturn_config_rotate.sh chmod 700 $install_dir/update_synapse_for_appservice.sh -chown $synapse_user:root -R $data_path +chown $synapse_user:root -R $data_dir chown $synapse_user:root -R /var/log/matrix-$app chown $synapse_user:root -R /etc/matrix-$app chmod u=rwX,g=rX,o= -R /etc/matrix-$app @@ -317,8 +305,8 @@ setfacl -R -m user:turnserver:rwX /var/log/matrix-$app # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add matrix-$app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $synapse_tls_port -yunohost service add coturn-$app --needs_exposed_ports $turnserver_tls_port +yunohost service add matrix-$app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $port_synapse_tls +yunohost service add coturn-$app --needs_exposed_ports $port_turnserver_tls #================================================= # RELOAD SERVICES @@ -326,7 +314,7 @@ yunohost service add coturn-$app --needs_exposed_ports $turnserver_tls_port ynh_script_progression --message="Restarting Synapse services..." --weight=11 ynh_systemd_action --service_name=coturn-$app.service --action=restart -ynh_systemd_action --service_name=matrix-$app --action=restart --line_match="Synapse now listening on TCP port $synapse_tls_port" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 +ynh_systemd_action --service_name=matrix-$app --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 #================================================= # SETUP FAIL2BAN diff --git a/scripts/remove b/scripts/remove index edc2755..706a8ba 100755 --- a/scripts/remove +++ b/scripts/remove @@ -16,41 +16,46 @@ source /usr/share/yunohost/helpers synapse_user="matrix-$app" synapse_user_app="$app" -#synapse_db_name="matrix_$app" -#synapse_db_user="matrix_$app" -#synapse_db_name="matrix_$app" upstream_version=$(ynh_app_upstream_version) final_www_path="/var/www/$app" #================================================= -# STANDARD REMOVE +# REMOVE SYSTEM CONFIGURATIONS #================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 -# Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status matrix-$app >/dev/null 2>&1 +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) +if ynh_exec_warn_less yunohost service status matrix-$app >/dev/null then - yunohost service remove matrix-$app + ynh_script_progression --message="Removing matrix-$app service integration..." --weight=1 + yunohost service remove matrix-$app fi -if yunohost service status coturn-$app >/dev/null 2>&1 +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) +if ynh_exec_warn_less yunohost service status coturn-$app >/dev/null then - yunohost service remove coturn-$app + ynh_script_progression --message="Removing coturn-$app service integration..." --weight=1 + yunohost service remove coturn-$app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service" --weight=2 - ynh_remove_systemd_config --service=matrix-$app ynh_remove_systemd_config --service=coturn-$app -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory" --weight=2 +# Remove the dedicated NGINX config +ynh_remove_nginx_config + +# Remove the dedicated PHP-FPM config +ynh_remove_fpm_config + +# Remove the app-specific logrotate config +ynh_remove_logrotate + +# Remove the dedicated fail2ban config +ynh_remove_fail2ban_config + +# Remove other various files specific to the app... ynh_secure_remove --file=$final_www_path ynh_secure_remove --file=/var/log/matrix-$app @@ -59,40 +64,6 @@ ynh_secure_remove --file=/etc/default/matrix-$app ynh_secure_remove --file=/etc/default/coturn-$app ynh_secure_remove --file=/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration" --weight=2 - -# Remove the dedicated nginx config -ynh_remove_nginx_config - -# Remove the dedicated php-fpm config -ynh_remove_fpm_config - -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration" --weight=1 - -# Remove the app-specific logrotate config -ynh_remove_logrotate - -#================================================= -# REMOVE FAIL2BAN CONFIGURATION -#================================================= -ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=8 - -# Remove the dedicated fail2ban config -ynh_remove_fail2ban_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user" --weight=1 - # Delete a system user ynh_system_user_delete --username=$synapse_user yunohost user delete $synapse_user_app @@ -100,7 +71,5 @@ yunohost user delete $synapse_user_app #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Due of the backup core only feature the data directory in '/home/yunohost.app/matrix-$app' was not removed. It need to be removed manually to purge app user data." ynh_script_progression --message="Removal of $app completed" --last -sleep 1 diff --git a/scripts/upgrade b/scripts/upgrade index 79304ec..3be9a38 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,31 +16,8 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=3 +ynh_script_progression --message="Loading installation settings..." --weight=3 -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name) -#REMOVEME? jitsi_server=$(ynh_app_setting_get --app=$app --key=jitsi_server) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? synapse_old_version=$(ynh_app_setting_get --app=$app --key=synapse_version) -#REMOVEME? is_free_registration=$(ynh_app_setting_get --app=$app --key=is_free_registration) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=synapse_port) -#REMOVEME? synapse_tls_port=$(ynh_app_setting_get --app=$app --key=synapse_tls_port) -#REMOVEME? turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port) -#REMOVEME? turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port) -#REMOVEME? cli_port=$(ynh_app_setting_get --app=$app --key=cli_port) -#REMOVEME? report_stats=$(ynh_app_setting_get --app=$app --key=report_stats) -#REMOVEME? allow_public_rooms=$(ynh_app_setting_get --app=$app --key=allow_public_rooms) -#REMOVEME? e2e_enabled_by_default=$(ynh_app_setting_get --app=$app --key=e2e_enabled_by_default) -#REMOVEME? synapse_db_pwd=$(ynh_app_setting_get --app=$app --key=synapse_db_pwd) -#REMOVEME? turnserver_pwd=$(ynh_app_setting_get --app=$app --key=turnserver_pwd) -#REMOVEME? registration_shared_secret=$(ynh_app_setting_get --app=$app --key=registration_shared_secret) -#REMOVEME? form_secret=$(ynh_app_setting_get --app=$app --key=form_secret) -#REMOVEME? macaroon_secret_key=$(ynh_app_setting_get --app=$app --key=macaroon_secret_key) -#REMOVEME? synapse_user_app_pwd=$(ynh_app_setting_get --app=$app --key=synapse_user_app_pwd) domain_whitelist_client_=$(get_domain_list) domain_whitelist_client=${domain_whitelist_client_%"\n"} main_domain=$(yunohost domain list --output-as json | jq -r .main) @@ -51,13 +28,9 @@ main_domain=$(yunohost domain list --output-as json | jq -r .main) synapse_user="matrix-$app" synapse_user_app="$app" -synapse_db_name="matrix_$app" -synapse_db_user="matrix_$app" -synapse_db_name="matrix_$app" upstream_version=$(ynh_app_upstream_version) upgrade_type=$(ynh_check_app_version_changed) final_www_path="/var/www/$app" -data_path="/home/yunohost.app/matrix-$app" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -394,8 +367,8 @@ fi # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add matrix-$app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $synapse_tls_port -yunohost service add coturn-$app --needs_exposed_ports $turnserver_tls_port +yunohost service add matrix-$app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $port_synapse_tls +yunohost service add coturn-$app --needs_exposed_ports $port_turnserver_tls #================================================= # UPDATE SYSTEMD @@ -498,7 +471,7 @@ ynh_app_setting_set --app=$app --key=synapse_version --value=$upstream_version ynh_script_progression --message="Restarting Synapse services..." --weight=5 ynh_systemd_action --service_name=coturn-$app.service --action=restart -ynh_systemd_action --service_name=matrix-$app --action=restart --line_match="Synapse now listening on TCP port $synapse_tls_port" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 +ynh_systemd_action --service_name=matrix-$app --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml index 603ba78..423a01b 100644 --- a/tests.toml +++ b/tests.toml @@ -6,12 +6,13 @@ test_format = 1.0 # Default args to use for install # ------------------------------- - args.is_free_registration=1 - args.server_name="domain.tld" + args.is_free_registration = 1 + args.server_name = "domain.tld" + args.jitsi_server = "jitsi.riot.im" # ------------------------------- # Commits to test upgrade from # ------------------------------- - test_upgrade_from.00a1a6e7.name = "Upgrade from 5.4" - test_upgrade_from.00a1a6e7.args.foo = "bar" + #test_upgrade_from.00a1a6e7.name = "Upgrade from 5.4" +