-
Notifications
You must be signed in to change notification settings - Fork 11
/
make.sh
executable file
·116 lines (92 loc) · 4.84 KB
/
make.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
set +x
set +e
cd $GOPATH/src/github.com/aerospike-community/amc
edition=${1:-enterprise}
environ=${2:-dev}
platform=${3:-linux}
sysname=$(uname | tr '[:upper:]' '[:lower:]')
#maintainer="Khosrow Afroozeh ([email protected])"
maintainer="Zohar Elkayam ([email protected])"
description="Aerospike Management Console"
echo "platform is ${platform}"
echo "sysname is ${sysname}"
build=`date -u +%Y%m%d.%H%M%S`
version=`git describe --tags $(git rev-list --tags --max-count=1)`
# version=`git describe`
# build content
rm -rf build/static
cd static
npm install
grunt
cd ..
case $platform in
'linux')
BASE_DIR="deployment/release/linux"
rm -rf $BASE_DIR/opt/amc/static
rm -rf $BASE_DIR/opt/amc/mailer
rm -rf $BASE_DIR/etc/init.d
mkdir -p $BASE_DIR/var/log
mkdir -p $BASE_DIR/opt/amc
mkdir -p $BASE_DIR/etc/amc
cp -R build/static $BASE_DIR/opt/amc/
mkdir -p $BASE_DIR/opt/amc/mailer
cp -R mailer/templates $BASE_DIR/opt/amc/mailer/
# build binary
CGO_ENABLED=0 GOOS=$platform go build -a -tags "purego $edition" -ldflags "-X github.com/aerospike-community/amc/common.AMCEdition=$edition -X github.com/aerospike-community/amc/common.AMCBuild=$build -X github.com/aerospike-community/amc/common.AMCVersion=$version -X github.com/aerospike-community/amc/common.AMCEnv=$environ" -o $BASE_DIR/opt/amc/amc .
# rpm systemd
cp -f deployment/common/amc.service $BASE_DIR/opt/amc/
fpm --config-files /etc/amc --rpm-os linux --after-install "deployment/common/systemd_after_install.sh" -f -s dir -t rpm -n "aerospike-amc-$edition" -v $version -C $BASE_DIR -m "$maintainer" --description "$description" --vendor "Aerospike" .
mv aerospike-amc-${edition}-`echo $version | tr - _`-1.x86_64.rpm aerospike-amc-${edition}-`echo $version | tr - _`-1.x86_64.systemd.rpm
rm $BASE_DIR/opt/amc/amc.service
# rpm init.d
mkdir -p $BASE_DIR/etc/init.d
cp -f deployment/common/amc.rpm $BASE_DIR/etc/init.d/amc
chmod +x $BASE_DIR/etc/init.d/amc
fpm --config-files /etc/amc --rpm-os linux -f -s dir -t rpm -n "aerospike-amc-$edition" -v $version -C $BASE_DIR -m "$maintainer" --description "$description" --vendor "Aerospike" .
# deb for init.d
cp -f deployment/common/amc.deb $BASE_DIR/etc/init.d/amc
chmod +x $BASE_DIR/etc/init.d/amc
fpm --config-files /etc/amc -f -s dir -t deb -n "aerospike-amc-$edition" -v $version -C $BASE_DIR -m "$maintainer" --description "$description" --vendor "Aerospike" .
## deb download need to be renamed from _ to -
mv aerospike-amc-${edition}_${version}_amd64.deb aerospike-amc-${edition}-${version}_amd64.deb
# deb for systemd
rm -rf $BASE_DIR/etc/init.d
cp -f deployment/common/amc.service $BASE_DIR/opt/amc/
fpm --config-files /etc/amc --after-install "deployment/common/systemd_after_install.sh" -f -s dir -t deb -n "aerospike-amc-$edition" -v $version -C $BASE_DIR -m "$maintainer" --description "$description" --vendor "Aerospike" .
## deb download need to be renamed from _ to -
mv aerospike-amc-${edition}_${version}_amd64.deb aerospike-amc-${edition}-${version}_amd64.systemd.deb
# zip, for all others with init.d
mkdir $BASE_DIR/etc/init.d
cp -f deployment/common/amc.other.sh $BASE_DIR/etc/init.d/amc
chmod +x $BASE_DIR/etc/init.d/amc
fpm --config-files /etc/amc -f -s dir -t tar -n "aerospike-amc-$edition" -v $version -C $BASE_DIR -m "$maintainer" --description "$description" --vendor "Aerospike" .
gzip "aerospike-amc-$edition.tar"
mv "aerospike-amc-$edition.tar.gz" "aerospike-amc-$edition-$version-linux.tar.gz"
# zip, for all other with systemd
rm -rf $BASE_DIR/etc/init.d
cp -f deployment/common/amc.service $BASE_DIR/opt/amc/
fpm --config-files /etc/amc -f -s dir -t tar -n "aerospike-amc-$edition" -v $version -C $BASE_DIR -m "$maintainer" --description "$description" --vendor "Aerospike" .
gzip "aerospike-amc-$edition.tar"
mv "aerospike-amc-$edition.tar.gz" "aerospike-amc-$edition-$version-linux.systemd.tar.gz"
;;
'darwin')
BASE_DIR="deployment/release/darwin/amc"
mkdir -p $BASE_DIR
rm -rf $BASE_DIR/static
rm -rf $BASE_DIR/mailer
cp -R build/static $BASE_DIR/
mkdir -p $BASE_DIR/mailer
cp -R mailer/templates $BASE_DIR/mailer/
# build binary
CGO_ENABLED=0 GOOS=$platform go build -a -tags "purego $edition" -ldflags "-X github.com/aerospike-community/amc/common.AMCEdition=$edition -X github.com/aerospike-community/amc/common.AMCBuild=$build -X github.com/aerospike-community/amc/common.AMCVersion=$version -X github.com/aerospike-community/amc/common.AMCEnv=$environ" -o $BASE_DIR/amc .
# zip
fpm --verbose -f -s dir -t tar -n "aerospike-amc-$edition" -v $version -C deployment/release/darwin -m "$maintainer" --description "$description" --vendor "Aerospike" .
gzip "aerospike-amc-$edition.tar"
mv "aerospike-amc-$edition.tar.gz" "aerospike-amc-$edition-$version-darwin.tar.gz"
;;
*)
echo "unrecognized platform ${platform}"
exit 1
;;
esac