Browse Source

Fix Installers / Build script for web terminal (#3890)

* Update the installer

* Update auto compile script to include install nodejs

And some more improvements to installers

* Mute output
Jaap Marcus 2 years ago
parent
commit
553dea230f

+ 13 - 2
bin/v-add-sys-web-terminal

@@ -36,8 +36,19 @@ check_hestia_demo_mode
 # Updating WEB_TERMINAL value
 $BIN/v-change-sys-config-value "WEB_TERMINAL" "true"
 
-# Check if nodejs and hestia-web-terminal are installed
-if [ ! -f "/usr/bin/node" ] || [ ! -f "$HESTIA/web-terminal/server.js" ]; then
+# Check if nodejs is installed if not install repo
+apt="/etc/apt/sources.list.d"
+codename="$(lsb_release -s -c)"
+
+if [ ! -z $(which "node") ]; then
+	echo "Adding NodeJS 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

+ 29 - 7
install/hst-install-debian.sh

@@ -238,7 +238,7 @@ done
 eval set -- "$args"
 
 # Parsing arguments
-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
+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
 	case $Option in
 		a) apache=$OPTARG ;;      # Apache
 		w) phpfpm=$OPTARG ;;      # PHP-FPM
@@ -589,6 +589,10 @@ if [ "$proftpd" = 'yes' ]; then
 	echo '   - ProFTPD FTP Server'
 fi
 
+if [ "$webterminal" = 'yes' ]; then
+	echo '   - Web terminal'
+fi
+
 # Firewall stack
 if [ "$iptables" = 'yes' ]; then
 	echo -n '   - Firewall (iptables)'
@@ -1035,6 +1039,16 @@ if [ -n "$withdebs" ] && [ -d "$withdebs" ]; then
 		echo "    - hestia-nginx backend package"
 		dpkg -i $withdebs/hestia-nginx_*.deb > /dev/null 2>&1
 	fi
+
+	if [ "$webterminal" = "yes" ]; then
+		if [ -z $(ls $withdebs/hestia-web-terminal_*.deb 2> /dev/null) ]; then
+			echo "    - hestia-web-terminal package (from apt)"
+			apt-get -y install hestia-web-terminal > /dev/null 2>&1
+		else
+			echo "    - hestia-web-terminal"
+			dpkg -i $withdebs/hestia-web-terminal_*.deb > /dev/null 2>&1
+		fi
+	fi
 fi
 
 # Restoring autostart policy
@@ -1246,12 +1260,6 @@ else
 	write_config_value "DISK_QUOTA" "no"
 fi
 
-# Web terminal
-if [ "$webterminal" = 'yes' ]; then
-	write_config_value "WEB_TERMINAL" "true"
-else
-	write_config_value "WEB_TERMINAL" "false"
-fi
 write_config_value "WEB_TERMINAL_PORT" "8085"
 
 # Backups
@@ -2093,6 +2101,20 @@ else
 	$HESTIA/bin/v-change-sys-api disable
 fi
 
+#----------------------------------------------------------#
+#              Configure Web terminal                      #
+#----------------------------------------------------------#
+
+# Web terminal
+if [ "$webterminal" = 'yes' ]; then
+	write_config_value "WEB_TERMINAL" "true"
+	systemctl daemon-reload > /dev/null 2>&1
+	systemctl enable hestia-web-terminal > /dev/null 2>&1
+	systemctl restart hestia-web-terminal > /dev/null 2>&1
+else
+	write_config_value "WEB_TERMINAL" "false"
+fi
+
 #----------------------------------------------------------#
 #                  Configure File Manager                  #
 #----------------------------------------------------------#

+ 30 - 7
install/hst-install-ubuntu.sh

@@ -238,7 +238,7 @@ done
 eval set -- "$args"
 
 # Parsing arguments
-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
+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
 	case $Option in
 		a) apache=$OPTARG ;;      # Apache
 		w) phpfpm=$OPTARG ;;      # PHP-FPM
@@ -575,6 +575,10 @@ if [ "$proftpd" = 'yes' ]; then
 	echo '   - ProFTPD FTP Server'
 fi
 
+if [ "$webterminal" = 'yes' ]; then
+	echo '   - Web terminal'
+fi
+
 # Firewall stack
 if [ "$iptables" = 'yes' ]; then
 	echo -n '   - Firewall (iptables)'
@@ -936,6 +940,7 @@ fi
 if [ -d "$withdebs" ]; then
 	software=$(echo "$software" | sed -e "s/hestia-nginx//")
 	software=$(echo "$software" | sed -e "s/hestia-php//")
