forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-add-sys-web-terminal
More file actions
executable file
·68 lines (55 loc) · 2.28 KB
/
v-add-sys-web-terminal
File metadata and controls
executable file
·68 lines (55 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# info: add system web terminal
# options: NONE
#
# example: v-add-sys-web-terminal
#
# This function enables the web terminal.
#----------------------------------------------------------#
# Variables & Functions #
#----------------------------------------------------------#
# Includes
# shellcheck source=/etc/hestiacp/hestia.conf
source /etc/hestiacp/hestia.conf
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# load config file
source_conf "$HESTIA/conf/hestia.conf"
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
if [ "$WEB_TERMINAL" = 'true' ]; then
exit
fi
# Perform verification if read-only mode is enabled
check_hestia_demo_mode
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Updating WEB_TERMINAL value
$BIN/v-change-sys-config-value "WEB_TERMINAL" "true"
# Check if Node.js is installed if not install repo
apt="/etc/apt/sources.list.d"
codename="$(lsb_release -s -c)"
if [ ! -z $(which "node") ]; then
echo "Adding Node.js 20.x repo..."
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x $codename main" > $apt/nodesource.list
echo "deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x $codename main" >> $apt/nodesource.list
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg > /dev/null 2>&1
fi
if [ ! -f "$HESTIA/web-terminal/server.js" ]; then
# Install hestia-web-terminal package + nodejs
apt-get -qq update
apt-get -qq install nodejs hestia-web-terminal -y
else
# Starting web terminal websocket server
$BIN/v-start-service "hestia-web-terminal"
systemctl enable hestia-web-terminal
fi
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Logging
$BIN/v-log-action "system" "Info" "Web Terminal" "Web terminal enabled."
log_event "$OK" "$ARGUMENTS"
exit