1+ #! /bin/bash
2+
13# Autocompile Script for HestiaCP deb Files.
24
35# Clear previous screen output
46clear
57
68# Define download function
79download_file () {
8- wget $1 -q --show-progress --progress=bar:force
10+ local url=$1
11+ local destination=$2
12+
13+ # default destionation is the curent working directory
14+ local dstopt=" "
15+
16+ if [ ! -z " $( echo " $url " | grep -E " \.(gz|gzip|bz2|zip|xz)$" ) " ]; then
17+ # when a archive file is downloaded it will be first saved localy
18+ dstopt=" --directory-prefix=$ARHIVE_DIR "
19+ local is_archive=" true"
20+ local filename=" ${url##*/ } "
21+ elif [ ! -z " $destination " ]; then
22+ # Plain files will be written to specified location
23+ dstopt=" -O $destination "
24+ fi
25+
26+ if [ ! -f " $ARHIVE_DIR /$filename " ]; then
27+ wget $url -q $dstopt --show-progress --progress=bar:force
28+ fi
29+
30+ if [ ! -z " $destination " ] && [ " $is_archive " = " true" ]; then
31+ if [ " $destination " = " -" ]; then
32+ cat " $ARHIVE_DIR /$filename "
33+ elif [ -d $( basename $destination ) ]; then
34+ cp " $ARHIVE_DIR /$filename " " $destination "
35+ fi
36+ fi
937}
1038
1139# Set compiling directory
1240BUILD_DIR=' /tmp/hestiacp-src/'
1341DEB_DIR=" $BUILD_DIR /debs/"
1442INSTALL_DIR=' /usr/local/hestia'
43+ SRC_DIR=" $( cd " $( dirname " $0 " ) /.." && pwd) "
44+ ARHIVE_DIR=" $SRC_DIR /src/archive/"
1545
1646# Set Version for compiling
1747HESTIA_V=' 0.10.0-190430_amd64'
@@ -24,6 +54,7 @@ PHP_V='7.3.5'
2454# Create build directories
2555rm -rf $BUILD_DIR
2656mkdir -p $DEB_DIR
57+ mkdir -p $ARHIVE_DIR
2758
2859# Set package dependencies for compiling
2960SOFTWARE=' build-essential libxml2-dev libz-dev libcurl4-gnutls-dev unzip openssl libssl-dev pkg-config'
109140GIT_REP=' https://raw.githubusercontent.com/hestiacp/hestiacp/' $branch ' /src/deb'
110141
111142# Generate Links for sourcecode
112- HESTIA=' https://github.com/hestiacp/hestiacp/archive/' $branch ' .zip '
143+ HESTIA=' https://github.com/hestiacp/hestiacp/archive/' $branch ' .tar.gz '
113144NGINX=' https://nginx.org/download/nginx-' $NGINX_V ' .tar.gz'
114145OPENSSL=' https://www.openssl.org/source/openssl-' $OPENSSL_V ' .tar.gz'
115146PCRE=' https://ftp.pcre.org/pub/pcre/pcre-' $PCRE_V ' .tar.gz'
@@ -139,10 +170,10 @@ if [ "$NGINX_B" = true ] ; then
139170 mkdir $BUILD_DIR /hestia-nginx_$NGINX_V
140171
141172 # Download and unpack source files
142- download_file $NGINX | tar xz
143- download_file $OPENSSL | tar xz
144- download_file $PCRE | tar xz
145- download_file $ZLIB | tar xz
173+ download_file $NGINX ' - ' | tar xz
174+ download_file $OPENSSL ' - ' | tar xz
175+ download_file $PCRE ' - ' | tar xz
176+ download_file $ZLIB ' - ' | tar xz
146177
147178 # Change to nginx directory
148179 cd nginx-$NGINX_V
@@ -197,7 +228,7 @@ if [ "$NGINX_B" = true ] ; then
197228 # Get nginx.conf
198229 cd ../../
199230 rm usr/local/hestia/nginx/conf/nginx.conf
200- download_file $GIT_REP /nginx/nginx.conf -O usr/local/hestia/nginx/conf/nginx.conf
231+ download_file " $GIT_REP /nginx/nginx.conf" " usr/local/hestia/nginx/conf/nginx.conf"
201232
202233 # copy binary
203234 cp usr/local/hestia/nginx/sbin/nginx usr/local/hestia/nginx/sbin/hestia-nginx
@@ -234,7 +265,7 @@ if [ "$PHP_B" = true ] ; then
234265 mkdir ${BUILD_DIR} /hestia-php_$PHP_V
235266
236267 # Download and unpack source files
237- download_file $PHP | tar xz
268+ download_file $PHP ' - ' | tar xz
238269
239270 # Change to php directory
240271 cd php-$PHP_V
@@ -270,10 +301,10 @@ if [ "$PHP_B" = true ] ; then
270301 mv ${BUILD_DIR} /usr/local/hestia/php usr/local/hestia/
271302
272303 # Get php-fpm.conf
273- download_file $GIT_REP /php/php-fpm.conf -O usr/local/hestia/php/etc/php-fpm.conf
304+ download_file " $GIT_REP /php/php-fpm.conf" " usr/local/hestia/php/etc/php-fpm.conf"
274305
275306 # Get php.ini
276- download_file $GIT_REP /php/php.ini -O usr/local/hestia/php/lib/php.ini
307+ download_file " $GIT_REP /php/php.ini" " usr/local/hestia/php/lib/php.ini"
277308
278309 # copy binary
279310 cp usr/local/hestia/php/sbin/php-fpm usr/local/hestia/php/sbin/hestia-php
@@ -310,9 +341,7 @@ if [ "$HESTIA_B" = true ] ; then
310341 mkdir $BUILD_DIR /hestia_$HESTIA_V
311342
312343 # Download and unpack source files
313- download_file $HESTIA
314- unzip -q $branch .zip
315- rm $branch .zip
344+ download_file $HESTIA ' -' | tar xz
316345
317346 # Prepare Deb Package Folder Structure
318347 cd hestia_$HESTIA_V /
0 commit comments