Skip to content

Commit 341489e

Browse files
authored
Termix: add guacd build and systemd integration (#12999)
1 parent ee78294 commit 341489e

File tree

2 files changed

+143
-8
lines changed

2 files changed

+143
-8
lines changed

ct/termix.sh

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,87 @@ function update_script() {
2929
exit
3030
fi
3131

32+
if check_for_gh_tag "guacd" "apache/guacamole-server"; then
33+
msg_info "Stopping guacd"
34+
systemctl stop guacd 2>/dev/null || true
35+
msg_ok "Stopped guacd"
36+
37+
ensure_dependencies \
38+
libcairo2-dev \
39+
libjpeg62-turbo-dev \
40+
libpng-dev \
41+
libtool-bin \
42+
uuid-dev \
43+
libvncserver-dev \
44+
freerdp3-dev \
45+
libssh2-1-dev \
46+
libtelnet-dev \
47+
libwebsockets-dev \
48+
libpulse-dev \
49+
libvorbis-dev \
50+
libwebp-dev \
51+
libssl-dev \
52+
libpango1.0-dev \
53+
libswscale-dev \
54+
libavcodec-dev \
55+
libavutil-dev \
56+
libavformat-dev
57+
58+
msg_info "Updating Guacamole Server (guacd)"
59+
fetch_and_deploy_gh_tag "guacd" "apache/guacamole-server" "${CHECK_UPDATE_RELEASE}" "/opt/guacamole-server"
60+
cd /opt/guacamole-server
61+
export CPPFLAGS="-Wno-error=deprecated-declarations"
62+
$STD autoreconf -fi
63+
$STD ./configure --with-init-dir=/etc/init.d --enable-allow-freerdp-snapshots
64+
$STD make
65+
$STD make install
66+
$STD ldconfig
67+
cd /opt
68+
rm -rf /opt/guacamole-server
69+
msg_ok "Updated Guacamole Server (guacd) to ${CHECK_UPDATE_RELEASE}"
70+
71+
if [[ ! -f /etc/guacamole/guacd.conf ]]; then
72+
mkdir -p /etc/guacamole
73+
cat <<EOF >/etc/guacamole/guacd.conf
74+
[server]
75+
bind_host = 127.0.0.1
76+
bind_port = 4822
77+
EOF
78+
fi
79+
80+
if [[ ! -f /etc/systemd/system/guacd.service ]]; then
81+
cat <<EOF >/etc/systemd/system/guacd.service
82+
[Unit]
83+
Description=Guacamole Proxy Daemon (guacd)
84+
After=network.target
85+
86+
[Service]
87+
Type=forking
88+
ExecStart=/etc/init.d/guacd start
89+
ExecStop=/etc/init.d/guacd stop
90+
ExecReload=/etc/init.d/guacd restart
91+
PIDFile=/var/run/guacd.pid
92+
Restart=on-failure
93+
RestartSec=5
94+
95+
[Install]
96+
WantedBy=multi-user.target
97+
EOF
98+
fi
99+
100+
if ! grep -q "guacd.service" /etc/systemd/system/termix.service 2>/dev/null; then
101+
sed -i '/^After=network.target/s/$/ guacd.service/' /etc/systemd/system/termix.service
102+
sed -i '/^\[Unit\]/a Wants=guacd.service' /etc/systemd/system/termix.service
103+
fi
104+
105+
systemctl daemon-reload
106+
systemctl enable -q --now guacd
107+
fi
108+
32109
if check_for_gh_release "termix" "Termix-SSH/Termix"; then
33-
msg_info "Stopping Service"
110+
msg_info "Stopping Termix"
34111
systemctl stop termix
35-
msg_ok "Stopped Service"
112+
msg_ok "Stopped Termix"
36113

37114
msg_info "Backing up Data"
38115
cp -r /opt/termix/data /opt/termix_data_backup
@@ -95,16 +172,16 @@ function update_script() {
95172
sed -i 's|/app/html|/opt/termix/html|g' /etc/nginx/nginx.conf
96173
sed -i 's|/app/nginx|/opt/termix/nginx|g' /etc/nginx/nginx.conf
97174
sed -i 's|listen ${PORT};|listen 80;|g' /etc/nginx/nginx.conf
98-
175+
99176
nginx -t && systemctl reload nginx
100177
msg_ok "Updated Nginx Configuration"
101178
else
102179
msg_warn "Nginx configuration not updated. If Termix doesn't work, restore from backup or update manually."
103180
fi
104181

105-
msg_info "Starting Service"
182+
msg_info "Starting Termix"
106183
systemctl start termix
107-
msg_ok "Started Service"
184+
msg_ok "Started Termix"
108185
msg_ok "Updated successfully!"
109186
fi
110187
exit

install/termix-install.sh

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,41 @@ $STD apt install -y \
1919
python3 \
2020
nginx \
2121
openssl \
22-
gettext-base
22+
gettext-base \
23+
libcairo2-dev \
24+
libjpeg62-turbo-dev \
25+
libpng-dev \
26+
libtool-bin \
27+
uuid-dev \
28+
libvncserver-dev \
29+
freerdp3-dev \
30+
libssh2-1-dev \
31+
libtelnet-dev \
32+
libwebsockets-dev \
33+
libpulse-dev \
34+
libvorbis-dev \
35+
libwebp-dev \
36+
libssl-dev \
37+
libpango1.0-dev \
38+
libswscale-dev \
39+
libavcodec-dev \
40+
libavutil-dev \
41+
libavformat-dev
2342
msg_ok "Installed Dependencies"
2443

44+
msg_info "Building Guacamole Server (guacd)"
45+
fetch_and_deploy_gh_tag "guacd" "apache/guacamole-server" "latest" "/opt/guacamole-server"
46+
cd /opt/guacamole-server
47+
export CPPFLAGS="-Wno-error=deprecated-declarations"
48+
$STD autoreconf -fi
49+
$STD ./configure --with-init-dir=/etc/init.d --enable-allow-freerdp-snapshots
50+
$STD make
51+
$STD make install
52+
$STD ldconfig
53+
cd /opt
54+
rm -rf /opt/guacamole-server
55+
msg_ok "Built Guacamole Server (guacd)"
56+
2557
NODE_VERSION="22" setup_nodejs
2658
fetch_and_deploy_gh_release "termix" "Termix-SSH/Termix"
2759

@@ -74,10 +106,36 @@ systemctl reload nginx
74106
msg_ok "Configured Nginx"
75107

76108
msg_info "Creating Service"
109+
mkdir -p /etc/guacamole
110+
cat <<EOF >/etc/guacamole/guacd.conf
111+
[server]
112+
bind_host = 127.0.0.1
113+
bind_port = 4822
114+
EOF
115+
116+
cat <<EOF >/etc/systemd/system/guacd.service
117+
[Unit]
118+
Description=Guacamole Proxy Daemon (guacd)
119+
After=network.target
120+
121+
[Service]
122+
Type=forking
123+
ExecStart=/etc/init.d/guacd start
124+
ExecStop=/etc/init.d/guacd stop
125+
ExecReload=/etc/init.d/guacd restart
126+
PIDFile=/var/run/guacd.pid
127+
Restart=on-failure
128+
RestartSec=5
129+
130+
[Install]
131+
WantedBy=multi-user.target
132+
EOF
133+
77134
cat <<EOF >/etc/systemd/system/termix.service
78135
[Unit]
79136
Description=Termix Backend
80-
After=network.target
137+
After=network.target guacd.service
138+
Wants=guacd.service
81139
82140
[Service]
83141
Type=simple
@@ -92,7 +150,7 @@ RestartSec=5
92150
[Install]
93151
WantedBy=multi-user.target
94152
EOF
95-
systemctl enable -q --now termix
153+
systemctl enable -q --now guacd termix
96154
msg_ok "Created Service"
97155

98156
motd_ssh

0 commit comments

Comments
 (0)