2025-02-03 13:09:49 +01:00
#!/usr/bin/env bash
2026-01-06 13:28:12 +01:00
# Copyright (c) 2021-2026 community-scripts ORG
2025-02-03 13:09:49 +01:00
# Author: tremor021
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
2025-03-04 17:54:20 +01:00
# Source: https://github.com/element-hq/synapse
2025-02-03 13:09:49 +01:00
2025-03-24 14:20:56 +01:00
source /dev/stdin <<< " $FUNCTIONS_FILE_PATH "
2025-02-03 13:09:49 +01:00
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
2026-01-23 21:54:23 +01:00
$STD apt install -y \
2025-02-03 13:09:49 +01:00
apt-transport-https \
2025-05-27 13:48:34 +02:00
debconf-utils
2025-02-03 13:09:49 +01:00
msg_ok "Installed Dependencies"
2026-01-23 21:54:23 +01:00
NODE_VERSION = "22" NODE_MODULE = "yarn" setup_nodejs
2025-04-24 09:52:22 +02:00
2026-02-24 09:24:44 +01:00
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. "
2025-05-15 11:13:57 +02:00
read -p " ${ TAB3 } Please enter the name for your server: " servername
2025-02-05 10:50:57 +01:00
2025-02-03 13:09:49 +01:00
msg_info "Installing Element Synapse"
2026-01-23 21:54:23 +01:00
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"
2025-02-05 10:50:57 +01:00
echo " matrix-synapse-py3 matrix-synapse/server-name string $servername " | debconf-set-selections
2025-02-03 13:09:49 +01:00
echo "matrix-synapse-py3 matrix-synapse/report-stats boolean false" | debconf-set-selections
2026-02-10 15:26:22 +01:00
echo "exit 101" >/usr/sbin/policy-rc.d
chmod +x /usr/sbin/policy-rc.d
2026-01-23 21:54:23 +01:00
$STD apt install matrix-synapse-py3 -y
2026-02-10 15:26:22 +01:00
rm -f /usr/sbin/policy-rc.d
2025-02-03 13:09:49 +01:00
sed -i 's/127.0.0.1/0.0.0.0/g' /etc/matrix-synapse/homeserver.yaml
2025-02-03 20:33:30 +01:00
sed -i 's/' \' '::1' \' ', //g' /etc/matrix-synapse/homeserver.yaml
2025-04-24 09:52:22 +02:00
SECRET = $( openssl rand -hex 32)
ADMIN_PASS = " $( openssl rand -base64 18 | cut -c1-13) "
echo "enable_registration_without_verification: true" >>/etc/matrix-synapse/homeserver.yaml
echo " registration_shared_secret: ${ SECRET } " >>/etc/matrix-synapse/homeserver.yaml
2025-02-03 13:09:49 +01:00
systemctl enable -q --now matrix-synapse
2025-04-24 09:52:22 +02:00
$STD register_new_matrix_user -a --user admin --password " $ADMIN_PASS " --config /etc/matrix-synapse/homeserver.yaml
{
echo "Matrix-Credentials"
echo "Admin username: admin"
echo " Admin password: $ADMIN_PASS "
} >>~/matrix.creds
systemctl stop matrix-synapse
sed -i '34d' /etc/matrix-synapse/homeserver.yaml
systemctl start matrix-synapse
2026-01-23 21:54:23 +01:00
msg_ok "Installed Element Synapse"
2026-01-24 23:48:24 +01:00
fetch_and_deploy_gh_release "synapse-admin" "etkecc/synapse-admin" "tarball"
2026-01-23 21:54:23 +01:00
msg_info "Installing Synapse-Admin"
2025-04-25 18:36:40 -07:00
cd /opt/synapse-admin
2025-06-10 20:13:00 +02:00
$STD yarn global add serve
2025-04-24 09:52:22 +02:00
$STD yarn install --ignore-engines
2025-06-10 20:13:00 +02:00
$STD yarn build
2025-06-18 12:03:00 +02:00
mv ./dist ../ &&
rm -rf * &&
2025-06-10 20:13:00 +02:00
mv ../dist ./
2026-01-23 21:54:23 +01:00
msg_ok "Installed Synapse-Admin"
2025-02-03 13:09:49 +01:00
2025-04-24 09:52:22 +02:00
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/synapse-admin.service
[ Unit]
2025-04-24 20:52:57 +02:00
Description = Synapse-Admin Service
2025-04-24 09:52:22 +02:00
After = network.target
Requires = matrix-synapse.service
[ Service]
Type = simple
WorkingDirectory = /opt/synapse-admin
2025-06-10 20:13:00 +02:00
ExecStart = /usr/local/bin/serve -s dist -l 5173
2025-04-24 09:52:22 +02:00
Restart = always
[ Install]
WantedBy = multi-user.target
EOF
systemctl enable -q --now synapse-admin
msg_ok "Created Service"
2025-02-03 13:09:49 +01:00
motd_ssh
customize
2025-11-22 17:27:13 +01:00
cleanup_lxc