package.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. set -e
  3. cur_date="`date +%Y-%m-%d`"
  4. ROOT=$(cd `dirname $0`; pwd)
  5. mkdir -p $ROOT/tmp
  6. rm -rf $ROOT/tmp/*
  7. # NOTE: App is installed to /opt/$APP_COMPARTMENT/$APP_MODULE
  8. APP_COMPARTMENT="nginx-green"
  9. APP_MODULE="nginx-green"
  10. # ----- Start build -----
  11. # NOTE: Adapted from https://github.com/moezzie/nginx-portable
  12. NGINX_VERSION="nginx-1.26.2"
  13. NGINX_BUILD_DIR=$ROOT/cache/$NGINX_VERSION/
  14. ./build-nginx.sh $NGINX_VERSION "/opt/$APP_COMPARTMENT/$APP_MODULE"
  15. # ----- End build -----
  16. cp -rf $ROOT/$APP_MODULE $ROOT/tmp/
  17. cp -rf $ROOT/$APP_MODULE-installer $ROOT/tmp/
  18. mkdir -p $ROOT/tmp/$APP_MODULE/logs
  19. mkdir -p $ROOT/tmp/$APP_MODULE/tmp
  20. mkdir -p $ROOT/tmp/$APP_MODULE/bin
  21. cp -rf $NGINX_BUILD_DIR/conf $ROOT/tmp/$APP_MODULE/conf
  22. cp -f $ROOT/conf/nginx.conf $ROOT/tmp/$APP_MODULE/conf/nginx.conf
  23. cp -rf $NGINX_BUILD_DIR/html $ROOT/tmp/$APP_MODULE/html
  24. cp -f $NGINX_BUILD_DIR/objs/nginx $ROOT/tmp/$APP_MODULE/bin/nginx-green
  25. mkdir -p $ROOT/tmp/$APP_MODULE/conf/sites-available
  26. mkdir -p $ROOT/tmp/$APP_MODULE/conf/sites-enabled
  27. mkdir -p $ROOT/tmp/$APP_MODULE/conf/streams-available
  28. mkdir -p $ROOT/tmp/$APP_MODULE/conf/streams-enabled
  29. mkdir -p $ROOT/tmp/$APP_MODULE/conf/conf.d/sites-available
  30. mkdir -p $ROOT/tmp/$APP_MODULE/conf/conf.d/sites-enabled
  31. mkdir -p $ROOT/tmp/$APP_MODULE/conf/conf.d/streams-available
  32. mkdir -p $ROOT/tmp/$APP_MODULE/conf/conf.d/streams-enabled
  33. cd $ROOT/tmp
  34. tar -zcf $ROOT/tmp/$APP_MODULE-installer/$APP_MODULE.tar.gz $APP_MODULE
  35. cd $ROOT
  36. mkdir -p release
  37. cd $ROOT/tmp
  38. tar -zcf $ROOT/release/$APP_MODULE-installer-v${cur_date}.tar.gz $APP_MODULE-installer
  39. rm -rf $ROOT/tmp/*
  40. rmdir $ROOT/tmp
  41. echo "打包成功"