v-update-sys-developer 8.5 KB

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