Skip to content

Commit 82d063e

Browse files
Chore/config updates (hestiacp#4470)
* Bugfix: Initial Node.js setup * Cleanup tmp directory after app install * Streamline Node.js installation when needed * Run NPM run format --------- Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent 5339750 commit 82d063e

File tree

6 files changed

+48
-37
lines changed

6 files changed

+48
-37
lines changed

bin/v-add-sys-web-terminal

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

39-
# Check if Node.js is installed if not install repo
39+
# Detect and install Node.js if necessary
4040
apt="/etc/apt/sources.list.d"
41-
codename="$(lsb_release -s -c)"
41+
node_v="20"
4242

43-
if [ ! -z $(which "node") ]; then
44-
echo "Adding Node.js 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
43+
if [ $(uname -m) = "x86_64" ]; then
44+
ARCH=amd64
45+
elif [ $(uname -m) = "aarch64" ]; then
46+
ARCH=arm64
47+
fi
48+
49+
if [ -z $(which "node") ]; then
50+
echo "Installing Node.js $node_v"
51+
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/nodejs.gpg] https://deb.nodesource.com/node_$node_v.x nodistro main" > $apt/nodejs.list
52+
curl -s https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodejs.gpg > /dev/null 2>&1
53+
apt-get -qq install nodejs -y
54+
else
55+
node_v_installed=$(/usr/bin/node -v | cut -f1 -d'.' | sed 's/v//g')
56+
if [ "$node_v_installed" -lt "$node_v" ]; then
57+
echo "Web Terminal requires Node.js 20.x or higher"
58+
exit 1
59+
fi
4860
fi
4961

5062
if [ ! -f "$HESTIA/web-terminal/server.js" ]; then
51-
# Install hestia-web-terminal package + nodejs
5263
apt-get -qq update
53-
apt-get -qq install nodejs hestia-web-terminal -y
64+
apt-get -qq install hestia-web-terminal -y
5465
else
5566
# Starting web terminal websocket server
5667
$BIN/v-start-service "hestia-web-terminal"

bin/v-update-sys-hestia-git

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,23 @@ source /etc/hestiacp/hestia.conf
2020
source $HESTIA/func/main.sh
2121
# load config file
2222
source_conf "$HESTIA/conf/hestia.conf"
23-
# define Node.js version for download (required for building JS/CSS)
24-
NODE_MAJOR=20
2523

2624
# Perform verification if read-only mode is enabled
2725
check_hestia_demo_mode
2826

2927
# Detect and install Node.js if necessary
3028
if [ -z $(which "node") ]; then
31-
read -p "Node.js not found. Install now to proceed? [Y/n] " answer
32-
if [ "$answer" = 'y' ] || [ "$answer" = 'Y' ]; then
33-
sudo mkdir -p /etc/apt/keyrings
34-
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
35-
36-
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
37-
sudo apt-get install -y nodejs
38-
else
39-
exit 0
29+
echo "Installing Node.js $node_v"
30+
apt="/etc/apt/sources.list.d"
31+
node_v="20"
32+
if [ $(uname -m) = "x86_64" ]; then
33+
ARCH=amd64
34+
elif [ $(uname -m) = "aarch64" ]; then
35+
ARCH=arm64
4036
fi
37+
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/nodejs.gpg] https://deb.nodesource.com/node_$node_v.x nodistro main" > $apt/nodejs.list
38+
curl -s https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodejs.gpg > /dev/null 2>&1
39+
apt-get -qq install nodejs -y
4140
fi
4241

4342
# Define download function

install/hst-install-debian.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ if [ "$webterminal" = 'yes' ]; then
871871
echo "[ * ] Node.js $node_v"
872872
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/nodejs.gpg] https://deb.nodesource.com/node_$node_v.x nodistro main" > $apt/nodejs.list
873873
curl -s https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodejs.gpg > /dev/null 2>&1
874-
curl -fsSL https://deb.nodesource.com/setup_$node_v.x | bash -
874+
apt-get -y install nodejs > $LOG
875875
fi
876876

877877
# Installing PostgreSQL repo
@@ -2352,7 +2352,7 @@ chown hestiaweb:hestiaweb /var/spool/cron/crontabs/hestiaweb
23522352
# Enable automatic updates
23532353
$HESTIA/bin/v-add-cron-hestia-autoupdate apt
23542354

2355-
# Building initital rrd images
2355+
# Building initial rrd images
23562356
$HESTIA/bin/v-update-sys-rrd
23572357

23582358
# Enabling file system quota

install/hst-install-ubuntu.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ if [ "$webterminal" = 'yes' ]; then
841841
echo "[ * ] Node.js $node_v"
842842
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/nodejs.gpg] https://deb.nodesource.com/node_$node_v.x nodistro main" > $apt/nodejs.list
843843
curl -s https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodejs.gpg > /dev/null 2>&1
844-
curl -fsSL https://deb.nodesource.com/setup_$node_v.x | bash -
844+
apt-get -y install nodejs > $LOG
845845
fi
846846

847847
# Installing PostgreSQL repo
@@ -2346,7 +2346,7 @@ chown hestiaweb:hestiaweb /var/spool/cron/crontabs/hestiaweb
23462346
# Enable automatic updates
23472347
$HESTIA/bin/v-add-cron-hestia-autoupdate apt
23482348

2349-
# Building initital rrd images
2349+
# Building initial rrd images
23502350
$HESTIA/bin/v-update-sys-rrd
23512351

23522352
# Enabling file system quota

install/upgrade/versions/1.9.0.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ upgrade_config_set_value 'UPGRADE_UPDATE_FILEMANAGER_CONFIG' 'false'
2727
$BIN/v-delete-sys-sftp-jail
2828
$BIN/v-add-sys-sftp-jail
2929

30-
codename="$(lsb_release -s -c)"
31-
apt=/etc/apt/sources.list.d
32-
33-
# Installing Node.js repo
34-
if [ "$webterminal" = 'yes' ]; then
35-
node_v="20"
36-
echo "[ * ] Adding Node.js $node_v repo and install"
37-
echo "deb [arch=$ARCH signed-by=/usr/share/keyrings/nodejs.gpg] https://deb.nodesource.com/node_$node_v.x nodistro main" > $apt/nodejs.list
38-
curl -s https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodejs.gpg > /dev/null 2>&1
39-
curl -fsSL https://deb.nodesource.com/setup_$node_v.x | bash -
40-
fi
41-
4230
# Check if hestiaweb exists
4331
if [ -z "$(grep ^hestiaweb: /etc/passwd)" ]; then
4432
# Generate a random password
@@ -50,7 +38,7 @@ if [ -z "$(grep ^hestiaweb: /etc/passwd)" ]; then
5038
cp $HESTIA_COMMON_DIR/sudo/hestiaweb /etc/sudoers.d/
5139
# Keep enabled for now
5240
# Remove sudo permissions admin user
53-
#rm /etc/sudoers.d/admin/
41+
# rm /etc/sudoers.d/admin/
5442
fi
5543

5644
# Check if cronjobs have been migrated

web/src/app/System/HestiaApp.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,17 @@ public function archiveExtract(string $src, string $path, $skip_components = nul
350350

351351
return $result;
352352
}
353+
354+
public function cleanupTmpDir(): void {
355+
$files = glob(self::TMPDIR_DOWNLOADS . "/*");
356+
foreach ($files as $file) {
357+
if (is_file($file)) {
358+
unlink($file);
359+
}
360+
}
361+
}
362+
363+
public function __destruct() {
364+
$this->cleanupTmpDir();
365+
}
353366
}

0 commit comments

Comments
 (0)