Skip to content

Commit 78bd529

Browse files
author
Kristan Kenney
committed
[DevTools] Add ability to specify repository for v-update-sys-hestia-git
1 parent 2f59eeb commit 78bd529

File tree

1 file changed

+52
-20
lines changed

1 file changed

+52
-20
lines changed

bin/v-update-sys-hestia-git

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#!/bin/bash
22

3-
# Autocompile Script for HestiaCP deb Files.
3+
# v-update-sys-hestia-git
4+
# Downloads and compiles/installs packages from GitHub repositories
5+
# Options: REPOSITORY BRANCH INSTALL [PACKAGES]
6+
# Example: v-update-sys-hestia-git hestiacp staging/beta install all
7+
# - Will download from the hestiacp repository
8+
# - Pulls code from staging/beta branch
9+
# - install: installs package immediately
10+
# - 'all': (optional) - compiles nginx and php alongside panel.
11+
# this option takes a long time, only use when needed
12+
413

514
# Define download function
615
download_file() {
@@ -56,18 +65,20 @@ INSTALL_DIR='/usr/local/hestia'
5665
ARCHIVE_DIR="${BUILD_DIR}/archive"
5766

5867
# Set command variables
59-
branch=$1
60-
install=$2
68+
fork=$1
69+
branch=$2
70+
install=$3
71+
flags=$4
6172

6273
# Set Version for compiling
63-
BUILD_VER=$(curl -s https://raw.githubusercontent.com/hestiacp/hestiacp/$branch/src/deb/hestia/control | grep "Version:" | cut -d' ' -f2)
74+
BUILD_VER=$(curl -s https://raw.githubusercontent.com/$fork/hestiacp/$branch/src/deb/hestia/control | grep "Version:" | cut -d' ' -f2)
6475
BUILD_ARCH='amd64'
6576
HESTIA_V="${BUILD_VER}_${BUILD_ARCH}"
66-
NGINX_V=$(curl -s https://raw.githubusercontent.com/hestiacp/hestiacp/$branch/src/deb/nginx/control |grep "Version:" |cut -d' ' -f2)
67-
OPENSSL_V='1.1.1c'
77+
NGINX_V=$(curl -s https://raw.githubusercontent.com/$fork/hestiacp/$branch/src/deb/nginx/control |grep "Version:" |cut -d' ' -f2)
78+
OPENSSL_V='1.1.1g'
6879
PCRE_V='8.43'
6980
ZLIB_V='1.2.11'
70-
PHP_V=$(curl -s https://raw.githubusercontent.com/hestiacp/hestiacp/$branch/src/deb/php/control |grep "Version:" |cut -d' ' -f2)
81+
PHP_V=$(curl -s https://raw.githubusercontent.com/$fork/hestiacp/$branch/src/deb/php/control |grep "Version:" |cut -d' ' -f2)
7182

7283
# Create build directories
7384
rm -rf $BUILD_DIR
@@ -84,29 +95,42 @@ timestamp() {
8495

8596
# Set install flags
8697
if [ ! -z "$1" ]; then
98+
fork_check=$(curl -s --head -w %{http_code} https://raw.githubusercontent.com/$fork/hestiacp/release/src/deb/hestia/control -o /dev/null)
99+
if [ $fork_check -ne "200" ]; then
100+
echo "ERROR: invalid repository name specified."
101+
exit 1
102+
else
103+
echo "[!] Download code from GitHub repository: $fork"
104+
fork="$1"
105+
fi
106+
else
107+
fork="hestiacp"
108+
fi
109+
110+
if [ ! -z "$2" ]; then
87111
branch_check=$(curl -s --head -w %{http_code} https://raw.githubusercontent.com/hestiacp/hestiacp/$branch/src/deb/hestia/control -o /dev/null)
88112
if [ $branch_check -ne "200" ]; then
89-
echo "Error: invalid branch name specified."
113+
echo "ERROR: invalid branch name specified."
90114
exit 1
91115
else
92116
/usr/local/hestia/bin/v-change-sys-config-value 'RELEASE_BRANCH' "$branch"
93-
echo "Changed release branch to $branch."
117+
echo "[!] Changed system release branch to: $branch."
94118
fi
95119
else
96120
source /usr/local/hestia/conf/hestia.conf
97121
branch=$RELEASE_BRANCH
98122
fi
99123

100124
if [ -z "$branch" ]; then
101-
echo "No branch detected, please provide one using: v-update-sys-hestia-git branch"
125+
echo "ERROR: No branch detected."
102126
exit
103127
fi
104128

105129

106130
# Install needed software
107-
echo "Updating system APT repositories..."
131+
echo "[*] Updating APT package cache..."
108132
apt-get -qq update > /dev/null 2>&1
109-
echo "Installing dependencies for compilation..."
133+
echo "[*] Checking for missing dependencies and installing required libraries..."
110134
apt-get -qq install -y $SOFTWARE > /dev/null 2>&1
111135

112136
# Fix for Debian PHP Envroiment
@@ -115,14 +139,22 @@ ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl > /dev/null 2>&
115139
# Get system cpu cores
116140
NUM_CPUS=$(grep "^cpu cores" /proc/cpuinfo | uniq | awk '{print $4}')
117141

118-
# Set packages to compile
119-
HESTIA_B='true'
142+
# Check for existence of flags argument and set packages to build
143+
if [ ! -z "$flags" ]; then
144+
if [ "$flags" = "all" ]; then
145+
HESTIA_B='true'
146+
NGINX_B='true'
147+
PHP_B='true'
148+
fi
149+
else
150+
HESTIA_B='true'
151+
fi
120152

121153
# Set git repository raw path
122-
GIT_REP='https://raw.githubusercontent.com/hestiacp/hestiacp/'$branch'/src/deb'
154+
GIT_REP='https://raw.githubusercontent.com/'$fork'/hestiacp/'$branch'/src/deb'
123155

124156
# Generate Links for sourcecode
125-
HESTIA_ARCHIVE_LINK='https://github.com/hestiacp/hestiacp/archive/'$branch'.tar.gz'
157+
HESTIA_ARCHIVE_LINK='https://github.com/'$fork'/hestiacp/archive/'$branch'.tar.gz'
126158
NGINX='https://nginx.org/download/nginx-'$NGINX_V'.tar.gz'
127159
OPENSSL='https://www.openssl.org/source/openssl-'$OPENSSL_V'.tar.gz'
128160
PCRE='https://ftp.pcre.org/pub/pcre/pcre-'$PCRE_V'.tar.gz'
@@ -140,7 +172,7 @@ branch=$(echo "$branch" |sed 's/\//-/g');
140172

141173
if [ "$NGINX_B" = true ] ; then
142174

143-
echo "Building hestia-nginx package..."
175+
echo "[*] Building Package: hestia-nginx (backend web server)..."
144176
# Change to build directory
145177
cd $BUILD_DIR
146178

@@ -235,7 +267,7 @@ fi
235267
#################################################################################
236268

237269
if [ "$PHP_B" = true ] ; then
238-
echo "Building hestia-php package..."
270+
echo "[*] Building Package: hestia-php (backend engine)..."
239271
# Change to build directory
240272
cd $BUILD_DIR
241273

@@ -311,7 +343,7 @@ fi
311343
#################################################################################
312344

313345
if [ "$HESTIA_B" = true ] ; then
314-
echo "Building Hestia Control Panel package..."
346+
echo "[*] Building Package: hestia (Control Panel)..."
315347
# Change to build directory
316348
cd $BUILD_DIR
317349

@@ -389,7 +421,7 @@ install_build() {
389421

390422
# Define installation routine
391423

392-
if [ "$install" = "yes" ]; then
424+
if [ "$install" = "install" ] || [ "$install" = "yes" ]; then
393425
install_build
394426
else
395427
warning_message

0 commit comments

Comments
 (0)