+	software=$(echo "$software" | sed -e "s/hestia-web-terminal//")
 	software=$(echo "$software" | sed -e "s/hestia=${HESTIA_INSTALL_VER}//")
 fi
 if [ "$release" = '20.04' ]; then
@@ -1015,6 +1020,16 @@ if [ -n "$withdebs" ] && [ -d "$withdebs" ]; then
 		echo "    - hestia-nginx backend package"
 		dpkg -i $withdebs/hestia-nginx_*.deb > /dev/null 2>&1
 	fi
+
+	if [ "$webterminal" = "yes" ]; then
+		if [ -z $(ls $withdebs/hestia-web-terminal_*.deb 2> /dev/null) ]; then
+			echo "    - hestia-web-terminal package (from apt)"
+			apt-get -y install hestia-web-terminal > /dev/null 2>&1
+		else
+			echo "    - hestia-web-terminal"
+			dpkg -i $withdebs/hestia-web-terminal_*.deb > /dev/null 2>&1
+		fi
+	fi
 fi
 
 # Restoring autostart policy
@@ -1257,12 +1272,6 @@ else
 	write_config_value "DISK_QUOTA" "no"
 fi
 
-# Web terminal
-if [ "$webterminal" = 'yes' ]; then
-	write_config_value "WEB_TERMINAL" "true"
-else
-	write_config_value "WEB_TERMINAL" "false"
-fi
 write_config_value "WEB_TERMINAL_PORT" "8085"
 
 # Backups
@@ -2074,6 +2083,20 @@ fi
 echo "[ * ] Configuring File Manager..."
 $HESTIA/bin/v-add-sys-filemanager quiet
 
+#----------------------------------------------------------#
+#              Configure Web terminal                      #
+#----------------------------------------------------------#
+
+# Web terminal
+if [ "$webterminal" = 'yes' ]; then
+	write_config_value "WEB_TERMINAL" "true"
+	systemctl daemon-reload > /dev/null 2>&1
+	systemctl enable hestia-web-terminal > /dev/null 2>&1
+	systemctl restart hestia-web-terminal > /dev/null 2>&1
+else
+	write_config_value "WEB_TERMINAL" "false"
+fi
+
 #----------------------------------------------------------#
 #                  Configure dependencies                  #
 #----------------------------------------------------------#

+ 4 - 3
src/deb/web-terminal/postinst

@@ -27,9 +27,10 @@ source /usr/local/hestia/func/upgrade.sh
 source /usr/local/hestia/conf/hestia.conf
 source /usr/local/hestia/install/upgrade/upgrade.conf
 
-# Restart hestia-web-terminal service
+# Restart hestia-web-terminal service if enabled
 if [ -f "/etc/systemd/system/hestia-web-terminal.service" ]; then
 	systemctl daemon-reload > /dev/null 2>&1
-	systemctl enable hestia-web-terminal > /dev/null 2>&1
-	systemctl restart hestia-web-terminal > /dev/null 2>&1
+	if systemctl is-enabled hestia-web-terminal > /dev/null 2>&1; then
+		systemctl restart hestia-web-terminal
+	fi
 fi

+ 10 - 2
src/hst_autocompile.sh

@@ -273,7 +273,10 @@ if [ "$dontinstalldeps" != 'true' ]; then
 		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'
 
 		# Installing NodeJS 20.x repo
-		if [ ! -f $apt/nodesource.list ] && [ ! -z $(which "node") ]; then
+		apt="/etc/apt/sources.list.d"
+		codename="$(lsb_release -s -c)"
+
+		if [ -z $(which "node") ]; then
 			echo "Adding NodeJS 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
@@ -285,6 +288,11 @@ if [ "$dontinstalldeps" != 'true' ]; then
 		echo "Installing dependencies for compilation..."
 		apt-get -qq install -y $SOFTWARE > /dev/null 2>&1
 
+		nodejs_version=$(/usr/bin/node -v | cut -f1 -d'.' | sed 's/v//g')
+		if [ "$nodejs_version" -lt 18 ]; then
+			echo "Requires NodeJS 18.x or higher"
+			exit 1
+		fi
 		# Fix for Debian PHP Envroiment
 		if [ $BUILD_ARCH == "amd64" ]; then
 			if [ ! -L /usr/local/include/curl ]; then
@@ -738,7 +746,7 @@ if [ "$HESTIA_B" = true ]; then
 
 			# Build web and move needed directories
 			cd $BUILD_DIR/hestiacp-$branch_dash
-			npm ci
+			npm ci --ignore-scripts
 			npm run build
 			cp -rf bin func install web $BUILD_DIR_HESTIA/usr/local/hestia/