| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- # Autocompile Script for HestiaCP deb Files.
- # Define download function
- download_file() {
- wget $1 -q --show-progress --progress=bar:force
- }
- # Set compiling directory
- BUILD_DIR='/tmp/hestiacp-src/'
- DEB_DIR="$BUILD_DIR/debs/"
- INSTALL_DIR='/usr/local/hestia'
- # Set Version for compiling
- HESTIA_V='0.10.0-190430_amd64'
- NGINX_V='1.16.0'
- OPENSSL_V='1.1.1b'
- PCRE_V='8.43'
- ZLIB_V='1.2.11'
- PHP_V='7.3.4'
- # Create build directories
- rm -rf $BUILD_DIR
- mkdir -p $DEB_DIR
- # Set package dependencies for compiling
- SOFTWARE='build-essential libxml2-dev libz-dev libcurl4-gnutls-dev unzip openssl libssl-dev pkg-config'
- # Define a timestamp function
- timestamp() {
- date +%s
- }
- branch=$2
- install=$3
- # Set install flags
- if [ ! -z "$1" ]; then
- branch=$1
- else
- source /usr/local/hestia/conf/hestia.conf
- branch=$RELEASE_BRANCH
- fi
- if [ ! -z "$2" ]; then
- install=$2
- else
- install="y"
- fi
- # Install needed software
- echo "Updating system APT repositories..."
- apt-get -qq update > /dev/null 2>&1
- echo "Installing dependencies for compilation..."
- apt-get -qq install -y $SOFTWARE > /dev/null 2>&1
- # Fix for Debian PHP Envroiment
- if [ ! -e /usr/local/include/curl ]; then
- ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl
- fi
- # Get system cpu cores
- NUM_CPUS=$(grep "^cpu cores" /proc/cpuinfo | uniq | awk '{print $4}')
- # Set packages to compile
- HESTIA_B='true'
- # Set git repository raw path
- GIT_REP='https://raw.githubusercontent.com/hestiacp/hestiacp/'$branch'/src/deb'
- # Generate Links for sourcecode
- HESTIA='https://github.com/hestiacp/hestiacp/archive/'$branch'.zip'
- NGINX='https://nginx.org/download/nginx-'$NGINX_V'.tar.gz'
- OPENSSL='https://www.openssl.org/source/openssl-'$OPENSSL_V'.tar.gz'
- PCRE='https://ftp.pcre.org/pub/pcre/pcre-'$PCRE_V'.tar.gz'
- ZLIB='https://www.zlib.net/zlib-'$ZLIB_V'.tar.gz'
- PHP='http://de2.php.net/distributions/php-'$PHP_V'.tar.gz'
- #################################################################################
- #
- # Building hestia-nginx
- #
- #################################################################################
- if [ "$NGINX_B" = true ] ; then
- echo "Building hestia-nginx package..."
- # Change to build directory
- cd $BUILD_DIR
- # Check if target directory exist
- if [ -d $BUILD_DIR/hestia-nginx_$NGINX_V ]; then
- #mv $BUILD_DIR/hestia-nginx_$NGINX_V $BUILD_DIR/hestia-nginx_$NGINX_V-$(timestamp)
- rm -r $BUILD_DIR/hestia-nginx_$NGINX_V
- fi
- # Create directory
- mkdir $BUILD_DIR/hestia-nginx_$NGINX_V
- # Download and unpack source files
- download_file $NGINX | tar xz
- download_file $OPENSSL | tar xz
- download_file $PCRE | tar xz
- download_file $ZLIB | tar xz
- # Change to nginx directory
- cd nginx-$NGINX_V
- # configure nginx
- ./configure --prefix=/usr/local/hestia/nginx \
- --with-http_ssl_module \
- --with-openssl=../openssl-$OPENSSL_V \
- --with-openssl-opt=enable-ec_nistp_64_gcc_128 \
- --with-openssl-opt=no-nextprotoneg \
- --with-openssl-opt=no-weak-ssl-ciphers \
- --with-openssl-opt=no-ssl3 \
- --with-pcre=../pcre-$PCRE_V \
- --with-pcre-jit \
- --with-zlib=../zlib-$ZLIB_V
- # Check install directory and remove if exists
- if [ -d "$BUILD_DIR$INSTALL_DIR" ]; then
- rm -r "$BUILD_DIR$INSTALL_DIR"
- fi
- # Create the files and install them
- make -j $NUM_CPUS && make DESTDIR=$BUILD_DIR install
- # Cleare up unused files
- cd $BUILD_DIR
- rm -r nginx-$NGINX_V openssl-$OPENSSL_V pcre-$PCRE_V zlib-$ZLIB_V
- # Prepare Deb Package Folder Structure
- cd hestia-nginx_$NGINX_V/
- mkdir -p usr/local/hestia etc/init.d DEBIAN
- # Download control, postinst and postrm files
- cd DEBIAN
- download_file $GIT_REP/nginx/control
- download_file $GIT_REP/nginx/copyright
- download_file $GIT_REP/nginx/postinst
- download_file $GIT_REP/nginx/postrm
- # Set permission
- chmod +x postinst postrm
- # Move nginx directory
- cd ..
- mv $BUILD_DIR/usr/local/hestia/nginx usr/local/hestia/
- # Get Service File
- cd etc/init.d
- download_file $GIT_REP/nginx/hestia
- chmod +x hestia
- # Get nginx.conf
- cd ../../
- rm usr/local/hestia/nginx/conf/nginx.conf
- download_file $GIT_REP/nginx/nginx.conf -O usr/local/hestia/nginx/conf/nginx.conf
- # copy binary
- cp usr/local/hestia/nginx/sbin/nginx usr/local/hestia/nginx/sbin/hestia-nginx
- # change permission and build the package
- cd $BUILD_DIR
- chown -R root:root hestia-nginx_$NGINX_V
- dpkg-deb --build hestia-nginx_$NGINX_V
- mv *.deb $DEB_DIR
- # clear up the source folder
- rm -r hestia-nginx_$NGINX_V
- fi
- #################################################################################
- #
- # Building hestia-php
- #
- #################################################################################
- if [ "$PHP_B" = true ] ; then
- echo "Building hestia-php package..."
- # Change to build directory
- cd $BUILD_DIR
- # Check if target directory exist
- if [ -d $BUILD_DIR/hestia-php_$PHP_V ]; then
- #mv $BUILD_DIR/hestia-php_$PHP_V $BUILD_DIR/hestia-php_$PHP_V-$(timestamp)
- rm -r $BUILD_DIR/hestia-php_$PHP_V
- fi
- # Create directory
- mkdir ${BUILD_DIR}/hestia-php_$PHP_V
- # Download and unpack source files
- download_file $PHP | tar xz
- # Change to php directory
- cd php-$PHP_V
- # Configure PHP
- ./configure --prefix=/usr/local/hestia/php \
- --enable-fpm \
- --with-fpm-user=admin \
- --with-fpm-group=admin \
- --with-libdir=lib/x86_64-linux-gnu \
- --with-mysqli \
- --with-curl \
- --enable-mbstring
- # Create the files and install them
- make -j $NUM_CPUS && make INSTALL_ROOT=$BUILD_DIR install
- # Cleare up unused files
- cd $BUILD_DIR
- rm -r php-$PHP_V
- # Prepare Deb Package Folder Structure
- cd hestia-php_$PHP_V/
- mkdir -p usr/local/hestia DEBIAN
- # Download control, postinst and postrm files
- cd DEBIAN
- download_file $GIT_REP/php/control
- download_file $GIT_REP/php/copyright
- # Move php directory
- cd ..
- mv ${BUILD_DIR}/usr/local/hestia/php usr/local/hestia/
- # Get php-fpm.conf
- download_file $GIT_REP/php/php-fpm.conf -O usr/local/hestia/php/etc/php-fpm.conf
- # Get php.ini
- download_file $GIT_REP/php/php.ini -O usr/local/hestia/php/lib/php.ini
- # copy binary
- cp usr/local/hestia/php/sbin/php-fpm usr/local/hestia/php/sbin/hestia-php
- # change permission and build the package
- cd $BUILD_DIR
- chown -R root:root hestia-php_$PHP_V
- dpkg-deb --build hestia-php_$PHP_V
- mv *.deb $DEB_DIR
- # clear up the source folder
- rm -r hestia-php_$PHP_V
- fi
- #################################################################################
- #
- # Building hestia
- #
- #################################################################################
- if [ "$HESTIA_B" = true ] ; then
- echo "Building Hestia Control Panel package..."
- # Change to build directory
- cd $BUILD_DIR
- # Check if target directory exist
- if [ -d $BUILD_DIR/hestia_$HESTIA_V ]; then
- #mv $BUILD_DIR/hestia_$HESTIA_V $BUILD_DIR/hestia_$HESTIA_V-$(timestamp)
- rm -r $BUILD_DIR/hestia_$HESTIA_V
- fi
- # Create directory
- mkdir $BUILD_DIR/hestia_$HESTIA_V
- # Download and unpack source files
- download_file $HESTIA
- unzip -q $branch.zip
- rm $branch.zip
- # Prepare Deb Package Folder Structure
- cd hestia_$HESTIA_V/
- mkdir -p usr/local/hestia DEBIAN
- # Download control, postinst and postrm files
- cd DEBIAN
- download_file $GIT_REP/hestia/control
- download_file $GIT_REP/hestia/copyright
- download_file $GIT_REP/hestia/postinst
- # Set permission
- chmod +x postinst
- # Move needed directories
- cd ../../hestiacp-$branch
- mv bin func install web ../hestia_$HESTIA_V/usr/local/hestia/
- # Set permission
- cd ../hestia_$HESTIA_V/usr/local/hestia/bin
- chmod +x *
- # change permission and build the package
- cd $BUILD_DIR
- chown -R root:root hestia_$HESTIA_V
- dpkg-deb --build hestia_$HESTIA_V
- mv *.deb $DEB_DIR
- # clear up the source folder
- rm -r hestia_$HESTIA_V
- rm -r hestiacp-$branch
- fi
- #################################################################################
- #
- # Install Packages
- #
- #################################################################################
- if [ "$install" = 'yes' ] || [ "$install" = 'y' ]; then
- echo "Installing packages..."
- for i in $DEB_DIR/*.deb; do
- # Install all available packages
- dpkg -i $i
- done
- unset $answer
- fi
|