-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepo-setup.sh
More file actions
65 lines (56 loc) · 3.93 KB
/
repo-setup.sh
File metadata and controls
65 lines (56 loc) · 3.93 KB
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
# scriptlet:_common/os.sh
# scriptlet:_common/os_version.sh
# scriptlet:_common/os_like.sh
# scriptlet:yum/repo_excludepkg.sh
# scriptlet:_common/package_install.sh
##
# Setup the Zabbix repo for this OS, shared between agent, agent2, server, and proxy.
function zabbix_repo_setup() {
local ZABBIX_VERSION="$1"
local OS_NAME="$(os)"
local OS_VERSION="$(os_version)"
local BASE="https://repo.zabbix.com/zabbix/${ZABBIX_VERSION}"
if [ -z "$(which wget)" ]; then
package_install wget
fi
case "${ZABBIX_VERSION}_${OS_NAME}" in
"7.2_almalinux" ) local SRC="https://repo.zabbix.com/zabbix/7.2/release/alma/${OS_VERSION}/noarch/zabbix-release-latest-7.2.el${OS_VERSION}.noarch.rpm";;
"7.2_debian" ) local SRC="https://repo.zabbix.com/zabbix/7.2/release/debian/pool/main/z/zabbix-release/zabbix-release_latest_7.2+debian${OS_VERSION}_all.deb";;
"7.2_raspbian" ) local SRC="https://repo.zabbix.com/zabbix/7.2/release/raspbian/pool/main/z/zabbix-release/zabbix-release_latest_7.2+debian${OS_VERSION}_all.deb";;
"7.2_rhel" ) local SRC="https://repo.zabbix.com/zabbix/7.2/release/rhel/${OS_VERSION}/noarch/zabbix-release-latest-7.2.el${OS_VERSION}.noarch.rpm";;
"7.2_rocky" ) local SRC="https://repo.zabbix.com/zabbix/7.2/release/rocky/${OS_VERSION}/noarch/zabbix-release-latest-7.2.el${OS_VERSION}.noarch.rpm";;
"7.2_ubuntu" ) local SRC="https://repo.zabbix.com/zabbix/7.2/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.2+ubuntu${OS_VERSION}.04_all.deb";;
"7.0_almalinux" ) local SRC="https://repo.zabbix.com/zabbix/7.0/alma/${OS_VERSION}/x86_64/zabbix-release-latest-7.0.el${OS_VERSION}.noarch.rpm";;
"7.0_debian" ) local SRC="https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_latest_7.0+debian${OS_VERSION}_all.deb";;
"7.0_raspbian" ) local SRC="https://repo.zabbix.com/zabbix/7.0/raspbian/pool/main/z/zabbix-release/zabbix-release_latest_7.0+debian${OS_VERSION}_all.deb";;
"7.0_rhel" ) local SRC="https://repo.zabbix.com/zabbix/7.0/rhel/${OS_VERSION}/x86_64/zabbix-release-latest-7.0.el${OS_VERSION}.noarch.rpm";;
"7.0_rocky" ) local SRC="https://repo.zabbix.com/zabbix/7.0/rocky/${OS_VERSION}/x86_64/zabbix-release-latest-7.0.el${OS_VERSION}.noarch.rpm";;
"7.0_ubuntu" ) local SRC="https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu${OS_VERSION}.04_all.deb";;
"6.0_almalinux" ) local SRC="https://repo.zabbix.com/zabbix/6.0/rhel/${OS_VERSION}/x86_64/zabbix-release-latest-6.0.el${OS_VERSION}.noarch.rpm";;
"6.0_debian" ) local SRC="https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_latest_6.0+debian${OS_VERSION}_all.deb";;
"6.0_raspbian" ) local SRC="https://repo.zabbix.com/zabbix/6.0/raspbian/pool/main/z/zabbix-release/zabbix-release_latest_6.0+debian${OS_VERSION}_all.deb";;
"6.0_rhel" ) local SRC="https://repo.zabbix.com/zabbix/6.0/rhel/${OS_VERSION}/x86_64/zabbix-release-latest-6.0.el${OS_VERSION}.noarch.rpm";;
"6.0_rocky" ) local SRC="https://repo.zabbix.com/zabbix/6.0/rocky/${OS_VERSION}/x86_64/zabbix-release-latest-6.0.el${OS_VERSION}.noarch.rpm";;
"6.0_ubuntu" ) local SRC="https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_6.0+ubuntu${OS_VERSION}.04_all.deb";;
esac
local FILE="$(basename "$SRC")"
# We will use this directory as a working directory for source files that need downloaded.
[ -d /opt/script-collection ] || mkdir -p /opt/script-collection
if [ ! -e /opt/script-collection/$FILE ]; then
wget $SRC -O /opt/script-collection/$FILE
if [ $? -ne 0 ]; then
echo "Failed to download $SRC" >&2
exit 1
fi
if [ $(os_like_debian) -eq 1 ]; then
dpkg -i /opt/script-collection/$FILE
apt update
elif [ $(os_like_rhel) -eq 1 ]; then
yum_repo_excludepkg /etc/yum.repos.d/epel.repo "zabbix*"
rpm -Uvh /opt/script-collection/$FILE
dnf clean all
else
echo "Unable to install $_FILE, unsupported OS [ $OS ] version [ $OSVERSIONMAJ ]" >&2
fi
fi
}