Update Snikket and use more Docker

- The modules are now directly copied from the Docker image
This commit is contained in:
Norbi Peti 2024-11-03 01:07:24 +01:00
parent ab326d8191
commit 0be068c04a
11 changed files with 50 additions and 158 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.idea

View file

@ -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`

View file

@ -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.

1
doc/POST_INSTALL.md Normal file
View file

@ -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.

View file

@ -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
"""

View file

@ -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
#=================================================

View file

@ -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
#=================================================

View file

@ -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
#=================================================

View file

@ -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
#=================================================

View file

@ -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

View file

@ -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