Skip to content

Commit 553dea2

Browse files
authored
Fix Installers / Build script for web terminal (hestiacp#3890)
* Update the installer * Update auto compile script to include install nodejs And some more improvements to installers * Mute output
1 parent 2e853b6 commit 553dea2

File tree

5 files changed

+86
-21
lines changed

5 files changed

+86
-21
lines changed

bin/v-add-sys-web-terminal

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,19 @@ check_hestia_demo_mode
3636
# Updating WEB_TERMINAL value
3737
$BIN/v-change-sys-config-value "WEB_TERMINAL" "true"
3838

39-
# Check if nodejs and hestia-web-terminal are installed
40-
if [ ! -f "/usr/bin/node" ] || [ ! -f "$HESTIA/web-terminal/server.js" ]; then
39+
# Check if nodejs is installed if not install repo
40+
apt="/etc/apt/sources.list.d"
41+
codename="$(lsb_release -s -c)"
42+
43+
if [ ! -z $(which "node") ]; then
44+
echo "Adding NodeJS 20.x repo..."
45+
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x $codename main" > $apt/nodesource.list
46+
echo "deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x $codename main" >> $apt/nodesource.list
47+
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg > /dev/null 2>&1
48+
fi
49+
50+
if [ ! -f "$HESTIA/web-terminal/server.js" ]; then
51+
# Install hestia-web-terminal package + nodejs
4152
apt-get -qq update
4253
apt-get -qq install nodejs hestia-web-terminal -y
4354
else

install/hst-install-debian.sh

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ done
238238
eval set -- "$args"
239239

240240
# Parsing arguments
241-
while getopts "a:w:v:j:k:m:M:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
241+
while getopts "a:w:v:j:k:m:M:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:W:D:fh" Option; do
242242
case $Option in
243243
a) apache=$OPTARG ;; # Apache
244244
w) phpfpm=$OPTARG ;; # PHP-FPM
@@ -589,6 +589,10 @@ if [ "$proftpd" = 'yes' ]; then
589589
echo ' - ProFTPD FTP Server'
590590
fi
591591

592+
if [ "$webterminal" = 'yes' ]; then
593+
echo ' - Web terminal'
594+
fi
595+
592596
# Firewall stack
593597
if [ "$iptables" = 'yes' ]; then
594598
echo -n ' - Firewall (iptables)'
@@ -1035,6 +1039,16 @@ if [ -n "$withdebs" ] && [ -d "$withdebs" ]; then
10351039
echo " - hestia-nginx backend package"
10361040
dpkg -i $withdebs/hestia-nginx_*.deb > /dev/null 2>&1
10371041
fi
1042+
1043+
if [ "$webterminal" = "yes" ]; then
1044+
if [ -z $(ls $withdebs/hestia-web-terminal_*.deb 2> /dev/null) ]; then
1045+
echo " - hestia-web-terminal package (from apt)"
1046+
apt-get -y install hestia-web-terminal > /dev/null 2>&1
1047+
else
1048+
echo " - hestia-web-terminal"
1049+
dpkg -i $withdebs/hestia-web-terminal_*.deb > /dev/null 2>&1
1050+
fi
1051+
fi
10381052
fi
10391053

10401054
# Restoring autostart policy
@@ -1246,12 +1260,6 @@ else
12461260
write_config_value "DISK_QUOTA" "no"
12471261
fi
12481262

1249-
# Web terminal
1250-
if [ "$webterminal" = 'yes' ]; then
1251-
write_config_value "WEB_TERMINAL" "true"
1252-
else
1253-
write_config_value "WEB_TERMINAL" "false"
1254-
fi
12551263
write_config_value "WEB_TERMINAL_PORT" "8085"
12561264

12571265
# Backups
@@ -2093,6 +2101,20 @@ else
20932101
$HESTIA/bin/v-change-sys-api disable
20942102
fi
20952103

2104+
#----------------------------------------------------------#
2105+
# Configure Web terminal #
2106+
#----------------------------------------------------------#
2107+
2108+
# Web terminal
2109+
if [ "$webterminal" = 'yes' ]; then
2110+
write_config_value "WEB_TERMINAL" "true"
2111+
systemctl daemon-reload > /dev/null 2>&1
2112+
systemctl enable hestia-web-terminal > /dev/null 2>&1
2113+
systemctl restart hestia-web-terminal > /dev/null 2>&1
2114+
else
2115+
write_config_value "WEB_TERMINAL" "false"
2116+
fi
2117+
20962118
#----------------------------------------------------------#
20972119
# Configure File Manager #
20982120
#----------------------------------------------------------#

install/hst-install-ubuntu.sh

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ done
238238
eval set -- "$args"
239239

240240
# Parsing arguments
241-
while getopts "a:w:v:j:k:m:M:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
241+
while getopts "a:w:v:j:k:m:M:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:W:D:fh" Option; do
242242
case $Option in
243243
a) apache=$OPTARG ;; # Apache
244244
w) phpfpm=$OPTARG ;; # PHP-FPM
@@ -575,6 +575,10 @@ if [ "$proftpd" = 'yes' ]; then
575575
echo ' - ProFTPD FTP Server'
576576
fi
577577

