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
615download_file () {
@@ -56,18 +65,20 @@ INSTALL_DIR='/usr/local/hestia'
5665ARCHIVE_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)
6475BUILD_ARCH=' amd64'
6576HESTIA_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 '
6879PCRE_V=' 8.43'
6980ZLIB_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
7384rm -rf $BUILD_DIR
@@ -84,29 +95,42 @@ timestamp() {
8495
8596# Set install flags
8697if [ ! -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
95119else
96120 source /usr/local/hestia/conf/hestia.conf
97121 branch=$RELEASE_BRANCH
98122fi
99123
100124if [ -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
103127fi
104128
105129
106130# Install needed software
107- echo " Updating system APT repositories ..."
131+ echo " [*] Updating APT package cache ..."
108132apt-get -qq update > /dev/null 2>&1
109- echo " Installing dependencies for compilation ..."
133+ echo " [*] Checking for missing dependencies and installing required libraries ..."
110134apt-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
116140NUM_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'
126158NGINX=' https://nginx.org/download/nginx-' $NGINX_V ' .tar.gz'
127159OPENSSL=' https://www.openssl.org/source/openssl-' $OPENSSL_V ' .tar.gz'
128160PCRE=' https://ftp.pcre.org/pub/pcre/pcre-' $PCRE_V ' .tar.gz'
@@ -140,7 +172,7 @@ branch=$(echo "$branch" |sed 's/\//-/g');
140172
141173if [ " $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
235267# ################################################################################
236268
237269if [ " $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
311343# ################################################################################
312344
313345if [ " $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
394426else
395427 warning_message
0 commit comments