-
Notifications
You must be signed in to change notification settings - Fork 9
/
build-consul-template-rpm.sh
executable file
·64 lines (54 loc) · 1.42 KB
/
build-consul-template-rpm.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
#!/bin/bash
#
if [[ -z "$1" ]]; then
echo $"Usage: $0 <VERSION> [ARCH]"
exit 1
fi
NAME=consul-template
VERSION=$1
if [[ -z "$2" ]]; then
ARCH=`uname -m`
else
ARCH=$2
fi
#https://github.com/hashicorp/consul-template/releases/download/v0.2.0/consul-template_0.2.0_linux_amd64.tar.gz
case "${ARCH}" in
i386)
ZIP=${NAME}_${VERSION}_linux_386.tar.gz
;;
x86_64)
ZIP=${NAME}_${VERSION}_linux_amd64.tar.gz
;;
*)
echo $"Unknown architecture ${ARCH}" >&2
exit 1
;;
esac
URL="https://github.com/hashicorp/${NAME}/releases/download/v${VERSION}/${ZIP}"
echo $"Creating ${NAME} RPM build file version ${VERSION}"
# fetching consul
curl -k -L -o $ZIP $URL || {
echo $"URL or version not found!" >&2
exit 1
}
# clear target foler
rm -rf target/*
# create target structure
mkdir -p target/usr/local/bin/
cp -r sources/${NAME}/etc/ target/
# unzip
tar -xf ${ZIP} -O > target/usr/local/bin/${NAME}
rm ${ZIP}
# create rpm
fpm -s dir -t rpm -f \
-C target -n ${NAME} \
-v ${VERSION} \
-p target \
-d "consul" \
--after-install spec/template_install.spec \
--after-remove spec/template_uninstall.spec \
--rpm-ignore-iteration-in-dependencies \
--description "Consul-template RPM package for RedHat Enterprise Linux 6" \
--url "https://github.com/hypoport/consul-rpm-rhel6" \
usr/ etc/
rm -rf target/etc target/usr