#!/bin/bash set -e cur_date="`date +%Y-%m-%d`" ROOT=$(cd `dirname $0`; pwd) mkdir -p $ROOT/tmp rm -rf $ROOT/tmp/* # NOTE: App is installed to /opt/$APP_COMPARTMENT/$APP_MODULE APP_COMPARTMENT="nsq-server" APP_MODULE="nsq-server" # ----- Start build ----- mkdir -p $ROOT/cache cd $ROOT/cache # Download nsq binary REMOTE_URL="https://s3.amazonaws.com/bitly-downloads/nsq/nsq-1.3.0.linux-amd64.go1.21.5.tar.gz" LOCAL_FILE="nsq-1.3.0.linux-amd64.go1.21.5" if [ ! -f "$LOCAL_FILE.tar.gz" ]; then echo "Downloading nsq binary..." wget $REMOTE_URL -O "$LOCAL_FILE.tar.gz" tar xf "$LOCAL_FILE.tar.gz" fi # ----- End build ----- cd $ROOT cp -rf $ROOT/$APP_MODULE $ROOT/tmp/ cp -rf $ROOT/$APP_MODULE-installer $ROOT/tmp/ mkdir -p $ROOT/tmp/$APP_MODULE/logs mkdir -p $ROOT/tmp/$APP_MODULE/tmp mkdir -p $ROOT/tmp/$APP_MODULE/bin cp -rf $ROOT/config $ROOT/tmp/$APP_MODULE/config # ----- Start copy ----- cp -rf $ROOT/cache/$LOCAL_FILE/bin/* $ROOT/tmp/$APP_MODULE/bin/ # ----- End copy ----- cd $ROOT/tmp tar -zcf $ROOT/tmp/$APP_MODULE-installer/$APP_MODULE.tar.gz $APP_MODULE cd $ROOT mkdir -p release cd $ROOT/tmp tar -zcf $ROOT/release/$APP_MODULE-installer-v${cur_date}.tar.gz $APP_MODULE-installer rm -rf $ROOT/tmp/* rmdir $ROOT/tmp echo "打包成功"