Files
ProxmoxVE/install/elementsynapse-install.sh
T
MickLesk 3f0dd1b09b install: answer every prompt from the environment, survive a closed stdin
Every interactive prompt takes a var_<app>_<name> override and treats a
closed stdin like Enter (`|| true`), so an install keeps going after the
console that started it is gone. Values the script cannot do without end
with exit 64 and name the variable to set. Validation loops stop asking
when nobody can answer instead of spinning on an empty read.
2026-10-23 20:44:37 +02:00

112 lines
3.4 KiB
Bash

#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: tremor021
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/element-hq/synapse
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y \
apt-transport-https \
debconf-utils
msg_ok "Installed Dependencies"
NODE_VERSION="22" NODE_MODULE="yarn" setup_nodejs
echo "${TAB3}It is important to choose the name for your server before you install Synapse, because it cannot be changed later."
echo "${TAB3}The server name determines the “domain” part of user-ids for users on your server: these will all be of the format @user:my.domain.name. It also determines how other matrix servers will reach yours for federation."
servername="${var_elementsynapse_server_name:-}"
[[ -n "$servername" ]] || read -r -p "${TAB3}Please enter the name for your server: " servername || true
[[ -n "$servername" ]] || { msg_error "No server name given; set var_elementsynapse_server_name or answer the prompt"; exit 64; }
msg_info "Installing Element Synapse"
setup_deb822_repo "matrix-org" \
"https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg" \
"https://packages.matrix.org/debian/" \
"$(get_os_info codename)" \
"main"
echo "matrix-synapse-py3 matrix-synapse/server-name string $servername" | debconf-set-selections
echo "matrix-synapse-py3 matrix-synapse/report-stats boolean false" | debconf-set-selections
echo "exit 101" >/usr/sbin/policy-rc.d
chmod +x /usr/sbin/policy-rc.d
$STD apt install matrix-synapse-py3 -y
rm -f /usr/sbin/policy-rc.d
sed -i 's/127.0.0.1/0.0.0.0/g' /etc/matrix-synapse/homeserver.yaml
sed -i 's/'\''::1'\'', //g' /etc/matrix-synapse/homeserver.yaml
SECRET=$(openssl rand -hex 32)
ADMIN_PASS="$(random_password 13)"
echo "enable_registration_without_verification: true" >>/etc/matrix-synapse/homeserver.yaml
echo "registration_shared_secret: ${SECRET}" >>/etc/matrix-synapse/homeserver.yaml
cat <<EOF >>/etc/matrix-synapse/homeserver.yaml
# MatrixRTC / Element Call configuration
experimental_features:
msc3266_enabled: true
msc4222_enabled: true
max_event_delay_duration: 24h
rc_message:
per_second: 0.5
burst_count: 30
rc_delayed_event_mgmt:
per_second: 1
burst_count: 20
EOF
systemctl enable -q --now matrix-synapse
$STD register_new_matrix_user -a --user admin --password "$ADMIN_PASS" --config /etc/matrix-synapse/homeserver.yaml
cat <<EOF >~/matrix.creds
Matrix-Credentials
Admin username: admin
Admin password: $ADMIN_PASS
EOF
systemctl stop matrix-synapse
sed -i '34d' /etc/matrix-synapse/homeserver.yaml
systemctl start matrix-synapse
msg_ok "Installed Element Synapse"
fetch_and_deploy_gh_release "synapse-admin" "etkecc/synapse-admin" "tarball"
msg_info "Installing Synapse-Admin"
cd /opt/synapse-admin
$STD yarn global add serve
$STD yarn install --ignore-engines
$STD yarn build
mv ./dist ../ &&
rm -rf * &&
mv ../dist ./
msg_ok "Installed Synapse-Admin"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/synapse-admin.service
[Unit]
Description=Synapse-Admin Service
After=network.target
Requires=matrix-synapse.service
[Service]
Type=simple
WorkingDirectory=/opt/synapse-admin
ExecStart=/usr/local/bin/serve -s dist -l 5173
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now synapse-admin
msg_ok "Created Service"
motd_ssh
customize
cleanup_lxc