578+
if [ "$webterminal" = 'yes' ]; then
579+
echo ' - Web terminal'
580+
fi
581+
578582
# Firewall stack
579583
if [ "$iptables" = 'yes' ]; then
580584
echo -n ' - Firewall (iptables)'
@@ -936,6 +940,7 @@ fi
936940
if [ -d "$withdebs" ]; then
937941
software=$(echo "$software" | sed -e "s/hestia-nginx//")
938942
software=$(echo "$software" | sed -e "s/hestia-php//")
943+
software=$(echo "$software" | sed -e "s/hestia-web-terminal//")
939944
software=$(echo "$software" | sed -e "s/hestia=${HESTIA_INSTALL_VER}//")
940945
fi
941946
if [ "$release" = '20.04' ]; then
@@ -1015,6 +1020,16 @@ if [ -n "$withdebs" ] && [ -d "$withdebs" ]; then
10151020
echo " - hestia-nginx backend package"
10161021
dpkg -i $withdebs/hestia-nginx_*.deb > /dev/null 2>&1
10171022
fi
1023+
1024+
if [ "$webterminal" = "yes" ]; then
1025+
if [ -z $(ls $withdebs/hestia-web-terminal_*.deb 2> /dev/null) ]; then
1026+
echo " - hestia-web-terminal package (from apt)"
1027+
apt-get -y install hestia-web-terminal > /dev/null 2>&1
1028+
else
1029+
echo " - hestia-web-terminal"
1030+
dpkg -i $withdebs/hestia-web-terminal_*.deb > /dev/null 2>&1
1031+
fi
1032+
fi
10181033
fi
10191034

10201035
# Restoring autostart policy
@@ -1257,12 +1272,6 @@ else
12571272
write_config_value "DISK_QUOTA" "no"
12581273
fi
12591274

1260-
# Web terminal
1261-
if [ "$webterminal" = 'yes' ]; then
1262-
write_config_value "WEB_TERMINAL" "true"
1263-
else
1264-
write_config_value "WEB_TERMINAL" "false"
1265-
fi
12661275
write_config_value "WEB_TERMINAL_PORT" "8085"
12671276

12681277
# Backups
@@ -2074,6 +2083,20 @@ fi
20742083
echo "[ * ] Configuring File Manager..."
20752084
$HESTIA/bin/v-add-sys-filemanager quiet
20762085

2086+
#----------------------------------------------------------#
2087+
# Configure Web terminal #
2088+
#----------------------------------------------------------#
2089+
2090+
# Web terminal
2091+
if [ "$webterminal" = 'yes' ]; then
2092+
write_config_value "WEB_TERMINAL" "true"
2093+
systemctl daemon-reload > /dev/null 2>&1
2094+
systemctl enable hestia-web-terminal > /dev/null 2>&1
2095+
systemctl restart hestia-web-terminal > /dev/null 2>&1
2096+
else
2097+
write_config_value "WEB_TERMINAL" "false"
2098+
fi
2099+
20772100
#----------------------------------------------------------#
20782101
# Configure dependencies #
20792102
#----------------------------------------------------------#

src/deb/web-terminal/postinst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ source /usr/local/hestia/func/upgrade.sh
2727
source /usr/local/hestia/conf/hestia.conf
2828
source /usr/local/hestia/install/upgrade/upgrade.conf
2929

30-
# Restart hestia-web-terminal service
30+
# Restart hestia-web-terminal service if enabled
3131
if [ -f "/etc/systemd/system/hestia-web-terminal.service" ]; then
3232
systemctl daemon-reload > /dev/null 2>&1
33-
systemctl enable hestia-web-terminal > /dev/null 2>&1
34-
systemctl restart hestia-web-terminal > /dev/null 2>&1
33+
if systemctl is-enabled hestia-web-terminal > /dev/null 2>&1; then
34+
systemctl restart hestia-web-terminal
35+
fi
3536
fi

src/hst_autocompile.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ if [ "$dontinstalldeps" != 'true' ]; then
273273
SOFTWARE='wget tar git curl build-essential libxml2-dev libz-dev libzip-dev libgmp-dev libcurl4-gnutls-dev unzip openssl nodejs libssl-dev pkg-config libsqlite3-dev libonig-dev rpm lsb-release'
274274

275275
# Installing NodeJS 20.x repo
276-
if [ ! -f $apt/nodesource.list ] && [ ! -z $(which "node") ]; then
276+
apt="/etc/apt/sources.list.d"
277+
codename="$(lsb_release -s -c)"
278+
279+
if [ -z $(which "node") ]; then
277280
echo "Adding NodeJS 20.x repo..."
278281
echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x $codename main" > $apt/nodesource.list
279282
echo "deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x $codename main" >> $apt/nodesource.list
@@ -285,6 +288,11 @@ if [ "$dontinstalldeps" != 'true' ]; then
285288
echo "Installing dependencies for compilation..."
286289
apt-get -qq install -y $SOFTWARE > /dev/null 2>&1
287290

291+
nodejs_version=$(/usr/bin/node -v | cut -f1 -d'.' | sed 's/v//g')
292+
if [ "$nodejs_version" -lt 18 ]; then
293+
echo "Requires NodeJS 18.x or higher"
294+
exit 1
295+
fi
288296
# Fix for Debian PHP Envroiment
289297
if [ $BUILD_ARCH == "amd64" ]; then
290298
if [ ! -L /usr/local/include/curl ]; then
@@ -738,7 +746,7 @@ if [ "$HESTIA_B" = true ]; then
738746

739747
# Build web and move needed directories
740748
cd $BUILD_DIR/hestiacp-$branch_dash
741-
npm ci
749+
npm ci --ignore-scripts
742750
npm run build
743751
cp -rf bin func install web $BUILD_DIR_HESTIA/usr/local/hestia/
744752

0 commit comments

Comments
 (0)