#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." builddir="$(mktemp -d)" ynh_setup_source --dest_dir="$builddir" --source_id=prosody snikketdir="$(mktemp -d)" ynh_setup_source --dest_dir="$snikketdir" portaldir="$(mktemp -d)" ynh_setup_source --dest_dir="$portaldir" --source_id=snikket-portal #================================================= # SPECIFIC SETUP #================================================= # BUILD PROSODY #================================================= ynh_script_progression --message="Building Prosody..." update-alternatives --set lua-interpreter /usr/bin/lua${luaversion} pushd "$builddir" ./configure --sysconfdir="/etc/$app" --datadir="/var/lib/$app" make make install # Install Prosody-Migrator pushd "tools/migration" make install popd popd #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding Prosody configuration..." config_path=/etc/$app ynh_app_setting_set --app=$app --key=config_path --value="$config_path" mkdir -p "$config_path" mkdir -p "$config_path"/{certs,conf.avail,conf.d} mkdir -p "$config_path"/firewall 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="$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/opt/ansible/files/migrator.cfg.lua" --destination="$config_path/migrator.cfg.lua" chown root:root "$config_path" chmod 755 "$config_path" chown root:$app "$config_path/conf.d" chmod 754 "$config_path/conf.d" chown root:$app "$config_path/conf.avail" chmod 754 "$config_path/conf.avail" chown root:$app "$config_path/certs" chmod 750 "$config_path/certs" #================================================= # SETUP MODULES #================================================= ynh_script_progression --message="Intalling modules..." mkdir -p "/etc/$app/modules" find "$snikketdir/etc/prosody/modules" -mindepth 1 -maxdepth 1 -type l | while IFS= read -r module do 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 #================================================= ynh_script_progression --message="Installing admin portal..." cp -r "${portaldir}/opt/snikket-web-portal/snikket_web/" "$install_dir/" pushd "$install_dir/snikket_web" python -m venv .venv cp -r "$portaldir"/usr/lib/python3/dist-packages/* .venv/lib/python*/site-packages/ cp -r "$portaldir"/usr/local/lib/python3.11/dist-packages/* .venv/lib/python*/site-packages/ .venv/bin/pip3 install --force babel # TODO: This is not ideal popd #================================================= # SETUP SNIKKET CONFIG #================================================= ynh_script_progression --message="Updating Snikket configuration..." # TODO: The TURN server should be set up as well cat >/etc/snikket/environment <