package.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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="nsq-server"
  9. APP_MODULE="nsq-server"
  10. # ----- Start build -----
  11. mkdir -p $ROOT/cache
  12. cd $ROOT/cache
  13. # Download nsq binary
  14. REMOTE_URL="https://s3.amazonaws.com/bitly-downloads/nsq/nsq-1.3.0.linux-amd64.go1.21.5.tar.gz"
  15. LOCAL_FILE="nsq-1.3.0.linux-amd64.go1.21.5"
  16. if [ ! -f "$LOCAL_FILE.tar.gz" ]; then
  17. echo "Downloading nsq binary..."
  18. wget $REMOTE_URL -O "$LOCAL_FILE.tar.gz"
  19. tar xf "$LOCAL_FILE.tar.gz"
  20. fi
  21. # ----- End build -----
  22. cd $ROOT
  23. cp -rf $ROOT/$APP_MODULE $ROOT/tmp/
  24. cp -rf $ROOT/$APP_MODULE-installer $ROOT/tmp/
  25. mkdir -p $ROOT/tmp/$APP_MODULE/logs
  26. mkdir -p $ROOT/tmp/$APP_MODULE/tmp
  27. mkdir -p $ROOT/tmp/$APP_MODULE/bin
  28. cp -rf $ROOT/config $ROOT/tmp/$APP_MODULE/config
  29. # ----- Start copy -----
  30. cp -rf $ROOT/cache/$LOCAL_FILE/bin/* $ROOT/tmp/$APP_MODULE/bin/
  31. # ----- End copy -----
  32. cd $ROOT/tmp
  33. tar -zcf $ROOT/tmp/$APP_MODULE-installer/$APP_MODULE.tar.gz $APP_MODULE
  34. cd $ROOT
  35. mkdir -p release
  36. cd $ROOT/tmp
  37. tar -zcf $ROOT/release/$APP_MODULE-installer-v${cur_date}.tar.gz $APP_MODULE-installer
  38. rm -rf $ROOT/tmp/*
  39. rmdir $ROOT/tmp
  40. echo "打包成功"