1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-04-27 18:30:17 +00:00

Element Synapse: Add Synapse-Admin web UI to manage Matrix (#4010)

* Update script

* Update
This commit is contained in:
Slaviša Arežina 2025-04-24 09:52:22 +02:00 committed by GitHub
parent fb3d0b24c7
commit de89dd90cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 139 additions and 44 deletions

View File

@ -20,18 +20,52 @@ color
catch_errors catch_errors
function update_script() { function update_script() {
header_info header_info
check_container_storage check_container_storage
check_container_resources check_container_resources
if [[ ! -d /etc/matrix-synapse ]]; then if [[ ! -d /etc/matrix-synapse ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit
fi
msg_info "Updating $APP LXC"
$STD apt-get update
$STD apt-get -y upgrade
msg_ok "Updated $APP LXC"
exit exit
fi
if [[ ! -f /opt/"${APP}"_version.txt ]]; then
touch /opt/"${APP}"_version.txt
fi
if ! dpkg -l | grep -q '^ii.*gpg'; then
$STD apt-get update
$STD apt-get install -y gpg
fi
if [[ ! -x /usr/bin/node ]]; then
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
$STD apt-get update
$STD apt-get install -y nodejs
$STD npm install -g yarn
fi
msg_info "Updating $APP LXC"
$STD apt-get update
$STD apt-get -y upgrade
msg_ok "Updated $APP LXC"
msg_info "Updating Synapse-Admin"
RELEASE=$(curl -fsSL https://api.github.com/repos/etkecc/synapse-admin/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ "${RELEASE}" != "$(cat /opt/"${APP}"_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
temp_file=$(mktemp)
systemctl stop synapse-admin
rm -rf /opt/synapse-admin
mkdir -p /opt/synapse-admin
curl -fsSL "https://github.com/etkecc/synapse-admin/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
tar xzf "$temp_file" -C /opt/synapse-admin
cd /opt/synapse-admin
$STD yarn install --ignore-engines
systemctl start synapse-admin
echo "${RELEASE}" >/opt/"${APP}"_version.txt
rm -f "$temp_file"
msg_ok "Update Successful"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi
exit
} }
start start

View File

@ -1,34 +1,43 @@
{ {
"name": "Element Synapse", "name": "Element Synapse",
"slug": "elementsynapse", "slug": "elementsynapse",
"categories": [ "categories": [
4 4
], ],
"date_created": "2025-02-02", "date_created": "2025-02-02",
"type": "ct", "type": "ct",
"updateable": true, "updateable": true,
"privileged": false, "privileged": false,
"interface_port": 8008, "interface_port": 8008,
"documentation": "https://element-hq.github.io/synapse/latest/welcome_and_overview.html", "documentation": "https://element-hq.github.io/synapse/latest/welcome_and_overview.html",
"website": "https://element.io/", "website": "https://element.io/",
"logo": "https://element.io/images/logo-mark-primary.svg", "logo": "https://element.io/images/logo-mark-primary.svg",
"description": "Synapse is an open source Matrix homeserver implementation, written and maintained by Element. Matrix is the open standard for secure and interoperable real time communications. You can directly run and manage the source code in this repository, available under an AGPL license. There is no support provided from Element unless you have a subscription.", "description": "Synapse is an open source Matrix homeserver implementation, written and maintained by Element. Matrix is the open standard for secure and interoperable real time communications. You can directly run and manage the source code in this repository, available under an AGPL license. There is no support provided from Element unless you have a subscription.",
"install_methods": [ "install_methods": [
{ {
"type": "default", "type": "default",
"script": "ct/elementsynapse.sh", "script": "ct/elementsynapse.sh",
"resources": { "resources": {
"cpu": 1, "cpu": 1,
"ram": 1024, "ram": 1024,
"hdd": 4, "hdd": 4,
"os": "debian", "os": "debian",
"version": "12" "version": "12"
}
} }
], }
"default_credentials": { ],
"username": null, "default_credentials": {
"password": null "username": null,
"password": null
},
"notes": [
{
"type": "info",
"text": "Type `cat ~/matrix.creds` to see admin username/password."
}, },
"notes": [] {
} "type": "info",
"text": "Synapse-Admin is running on port 5173"
}
]
}

View File

@ -17,9 +17,22 @@ msg_info "Installing Dependencies"
$STD apt-get install -y \ $STD apt-get install -y \
lsb-release \ lsb-release \
apt-transport-https \ apt-transport-https \
debconf-utils debconf-utils \
gpg
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
msg_info "Setting up Node.js Repository"
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
msg_ok "Set up Node.js Repository"
msg_info "Installing Node.js"
$STD apt-get update
$STD apt-get install -y nodejs
$STD npm install -g yarn
msg_ok "Installed Node.js"
read -p "Please enter the name for your server: " servername read -p "Please enter the name for your server: " servername
msg_info "Installing Element Synapse" msg_info "Installing Element Synapse"
@ -32,9 +45,48 @@ $STD apt-get install matrix-synapse-py3 -y
systemctl stop matrix-synapse systemctl stop matrix-synapse
sed -i 's/127.0.0.1/0.0.0.0/g' /etc/matrix-synapse/homeserver.yaml 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 sed -i 's/'\''::1'\'', //g' /etc/matrix-synapse/homeserver.yaml
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
systemctl enable -q --now matrix-synapse systemctl enable -q --now matrix-synapse
$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
temp_file=$(mktemp)
mkdir -p /opt/synapse-admin
RELEASE=$(curl -fsSL https://api.github.com/repos/etkecc/synapse-admin/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
curl -fsSL "https://github.com/etkecc/synapse-admin/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
tar xzf "$temp_file" -C /opt/synapse-admin
cd /opt/synapse-admin
$STD yarn install --ignore-engines
msg_ok "Installed Element Synapse" msg_ok "Installed Element Synapse"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/synapse-admin.service
[Unit]
Description=Excalidraw Service
After=network.target
Requires=matrix-synapse.service
[Service]
Type=simple
WorkingDirectory=/opt/synapse-admin
ExecStart=/usr/bin/yarn start --host
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now synapse-admin
msg_ok "Created Service"
motd_ssh motd_ssh
customize customize