v-update-sys-developer 8.6 KB

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