-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_packages
executable file
·110 lines (92 loc) · 3.1 KB
/
create_packages
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
#!/bin/bash
######################################################################
VERSION="4.4.3"
######################################################################
### HELPERS
prepare(){
echo "***************************************************************************************************************************************"
echo "PREPARE"
set -e
set -x
wget -c -O $SDIR/${VERSION}-static.tar.gz https://www.zabbix.com/downloads/${VERSION}/zabbix_agents-${VERSION}-linux3.0-amd64-static.tar.gz
mkdir $TMPDIR/static
tar -C $TMPDIR/static -zxvf $SDIR/${VERSION}-static.tar.gz
rm $TMPDIR/static/conf/zabbix_agentd/userparameter_*.conf
mkdir -p $TMPDIR/static/etc/init.d/
cp $SDIR/zabbix-agent.sysv $TMPDIR/static/etc/init.d/zabbix-agent
mv $TMPDIR/static/conf $TMPDIR/static/etc/zabbix/
mkdir $TMPDIR/static/usr
mv $TMPDIR/static/sbin $TMPDIR/static/usr/sbin
mv $TMPDIR/static/bin $TMPDIR/static/usr/bin
mkdir -p $TMPDIR/static/var/run/zabbix $TMPDIR/static/var/log/zabbix
chmod 755 $TMPDIR/static/var/run/zabbix $TMPDIR/static/var/log/zabbix
if [ -f "$SRCDIR/zabbix_agentd.conf.custom" ];then
cp -v "$SRCDIR/zabbix_agentd.conf.custom" TMPDIR/static/etc/zabbix/
fi
set +x
set +e
echo "prepare complete"
}
create_package(){
TYPE="$1"
echo "***************************************************************************************************************************************"
echo "PACKAGE TYPE: $TYPE"
echo
set -x
fpm --verbose -s dir \
-t $TYPE \
-n zabbix-agent \
--license GPLv2 \
-a native \
--deb-no-default-config-files \
--deb-group zabbix \
--rpm-group zabbix \
--rpm-user zabbix \
--deb-user zabbix \
--config-files /etc/zabbix/zabbix_agentd.conf \
-m "VICO OPS <[email protected]>" \
--url "https://github.com/vico-research-and-consulting/zabbix-agent-static" \
--after-install ${SDIR}/postinstall \
--before-remove ${SDIR}/prerm \
--after-remove ${SDIR}/postrm \
--conflicts zabbix-agent --conflicts zabbix-get --conflicts zabbix-sender \
-v $VERSION \
$TMPDIR/static/=/
set +x
echo "CONTENTS $TYPE:"
echo "------------------------------------------------------_"
if [ "$TYPE" = "deb" ];then
dpkg -c zabbix-agent_*.deb
RET="$?"
elif [ "$TYPE" = "rpm" ];then
rpm -qlvp zabbix-agent*.rpm
RET="$?"
fi
echo "------------------------------------------------------_"
if [ "$RET" != "0" ];then
echo "ERROR: error on creation of $TYPE package"
exit 1
fi
}
######################################################################
### MAIN
if [ -z "$1" ];then
echo "$0 <version>"
fi
SDIR="$(dirname $(readlink -f $0))/"
for P in $HOME/.gem/ruby/*/bin/fpm;do
P="$(dirname $P)"
export PATH="$P:$PATH"
done
if ( ! (type -a fpm >/dev/null 2>&1 ) );then
echo "Unable to find 'fpm'"
exit 100
fi
echo "CREATING VERSION: $VERSION"
rm -rf zabbix-agent_*.deb zabbix-agent*.rpm
TMPDIR="$(mktemp -d)"
trap "rm -rf $TMPDIR" EXIT TERM INT
prepare
create_package rpm
create_package deb
exit 0