Skip to content

Commit c04becd

Browse files
author
Kristan Kenney
committed
Add manual build script for testing purposes
hst_compile.sh: A manual version of hst_autocompile.sh, which allows a user to specify a specific branch to compile from and optionally install on the local system. Useful for rapidly testing feature branches.
1 parent 88261c6 commit c04becd

File tree

1 file changed

+329
-0
lines changed

1 file changed

+329
-0
lines changed

src/hst_compile.sh

Lines changed: 329 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,329 @@
1+
# Manual Compile script for Hestia CP files.
2+
3+
# Set packages to compile
4+
for arg; do
5+
case "$1" in
6+
--all)
7+
NGINX_B='true'
8+
PHP_B='true'
9+
HESTIA_B='true'
10+
;;
11+
--nginx)
12+
NGINX_B='true'
13+
;;
14+
--php)
15+
PHP_B='true'
16+
;;
17+
--hestia)
18+
HESTIA_B='true'
19+
;;
20+
-ia)
21+
HESTIA_B='true'
22+
NGINX_B='true'
23+
PHP_B='true'
24+
INSTALL_P='true'
25+
;;
26+
-ih)
27+
HESTIA_B='true'
28+
INSTALL_P='true'
29+
;;
30+
*)
31+
NOARGUMENT='true'
32+
;;
33+
esac
34+
done
35+
36+
if [[ $# -eq 0 ]] ; then
37+
echo "ERROR: No flag was specified. Valid options are --all, --nginx, --php,"
38+
echo " --hestia, -ia, or -ih"
39+
exit 1
40+
fi
41+
42+
# If branch was specified at run-time, convert its value to the branch variable
43+
if [ "$2" ]; then
44+
branch=$2
45+
fi
46+
47+
# Prompt for Git branch to download and build from if not specified at run-time
48+
if [ ! $2 ]; then
49+
echo -n "Please enter the name of the branch to build from (e.g. master): "
50+
read branch
51+
fi
52+
53+
# Set compiling directory
54+
BUILD_DIR='/root'
55+
INSTALL_DIR='/usr/local/hestia'
56+
57+
# Set Version for compiling
58+
HESTIA_V='0.9.8-28_amd64'
59+
NGINX_V='1.15.10'
60+
OPENSSL_V='1.1.1b'
61+
PCRE_V='8.42'
62+
ZLIB_V='1.2.11'
63+
PHP_V='7.3.4'
64+
65+
# Generate Links for sourcecode
66+
HESTIA='https://github.com/hestiacp/hestiacp/archive/'$branch'.zip'
67+
NGINX='https://nginx.org/download/nginx-'$NGINX_V'.tar.gz'
68+
OPENSSL='https://www.openssl.org/source/openssl-'$OPENSSL_V'.tar.gz'
69+
PCRE='https://ftp.pcre.org/pub/pcre/pcre-'$PCRE_V'.tar.gz'
70+
ZLIB='https://www.zlib.net/zlib-'$ZLIB_V'.tar.gz'
71+
PHP='http://de2.php.net/distributions/php-'$PHP_V'.tar.gz'
72+
73+
# Set repository path
74+
GIT_REP='https://raw.githubusercontent.com/hestiacp/hestiacp/'$branch'/src/deb/'
75+
76+
# Set package dependencies for compiling
77+
SOFTWARE='build-essential libxml2-dev libz-dev libcurl4-gnutls-dev unzip openssl libssl-dev pkg-config'
78+
79+
# Define a timestamp function
80+
timestamp() {
81+
date +%s
82+
}
83+
84+
# Install needed software
85+
echo "Update system repository..."
86+
apt-get -qq update
87+
echo "Installing dependencies for compilation..."
88+
apt-get -qq install -y $SOFTWARE
89+
90+
# Fix for Debian PHP Envroiment
91+
if [ ! -e /usr/local/include/curl ]; then
92+
ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl
93+
fi
94+
95+
#################################################################################
96+
#
97+
# Building hestia-nginx
98+
#
99+
#################################################################################
100+
101+
if [ "$NGINX_B" = true ] ; then
102+
# Change to build directory
103+
cd $BUILD_DIR
104+
105+
# Check if target directory exist
106+
if [ -d $BUILD_DIR/hestia-nginx_$HESTIA_V ]; then
107+
#mv $BUILD_DIR/hestia-nginx_$HESTIA_V $BUILD_DIR/hestia-nginx_$HESTIA_V-$(timestamp)
108+
rm -r $BUILD_DIR/hestia-nginx_$HESTIA_V
109+
fi
110+
111+
# Create directory
112+
mkdir $BUILD_DIR/hestia-nginx_$HESTIA_V
113+
114+
# Download and unpack source files
115+
wget -qO- $NGINX | tar xz
116+
wget -qO- $OPENSSL | tar xz
117+
wget -qO- $PCRE | tar xz
118+
wget -qO- $ZLIB | tar xz
119+
120+
# Change to nginx directory
121+
cd nginx-$NGINX_V
122+
123+
# configure nginx
124+
./configure --prefix=/usr/local/hestia/nginx \
125+
--with-http_ssl_module \
126+
--with-openssl=../openssl-$OPENSSL_V \
127+
--with-openssl-opt=enable-ec_nistp_64_gcc_128 \
128+
--with-openssl-opt=no-nextprotoneg \
129+
--with-openssl-opt=no-weak-ssl-ciphers \
130+
--with-openssl-opt=no-ssl3 \
131+
--with-pcre=../pcre-$PCRE_V \
132+
--with-pcre-jit \
133+
--with-zlib=../zlib-$ZLIB_V
134+
135+
# Check install directory and move if exists
136+
if [ -d $INSTALL_DIR ]; then
137+
#mv $INSTALL_DIR $INSTALL_DIR$(timestamp)
138+
rm -r $INSTALL_DIR
139+
fi
140+
141+
# Create the files and install them
142+
make && make install
143+
144+
# Cleare up unused files
145+
cd $BUILD_DIR
146+
rm -r nginx-$NGINX_V openssl-$OPENSSL_V pcre-$PCRE_V zlib-$ZLIB_V
147+
148+
# Prepare Deb Package Folder Structure
149+
cd hestia-nginx_$HESTIA_V/
150+
mkdir -p usr/local/hestia etc/init.d DEBIAN
151+
152+
# Download control, postinst and postrm files
153+
cd DEBIAN
154+
wget $GIT_REP/nginx/control
155+
wget $GIT_REP/nginx/copyright
156+
wget $GIT_REP/nginx/postinst
157+
wget $GIT_REP/nginx/postrm
158+
159+
# Set permission
160+
chmod +x postinst postrm
161+
162+
# Move nginx directory
163+
cd ..
164+
mv /usr/local/hestia/nginx usr/local/hestia/
165+
166+
# Get Service File
167+
cd etc/init.d
168+
wget $GIT_REP/nginx/hestia
169+
chmod +x hestia
170+
171+
# Get nginx.conf
172+
cd ../../
173+
rm usr/local/hestia/nginx/conf/nginx.conf
174+
wget $GIT_REP/nginx/nginx.conf -O usr/local/hestia/nginx/conf/nginx.conf
175+
176+
# copy binary
177+
cp usr/local/hestia/nginx/sbin/nginx usr/local/hestia/nginx/sbin/hestia-nginx
178+
179+
# change permission and build the package
180+
cd $BUILD_DIR
181+
chown -R root:root hestia-nginx_$HESTIA_V
182+
dpkg-deb --build hestia-nginx_$HESTIA_V
183+
184+
# clear up the source folder
185+
rm -r hestia-nginx_$HESTIA_V
186+
fi
187+
188+
189+
#################################################################################
190+
#
191+
# Building hestia-php
192+
#
193+
#################################################################################
194+
195+
if [ "$PHP_B" = true ] ; then
196+
# Change to build directory
197+
cd $BUILD_DIR
198+
199+
# Check if target directory exist
200+
if [ -d $BUILD_DIR/hestia-php_$HESTIA_V ]; then
201+
#mv $BUILD_DIR/hestia-php_$HESTIA_V $BUILD_DIR/hestia-php_$HESTIA_V-$(timestamp)
202+
rm -r $BUILD_DIR/hestia-php_$HESTIA_V
203+
fi
204+
205+
# Create directory
206+
mkdir $BUILD_DIR/hestia-php_$HESTIA_V
207+
208+
# Download and unpack source files
209+
wget -qO- $PHP | tar xz
210+
211+
# Change to php directory
212+
cd php-$PHP_V
213+
214+
# Configure PHP
215+
./configure --prefix=/usr/local/hestia/php \
216+
--enable-fpm \
217+
--with-fpm-user=admin \
218+
--with-fpm-group=admin \
219+
--with-libdir=lib/x86_64-linux-gnu \
220+
--with-mysqli \
221+
--with-curl \
222+
--enable-mbstring
223+
224+
# Create the files and install them
225+
make && make install
226+
227+
# Cleare up unused files
228+
cd $BUILD_DIR
229+
rm -r php-$PHP_V
230+
231+
# Prepare Deb Package Folder Structure
232+
cd hestia-php_$HESTIA_V/
233+
mkdir -p usr/local/hestia DEBIAN
234+
235+
# Download control, postinst and postrm files
236+
cd DEBIAN
237+
wget $GIT_REP/php/control
238+
wget $GIT_REP/php/copyright
239+
240+
# Move php directory
241+
cd ..
242+
mv /usr/local/hestia/php usr/local/hestia/
243+
244+
# Get php-fpm.conf
245+
wget $GIT_REP/php/php-fpm.conf -O usr/local/hestia/php/etc/php-fpm.conf
246+
247+
# Get php.ini
248+
wget $GIT_REP/php/php.ini -O usr/local/hestia/php/lib/php.ini
249+
250+
# copy binary
251+
cp usr/local/hestia/php/sbin/php-fpm usr/local/hestia/php/sbin/hestia-php
252+
253+
# change permission and build the package
254+
cd $BUILD_DIR
255+
chown -R root:root hestia-php_$HESTIA_V
256+
dpkg-deb --build hestia-php_$HESTIA_V
257+
258+
# clear up the source folder
259+
rm -r hestia-php_$HESTIA_V
260+
fi
261+
262+
263+
#################################################################################
264+
#
265+
# Building hestia
266+
#
267+
#################################################################################
268+
269+
if [ "$HESTIA_B" = true ] ; then
270+
# Change to build directory
271+
cd $BUILD_DIR
272+
273+
# Check if target directory exist
274+
if [ -d $BUILD_DIR/hestia_$HESTIA_V ]; then
275+
#mv $BUILD_DIR/hestia_$HESTIA_V $BUILD_DIR/hestia_$HESTIA_V-$(timestamp)
276+
rm -r $BUILD_DIR/hestia_$HESTIA_V
277+
fi
278+
279+
# Create directory
280+
mkdir $BUILD_DIR/hestia_$HESTIA_V
281+
282+
# Download and unpack source files
283+
wget $HESTIA
284+
unzip -q $branch.zip
285+
rm $branch.zip
286+
287+
# Prepare Deb Package Folder Structure
288+
cd hestia_$HESTIA_V/
289+
mkdir -p usr/local/hestia DEBIAN
290+
291+
# Download control, postinst and postrm files
292+
cd DEBIAN
293+
wget $GIT_REP/hestia/control
294+
wget $GIT_REP/hestia/copyright
295+
wget $GIT_REP/hestia/postinst
296+
297+
# Set permission
298+
chmod +x postinst
299+
300+
# Move needed directories
301+
cd ../../hestiacp-$branch
302+
mv bin func install web ../hestia_$HESTIA_V/usr/local/hestia/
303+
304+
# Set permission
305+
cd ../hestia_$HESTIA_V/usr/local/hestia/bin
306+
chmod +x *
307+
308+
# change permission and build the package
309+
cd $BUILD_DIR
310+
chown -R root:root hestia_$HESTIA_V
311+
dpkg-deb --build hestia_$HESTIA_V
312+
313+
# clear up the source folder
314+
rm -r hestia_$HESTIA_V
315+
rm -r hestiacp-$branch
316+
fi
317+
318+
#################################################################################
319+
#
320+
# Install Packages
321+
#
322+
#################################################################################
323+
324+
if [ "$INSTALL_P" = true ] ; then
325+
for i in ~/*hestia*.deb; do
326+
# Install all available packages
327+
dpkg -i $i
328+
done
329+
fi

0 commit comments

Comments
 (0)