Skip to content

Commit 75ee8a8

Browse files
committed
Added hst_autocompile script.
1 parent 23188bf commit 75ee8a8

File tree

1 file changed

+272
-0
lines changed

1 file changed

+272
-0
lines changed

src/hst_autocompile.sh

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
# Autocompile Script for HestiaCP deb Files.
2+
3+
# Set compiling directory
4+
BUILD_DIR='/usr/src'
5+
INSTALL_DIR='/usr/local/hestia'
6+
7+
# Set git repository raw path
8+
GIT_REP='https://raw.githubusercontent.com/hestiacp/hestiacp/master/src/deb'
9+
10+
# Set Version for compiling
11+
HESTIA_V='0.9.8-23_amd64'
12+
NGINX_V='1.15.5'
13+
OPENSSL_V='1.1.1'
14+
PCRE_V='8.42'
15+
ZLIB_V='1.2.11'
16+
PHP_V='5.6.38'
17+
18+
# Generate Links for sourcecode
19+
HESTIA='https://github.com/hestiacp/hestiacp/archive/master.zip'
20+
NGINX='https://nginx.org/download/nginx-'$NGINX_V'.tar.gz'
21+
OPENSSL='https://www.openssl.org/source/openssl-'$OPENSSL_V'.tar.gz'
22+
PCRE='https://ftp.pcre.org/pub/pcre/pcre-'$PCRE_V'.tar.gz'
23+
ZLIB='https://www.zlib.net/zlib-'$ZLIB_V'.tar.gz'
24+
PHP='http://de2.php.net/distributions/php-'$PHP_V'.tar.gz'
25+
26+
# Set package dependencies for compiling
27+
SOFTWARE='build-essential libxml2-dev libz-dev libcurl4-gnutls-dev unzip'
28+
29+
# Define a timestamp function
30+
timestamp() {
31+
date +%s
32+
}
33+
34+
# Install needed software
35+
apt-get install -y $SOFTWARE
36+
37+
# Fix for Debian PHP Envroiment
38+
cd /usr/local/include
39+
ln -s /usr/include/x86_64-linux-gnu/curl curl
40+
41+
# Set packages to compile
42+
for arg; do
43+
case "$1" in
44+
--all)
45+
NGINX_B='true'
46+
PHP_B='true'
47+
HESTIA_B='true'
48+
;;
49+
--nginx)
50+
NGINX_B='true'
51+
;;
52+
--php)
53+
PHP_B='true'
54+
;;
55+
--hestia)
56+
HESTIA_B='true'
57+
;;
58+
esac
59+
done
60+
61+
#################################################################################
62+
#
63+
# Building hestia-nginx
64+
#
65+
#################################################################################
66+
67+
if [ "$NGINX_B" = true ] ; then
68+
# Change to build directory
69+
cd $BUILD_DIR
70+
71+
# Check if target directory exist
72+
if [ -d $BUILD_DIR/hestia-nginx_$HESTIA_V ]; then
73+
#mv $BUILD_DIR/hestia-nginx_$HESTIA_V $BUILD_DIR/hestia-nginx_$HESTIA_V-$(timestamp)
74+
rm -r $BUILD_DIR/hestia-nginx_$HESTIA_V
75+
fi
76+
77+
# Create directory
78+
mkdir $BUILD_DIR/hestia-nginx_$HESTIA_V
79+
80+
# Download and unpack source files
81+
wget -qO- $NGINX | tar xz
82+
wget -qO- $OPENSSL | tar xz
83+
wget -qO- $PCRE | tar xz
84+
wget -qO- $ZLIB | tar xz
85+
86+
# Change to nginx directory
87+
cd nginx-$NGINX_V
88+
89+
# configure nginx
90+
./configure --prefix=/usr/local/hestia/nginx \
91+
--with-http_ssl_module \
92+
--with-openssl=../openssl-$OPENSSL_V \
93+
--with-openssl-opt=enable-ec_nistp_64_gcc_128 \
94+
--with-openssl-opt=no-nextprotoneg \
95+
--with-openssl-opt=no-weak-ssl-ciphers \
96+
--with-openssl-opt=no-ssl3 \
97+
--with-pcre=../pcre-$PCRE_V \
98+
--with-pcre-jit \
99+
--with-zlib=../zlib-$ZLIB_V
100+
101+
# Check install directory and move if exists
102+
if [ -d $INSTALL_DIR ]; then
103+
#mv $INSTALL_DIR $INSTALL_DIR$(timestamp)
104+
rm -r $INSTALL_DIR
105+
fi
106+
107+
# Create the files and install them
108+
make && make install
109+
110+
# Cleare up unused files
111+
cd $BUILD_DIR
112+
rm -r nginx-$NGINX_V openssl-$OPENSSL_V pcre-$PCRE_V zlib-$ZLIB_V
113+
114+
# Prepare Deb Package Folder Structure
115+
cd hestia-nginx_$HESTIA_V/
116+
mkdir -p usr/local/hestia etc/init.d DEBIAN
117+
118+
# Download control, postinst and postrm files
119+
cd DEBIAN
120+
wget $GIT_REP/nginx/control
121+
wget $GIT_REP/nginx/postinst
122+
wget $GIT_REP/nginx/postrm
123+
124+
# Set permission
125+
chmod +x postinst postrm
126+
127+
# Move nginx directory
128+
cd ..
129+
mv /usr/local/hestia/nginx usr/local/hestia/
130+
131+
# Get Service File
132+
cd etc/init.d
133+
wget $GIT_REP/nginx/hestia
134+
chmod +x hestia
135+
136+
# Get nginx.conf
137+
cd ../../
138+
rm usr/local/hestia/nginx/conf/nginx.conf
139+
wget $GIT_REP/nginx/nginx.conf -O usr/local/hestia/nginx/conf/nginx.conf
140+
141+
# copy binary
142+
cp usr/local/hestia/nginx/sbin/nginx usr/local/hestia/nginx/sbin/hestia-nginx
143+
144+
# build the package
145+
cd /usr/src
146+
dpkg-deb --build hestia-nginx_$HESTIA_V
147+
148+
# clear up the source folder
149+
rm -r hestia-nginx_$HESTIA_V
150+
fi
151+
152+
#################################################################################
153+
#
154+
# Building hestia-php
155+
#
156+
#################################################################################
157+
158+
if [ "$PHP_B" = true ] ; then
159+
# Change to build directory
160+
cd $BUILD_DIR
161+
162+
# Check if target directory exist
163+
if [ -d $BUILD_DIR/hestia-php_$HESTIA_V ]; then
164+
#mv $BUILD_DIR/hestia-php_$HESTIA_V $BUILD_DIR/hestia-php_$HESTIA_V-$(timestamp)
165+
rm -r $BUILD_DIR/hestia-php_$HESTIA_V
166+
fi
167+
168+
# Create directory
169+
mkdir $BUILD_DIR/hestia-php_$HESTIA_V
170+
171+
# Download and unpack source files
172+
wget -qO- $PHP | tar xz
173+
174+
# Change to php directory
175+
cd php-$PHP_V
176+
177+
# Configure PHP
178+
./configure --prefix=/usr/local/hestia/php \
179+
--enable-fpm \
180+
--with-zlib \
181+
--with-fpm-user=admin \
182+
--with-fpm-group=admin \
183+
--with-mysql \
184+
--with-mysqli \
185+
--with-curl \
186+
--enable-mbstring
187+
188+
# Create the files and install them
189+
make && make install
190+
191+
# Cleare up unused files
192+
cd $BUILD_DIR
193+
rm -r php-$PHP_V
194+
195+
# Prepare Deb Package Folder Structure
196+
cd hestia-php_$HESTIA_V/
197+
mkdir -p usr/local/hestia DEBIAN
198+
199+
# Download control, postinst and postrm files
200+
cd DEBIAN
201+
wget $GIT_REP/php/control
202+
203+
# Move php directory
204+
cd ..
205+
mv /usr/local/hestia/php usr/local/hestia/
206+
207+
# Get php-fpm.conf
208+
wget $GIT_REP/php/php-fpm.conf -O usr/local/hestia/php/etc/php-fpm.conf
209+
210+
# copy binary
211+
cp usr/local/hestia/php/sbin/php-fpm usr/local/hestia/php/sbin/hestia-php
212+
213+
# build the package
214+
cd /usr/src
215+
dpkg-deb --build hestia-php_$HESTIA_V
216+
217+
# clear up the source folder
218+
rm -r hestia-php_$HESTIA_V
219+
fi
220+
221+
#################################################################################
222+
#
223+
# Building hestia
224+
#
225+
#################################################################################
226+
227+
if [ "$HESTIA_B" = true ] ; then
228+
# Change to build directory
229+
cd $BUILD_DIR
230+
231+
# Check if target directory exist
232+
if [ -d $BUILD_DIR/hestia_$HESTIA_V ]; then
233+
#mv $BUILD_DIR/hestia_$HESTIA_V $BUILD_DIR/hestia_$HESTIA_V-$(timestamp)
234+
rm -r $BUILD_DIR/hestia_$HESTIA_V
235+
fi
236+
237+
# Create directory
238+
mkdir $BUILD_DIR/hestia_$HESTIA_V
239+
240+
# Download and unpack source files
241+
wget $HESTIA
242+
unzip -q master.zip
243+
rm master.zip
244+
245+
# Prepare Deb Package Folder Structure
246+
cd hestia_$HESTIA_V/
247+
mkdir -p usr/local/hestia DEBIAN
248+
249+
# Download control, postinst and postrm files
250+
cd DEBIAN
251+
wget $GIT_REP/hestia/control
252+
wget $GIT_REP/hestia/postinst
253+
254+
# Set permission
255+
chmod +x postinst
256+
257+
# Move needed directories
258+
cd ../../hestiacp-master
259+
mv bin func install upd web ../hestia_$HESTIA_V/usr/local/hestia/
260+
261+
# Set permission
262+
cd ../hestia_$HESTIA_V/usr/local/hestia/bin
263+
chmod +x *
264+
265+
# build the package
266+
cd /usr/src
267+
dpkg-deb --build hestia_$HESTIA_V
268+
269+
# clear up the source folder
270+
rm -r hestia_$HESTIA_V
271+
rm -r hestiacp-master
272+
fi

0 commit comments

Comments
 (0)