Skip to content

Commit de89dd9

Browse files
authored
Element Synapse: Add Synapse-Admin web UI to manage Matrix (#4010)
* Update script * Update
1 parent fb3d0b2 commit de89dd9

File tree

3 files changed

+139
-44
lines changed

3 files changed

+139
-44
lines changed

ct/elementsynapse.sh

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,52 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
header_info
24-
check_container_storage
25-
check_container_resources
26-
if [[ ! -d /etc/matrix-synapse ]]; then
27-
msg_error "No ${APP} Installation Found!"
28-
exit
29-
fi
30-
msg_info "Updating $APP LXC"
31-
$STD apt-get update
32-
$STD apt-get -y upgrade
33-
msg_ok "Updated $APP LXC"
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
if [[ ! -d /etc/matrix-synapse ]]; then
27+
msg_error "No ${APP} Installation Found!"
3428
exit
29+
fi
30+
if [[ ! -f /opt/"${APP}"_version.txt ]]; then
31+
touch /opt/"${APP}"_version.txt
32+
fi
33+
if ! dpkg -l | grep -q '^ii.*gpg'; then
34+
$STD apt-get update
35+
$STD apt-get install -y gpg
36+
fi
37+
if [[ ! -x /usr/bin/node ]]; then
38+
mkdir -p /etc/apt/keyrings
39+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
40+
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
41+
$STD apt-get update
42+
$STD apt-get install -y nodejs
43+
$STD npm install -g yarn
44+
fi
45+
msg_info "Updating $APP LXC"
46+
$STD apt-get update
47+
$STD apt-get -y upgrade
48+
msg_ok "Updated $APP LXC"
49+
50+
msg_info "Updating Synapse-Admin"
51+
RELEASE=$(curl -fsSL https://api.github.com/repos/etkecc/synapse-admin/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
52+
if [[ "${RELEASE}" != "$(cat /opt/"${APP}"_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
53+
temp_file=$(mktemp)
54+
systemctl stop synapse-admin
55+
rm -rf /opt/synapse-admin
56+
mkdir -p /opt/synapse-admin
57+
curl -fsSL "https://github.com/etkecc/synapse-admin/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
58+
tar xzf "$temp_file" -C /opt/synapse-admin
59+
cd /opt/synapse-admin
60+
$STD yarn install --ignore-engines
61+
systemctl start synapse-admin
62+
echo "${RELEASE}" >/opt/"${APP}"_version.txt
63+
rm -f "$temp_file"
64+
msg_ok "Update Successful"
65+
else
66+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
67+
fi
68+
exit
3569
}
3670

3771
start
@@ -41,4 +75,4 @@ description
4175
msg_ok "Completed Successfully!\n"
4276
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
4377
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
44-
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8008${CL}"
78+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8008${CL}"
Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
11
{
2-
"name": "Element Synapse",
3-
"slug": "elementsynapse",
4-
"categories": [
5-
4
6-
],
7-
"date_created": "2025-02-02",
8-
"type": "ct",
9-
"updateable": true,
10-
"privileged": false,
11-
"interface_port": 8008,
12-
"documentation": "https://element-hq.github.io/synapse/latest/welcome_and_overview.html",
13-
"website": "https://element.io/",
14-
"logo": "https://element.io/images/logo-mark-primary.svg",
15-
"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.",
16-
"install_methods": [
17-
{
18-
"type": "default",
19-
"script": "ct/elementsynapse.sh",
20-
"resources": {
21-
"cpu": 1,
22-
"ram": 1024,
23-
"hdd": 4,
24-
"os": "debian",
25-
"version": "12"
26-
}
2+
"name": "Element Synapse",
3+
"slug": "elementsynapse",
4+
"categories": [
5+
4
6+
],
7+
"date_created": "2025-02-02",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 8008,
12+
"documentation": "https://element-hq.github.io/synapse/latest/welcome_and_overview.html",
13+
"website": "https://element.io/",
14+
"logo": "https://element.io/images/logo-mark-primary.svg",
15+
"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.",
16+
"install_methods": [
17+
{
18+
"type": "default",
19+
"script": "ct/elementsynapse.sh",
20+
"resources": {
21+
"cpu": 1,
22+
"ram": 1024,
23+
"hdd": 4,
24+
"os": "debian",
25+
"version": "12"
2726
}
28-
],
29-
"default_credentials": {
30-
"username": null,
31-
"password": null
27+
}
28+
],
29+
"default_credentials": {
30+
"username": null,
31+
"password": null
32+
},
33+
"notes": [
34+
{
35+
"type": "info",
36+
"text": "Type `cat ~/matrix.creds` to see admin username/password."
3237
},
33-
"notes": []
34-
}
38+
{
39+
"type": "info",
40+
"text": "Synapse-Admin is running on port 5173"
41+
}
42+
]
43+
}

install/elementsynapse-install.sh

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,22 @@ msg_info "Installing Dependencies"
1717
$STD apt-get install -y \
1818
lsb-release \
1919
apt-transport-https \
20-
debconf-utils
20+
debconf-utils \
21+
gpg
2122
msg_ok "Installed Dependencies"
2223

24+
msg_info "Setting up Node.js Repository"
25+
mkdir -p /etc/apt/keyrings
26+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
27+
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
28+
msg_ok "Set up Node.js Repository"
29+
30+
msg_info "Installing Node.js"
31+
$STD apt-get update
32+
$STD apt-get install -y nodejs
33+
$STD npm install -g yarn
34+
msg_ok "Installed Node.js"
35+
2336
read -p "Please enter the name for your server: " servername
2437

2538
msg_info "Installing Element Synapse"
@@ -32,9 +45,48 @@ $STD apt-get install matrix-synapse-py3 -y
3245
systemctl stop matrix-synapse
3346
sed -i 's/127.0.0.1/0.0.0.0/g' /etc/matrix-synapse/homeserver.yaml
3447
sed -i 's/'\''::1'\'', //g' /etc/matrix-synapse/homeserver.yaml
48+
SECRET=$(openssl rand -hex 32)
49+
ADMIN_PASS="$(openssl rand -base64 18 | cut -c1-13)"
50+
echo "enable_registration_without_verification: true" >>/etc/matrix-synapse/homeserver.yaml
51+
echo "registration_shared_secret: ${SECRET}" >>/etc/matrix-synapse/homeserver.yaml
3552
systemctl enable -q --now matrix-synapse
53+
$STD register_new_matrix_user -a --user admin --password "$ADMIN_PASS" --config /etc/matrix-synapse/homeserver.yaml
54+
{
55+
echo "Matrix-Credentials"
56+
echo "Admin username: admin"
57+
echo "Admin password: $ADMIN_PASS"
58+
} >>~/matrix.creds
59+
systemctl stop matrix-synapse
60+
sed -i '34d' /etc/matrix-synapse/homeserver.yaml
61+
systemctl start matrix-synapse
62+
temp_file=$(mktemp)
63+
mkdir -p /opt/synapse-admin
64+
RELEASE=$(curl -fsSL https://api.github.com/repos/etkecc/synapse-admin/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
65+
curl -fsSL "https://github.com/etkecc/synapse-admin/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
66+
tar xzf "$temp_file" -C /opt/synapse-admin
67+
cd /opt/synapse-admin
68+
$STD yarn install --ignore-engines
3669
msg_ok "Installed Element Synapse"
3770

71+
msg_info "Creating Service"
72+
cat <<EOF >/etc/systemd/system/synapse-admin.service
73+
[Unit]
74+
Description=Excalidraw Service
75+
After=network.target
76+
Requires=matrix-synapse.service
77+
78+
[Service]
79+
Type=simple
80+
WorkingDirectory=/opt/synapse-admin
81+
ExecStart=/usr/bin/yarn start --host
82+
Restart=always
83+
84+
[Install]
85+
WantedBy=multi-user.target
86+
EOF
87+
systemctl enable -q --now synapse-admin
88+
msg_ok "Created Service"
89+
3890
motd_ssh
3991
customize
4092

0 commit comments

Comments
 (0)