From 0be068c04acf15f8d06c9cd4097099203b4452af Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 3 Nov 2024 01:07:24 +0100 Subject: [PATCH] Update Snikket and use more Docker - The modules are now directly copied from the Docker image --- .gitignore | 1 + doc/ADMIN.md | 3 +- doc/ADMIN_fr.md | 1 - doc/POST_INSTALL.md | 1 + manifest.toml | 39 ++++++++++------------ scripts/install | 65 +++++++++++++++++-------------------- scripts/remove | 11 ------- scripts/restore | 11 ------- scripts/upgrade | 11 ------- sources/prosody-modules.txt | 56 -------------------------------- sources/snikket-modules.txt | 9 ----- 11 files changed, 50 insertions(+), 158 deletions(-) create mode 100644 .gitignore delete mode 100644 doc/ADMIN_fr.md create mode 100644 doc/POST_INSTALL.md delete mode 100644 sources/prosody-modules.txt delete mode 100644 sources/snikket-modules.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/doc/ADMIN.md b/doc/ADMIN.md index d06e571..eb892ed 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -1,2 +1 @@ -* Prosody will not replace the XMPP service Metronome integrated in YunoHost, it has been implemented for some specific apps that require Prosody. - +The `create-invite` script has been renamed to `snikket-create-invite` diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md deleted file mode 100644 index c7dc3e4..0000000 --- a/doc/ADMIN_fr.md +++ /dev/null @@ -1 +0,0 @@ -* Prosody ne remplacera pas le service XMPP Metronome intégré à YunoHost, il a été implémenté pour certaines applications spécifiques nécessitant Prosody. diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..70d141d --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1 @@ +It's time to create an admin account. Run `yunohost app shell snikket` then `snikket-create-invite --admin --group default` to create an invite. diff --git a/manifest.toml b/manifest.toml index 93eb493..20dda1e 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,13 +19,13 @@ code = "https://github.com/snikket-im/snikket-server/" fund = "https://snikket.org/donate/" [integration] -yunohost = ">= 11.2" +yunohost = ">= 12.0" architectures = "all" multi_instance = false ldap = false -sso = false +sso = "not_relevant" disk = "50M" ram.build = "50M" @@ -34,28 +34,27 @@ ram.runtime = "50M" [install] [install.domain] # this is a generic question - ask strings are automatically handled by YunoHost's core - type = "domain" + type = "domain" # TODO: The web interface and XMPP domains should be separated [install.admin] type = "email" ask.en = "Administrator E-mail" help.en = "Provide an E-mail address where users can contact you" [install.init_main_permission] type = "group" - default = "visitors" + default = "all_users" [resources] [resources.sources.main] - url = "https://github.com/snikket-im/snikket-server/archive/refs/tags/stable.20240221.tar.gz" + url = "snikket/snikket-server:stable.20240926" sha256 = "f33ad5ccddb52bb08059b0b7b0b38ab4d7ceb1304866b214ce554546efface06" + format = "docker" + prefetch = false [resources.sources.prosody] - url = "https://hg.prosody.im/trunk/archive/41a587613a0e.tar.gz" - sha256 = "701ce4761b1979614712ac9c9c13cb700415469a8e11ed9e3140fd6795bbcdcd" - [resources.sources.prosody-modules] - url = "https://hg.prosody.im/prosody-modules/archive/095030677ae6.tar.gz" - sha256 = "8c2a51ef72cbe86a3b2a8e5c4d8656ee1d167f153223b481b5e8c4c5ed85f11d" + url = "https://hg.prosody.im/trunk/archive/3e6d5738ea09.tar.gz" + sha256 = "78a01a43499e685b64dd3730dac04821007b80ba1740381ff0b537f04e1a6523" [resources.sources.snikket-portal] - url = "snikket/snikket-web-portal:dev" - sha256 = "a43d2131ac32ebdc2394675bf33ea75a9e2996e13ea352398909a30feab27c16" + url = "snikket/snikket-web-portal:stable.20240926" + sha256 = "5c6a4961ee88672ef4fe9fcb8171a68055b9133d500f563b541b4bb5a5edaf42" format = "docker" prefetch = false # Prefetch doesn't seem to be supported with Docker images @@ -77,19 +76,15 @@ ram.runtime = "50M" server.fixed=true http.default=5280 main.exposed="TCP" - # TODO: Need to remove/disable Metronome *before* installation starts because of the port allocation here - # TODO: Or switch to using prosody_ynh as a dependency [resources.permissions] main.url = "/" main.additional_urls = [ "groups.__DOMAIN__/", "share.__DOMAIN__/" ] [resources.apt] - packages = "libicu-dev, libidn11-dev, libssl-dev, openssl, txt2man, lua-luaossl, lua-readline, dns-root-data, lua-dbi-sqlite3, build-essential, python3-dev, python3-pip, python3-venv" - packages_from_raw_bash = """ - if [[ $YNH_DEBIAN_VERSION == "bullseye" ]]; then - echo "lua5.2, lua5.2-expat, lua5.2-socket, lua5.2-sec, lua5.2-unbound, liblua5.2-dev, lua-busted"; - elif [[ $YNH_DEBIAN_VERSION == "bookworm" ]]; then - echo "lua5.4, lua5.4-expat, lua5.4-socket, lua5.4-sec, lua5.4-unbound, liblua5.4-dev, lua-busted"; - fi - """ + packages = """ + libicu-dev, libssl-dev, + lua-dbi-sqlite3, build-essential, python3-dev, python3-pip, python3-venv, + lua5.4, liblua5.4-dev, + lua5.4-expat, lua5.4-sec, lua5.4-unbound, qrencode + """ diff --git a/scripts/install b/scripts/install index 6daa15a..5088456 100755 --- a/scripts/install +++ b/scripts/install @@ -9,17 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# DISABLE METRONOME -#================================================= -ynh_script_progression --message="Disabling Metronome..." - -if systemctl list-unit-files metronome.service &>/dev/null -then - ynh_systemd_action --service_name="metronome" --action="stop" - systemctl disable metronome.service --quiet -fi - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -31,9 +20,6 @@ ynh_setup_source --dest_dir="$builddir" --source_id=prosody snikketdir="$(mktemp -d)" ynh_setup_source --dest_dir="$snikketdir" -moddir="$(mktemp -d)" -ynh_setup_source --dest_dir="$moddir" --source_id=prosody-modules - portaldir="$(mktemp -d)" ynh_setup_source --dest_dir="$portaldir" --source_id=snikket-portal @@ -67,15 +53,15 @@ mkdir -p "$config_path" mkdir -p "$config_path"/{certs,conf.avail,conf.d} mkdir -p "$config_path"/firewall -prosody_config="$snikketdir/ansible/files/prosody.cfg.lua" +prosody_config="$snikketdir/opt/ansible/files/prosody.cfg.lua" ynh_replace_string --match_string="/snikket/prosody" --replace_string="/var/lib/snikket" --target_file="$prosody_config" ynh_replace_string --match_string="/var/run/prosody/prosody.pid" --replace_string="/var/run/snikket/prosody.pid" --target_file="$prosody_config" ynh_replace_string --match_string="/etc/prosody/" --replace_string="/etc/snikket/" --target_file="$prosody_config" -ynh_add_config --template="$snikketdir/ansible/files/prosody.cfg.lua" --destination="$config_path/prosody.cfg.lua" -ynh_add_config --template="$snikketdir/ansible/files/restricted_users.pfw" --destination="$config_path/restricted_users.pfw" +ynh_add_config --template="$prosody_config" --destination="$config_path/prosody.cfg.lua" +ynh_add_config --template="$snikketdir/opt/ansible/files/restricted_users.pfw" --destination="$config_path/restricted_users.pfw" # Add Prosody-Migrator config -ynh_add_config --template="$snikketdir/ansible/files/migrator.cfg.lua" --destination="$config_path/migrator.cfg.lua" +ynh_add_config --template="$snikketdir/opt/ansible/files/migrator.cfg.lua" --destination="$config_path/migrator.cfg.lua" chown root:root "$config_path" chmod 755 "$config_path" @@ -94,14 +80,19 @@ chmod 750 "$config_path/certs" #================================================= ynh_script_progression --message="Intalling modules..." mkdir -p "/etc/$app/modules" -while read module +find "$snikketdir/etc/prosody/modules" -mindepth 1 -maxdepth 1 -type l | while IFS= read -r module do - cp -r "$moddir/$module" "/etc/$app/modules/$module" -done < "../sources/prosody-modules.txt" -while read module -do - cp -r "$snikketdir/snikket-modules/$module" "/etc/$app/modules/$module" -done < "../sources/snikket-modules.txt" + echo "Found module $module" + module=$(basename $module) + if [[ -d "$snikketdir/usr/local/lib/prosody-modules/$module" ]]; then + echo "Found it in Prosody modules" + cp -r "$snikketdir/usr/local/lib/prosody-modules/$module" "/etc/$app/modules/$module" + fi + if [[ -d "$snikketdir/usr/local/lib/snikket-modules/$module" ]]; then + echo "Found it in Snikket modules" + cp -r "$snikketdir/usr/local/lib/snikket-modules/$module" "/etc/$app/modules/$module" + fi +done #================================================= # SETUP SNIKKET ADMIN PORTAL @@ -115,16 +106,6 @@ pushd "$install_dir/snikket_web" .venv/bin/pip3 install --force babel # TODO: This is not ideal popd -# TODO: Install the create-invite script (with env setting) -#================================================= -# CLEAN TEMPORARY FILES -#================================================= -ynh_script_progression --message="Cleaning temporary files..." -ynh_secure_remove --file="$builddir" -ynh_secure_remove --file="$snikketdir" -ynh_secure_remove --file="$moddir" -ynh_secure_remove --file="$portaldir" - #================================================= # SETUP SNIKKET CONFIG #================================================= @@ -143,6 +124,20 @@ SNIKKET_WEB_PROSODY_ENDPOINT=http://localhost:$port_http SNIKKET_WEB_SECRET_KEY=TODO EOF +mkdir -p "/usr/local/share/snikket" +cp "$snikketdir/usr/local/share/snikket/logo.png" "/usr/local/share/snikket/logo.png" +install "$snikketdir/usr/local/bin/create-invite" "/usr/local/bin/snikket-create-invite" # TODO: Only install for the Snikket user +install "$snikketdir/usr/local/bin/smtp-url-to-msmtp" "/usr/local/bin/snikket-smtp-url-to-msmtp" +install "$snikketdir/usr/local/bin/snikket-turn-addresses" "/usr/local/bin/snikket-turn-addresses" + +#================================================= +# CLEAN TEMPORARY FILES +#================================================= +ynh_script_progression --message="Cleaning temporary files..." +ynh_secure_remove --file="$builddir" +ynh_secure_remove --file="$snikketdir" +ynh_secure_remove --file="$portaldir" + #================================================= # SETUP CERTIFICATES #================================================= diff --git a/scripts/remove b/scripts/remove index 0029451..85a112d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -49,17 +49,6 @@ ynh_secure_remove --file="/usr/bin/prosody" ynh_secure_remove --file="/usr/bin/prosodyctl" ynh_secure_remove --file="/usr/bin/prosody-migrator" -#================================================= -# ENABLE METRONOME -#================================================= -ynh_script_progression --message="Enabling Metronome..." --weight=1 - -if systemctl list-unit-files metronome.service &>/dev/null -then - systemctl enable metronome.service --quiet - ynh_systemd_action --service_name="metronome" --action="start" -fi - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 554f380..c8f82fe 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,17 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DISABLE METRONOME -#================================================= -ynh_script_progression --message="Disabling Metronome..." --weight=1 - -if systemctl list-unit-files metronome.service &>/dev/null -then - ynh_systemd_action --service_name="metronome" --action="stop" - systemctl disable metronome.service --quiet -fi - #================================================= # RESTORE THE CONFIG DIR #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 9c20251..6125502 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,17 +15,6 @@ source /usr/share/yunohost/helpers upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# DISABLE METRONOME -#================================================= -ynh_script_progression --message="Disabling Metronome..." - -if systemctl list-unit-files metronome.service &>/dev/null -then - ynh_systemd_action --service_name="metronome" --action="stop" - systemctl disable metronome.service --quiet -fi - #================================================= # STANDARD UPGRADE STEPS #================================================= diff --git a/sources/prosody-modules.txt b/sources/prosody-modules.txt deleted file mode 100644 index dac6c7b..0000000 --- a/sources/prosody-modules.txt +++ /dev/null @@ -1,56 +0,0 @@ -mod_cloud_notify -mod_cloud_notify_extensions -mod_cloud_notify_encrypted -mod_cloud_notify_priority_tag -mod_cloud_notify_filters -mod_block_registrations -mod_conversejs -mod_migrate_http_upload -mod_lastlog2 -mod_limit_auth -mod_password_policy -mod_vcard_muc -mod_email -mod_http_altconnect -mod_firewall -mod_admin_notify -mod_http_oauth2 -mod_http_admin_api -mod_rest -mod_groups_migration -mod_invites_api -mod_invites_groups -mod_invites_page -mod_invites_register_api -mod_invites_tracking -mod_groups_internal -mod_groups_muc_bookmarks -mod_muc_defaults -mod_muc_local_only -mod_muc_offline_delivery -mod_http_host_status_check -mod_measure_process -mod_spam_reporting -mod_watch_spam_reports -mod_isolate_host -mod_muc_auto_reserve_nicks -mod_measure_active_users -mod_measure_lua -mod_measure_malloc -mod_http_xep227 -mod_portcheck -mod_sasl2 -mod_sasl2_bind2 -mod_sasl2_sm -mod_sasl2_fast -mod_client_management -mod_audit -mod_audit_auth -mod_audit_status -mod_audit_user_accounts -mod_password_policy -mod_s2s_status -mod_sasl_ssdp -mod_privilege -mod_admin_blocklist -mod_muc_moderation \ No newline at end of file diff --git a/sources/snikket-modules.txt b/sources/snikket-modules.txt deleted file mode 100644 index 0b48162..0000000 --- a/sources/snikket-modules.txt +++ /dev/null @@ -1,9 +0,0 @@ -mod_update_check -mod_update_notify -mod_invites_default_group -mod_invites_bootstrap -mod_snikket_client_id -mod_snikket_ios_preserve_push -mod_snikket_restricted_users -mod_snikket_deprecate_general_muc -mod_migrate_snikket_roles \ No newline at end of file