master
sh 176 lines 4.71 KB
Raw
1 #!/bin/sh
2
3 SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"
4
5 export DISABLE_TELEMETRY=1
6
7 install_debian_like() {
8 # This is needed to ensure package installs don't prompt for any user input.
9 export DEBIAN_FRONTEND=noninteractive
10
11 if apt-cache show netcat 2>&1 | grep -q "No packages found"; then
12 netcat="netcat-traditional"
13 else
14 netcat="netcat"
15 fi
16
17 apt-get update
18
19 # Install Netdata
20 # Strange quoting is required here so that glob matching works.
21 # shellcheck disable=SC2046
22 apt-get install -y $(find /netdata/artifacts -type f -name 'netdata*.deb' \
23 ! -name '*dbgsym*' ! -name '*cups*' ! -name '*freeipmi*') || exit 3
24
25 # Install testing tools
26 apt-get install -y --no-install-recommends curl dpkg-dev "${netcat}" jq || exit 1
27
28 dpkg-architecture --equal amd64 || NETDATA_SKIP_EBPF=1
29 }
30
31 install_fedora_like() {
32 # Using a glob pattern here because I can't reliably determine what the
33 # resulting package name will be (TODO: There must be a better way!)
34
35 PKGMGR="$( (command -v dnf > /dev/null && echo "dnf") || echo "yum")"
36
37 if [ "${PKGMGR}" = "dnf" ]; then
38 opts="--allowerasing"
39 fi
40
41 # Install Netdata
42 # Strange quoting is required here so that glob matching works.
43 "${PKGMGR}" install -y /netdata/artifacts/netdata*.rpm || exit 1
44
45 # Install testing tools
46 "${PKGMGR}" install -y curl nc jq || exit 1
47
48 [ "$(rpm --eval '%{_build_arch}')" = "x86_64" ] || NETDATA_SKIP_EBPF=1
49 }
50
51 install_centos() {
52 # Using a glob pattern here because I can't reliably determine what the
53 # resulting package name will be (TODO: There must be a better way!)
54
55 PKGMGR="$( (command -v dnf > /dev/null && echo "dnf") || echo "yum")"
56
57 if [ "${PKGMGR}" = "dnf" ]; then
58 opts="--allowerasing"
59 fi
60
61 # Install EPEL (needed for `jq`
62 "${PKGMGR}" install -y epel-release || exit 1
63
64 # Install Netdata
65 # Strange quoting is required here so that glob matching works.
66 "${PKGMGR}" install -y /netdata/artifacts/netdata*.rpm || exit 1
67
68 # Install testing tools
69 # shellcheck disable=SC2086
70 "${PKGMGR}" install -y ${opts} curl nc jq || exit 1
71
72 [ "$(rpm --eval '%{_build_arch}')" = "x86_64" ] || NETDATA_SKIP_EBPF=1
73 }
74
75 install_amazon_linux() {
76 PKGMGR="$( (command -v dnf > /dev/null && echo "dnf") || echo "yum")"
77
78 if [ "${PKGMGR}" = "dnf" ]; then
79 opts="--allowerasing"
80 fi
81
82 # Install Netdata
83 # Strange quoting is required here so that glob matching works.
84 "${PKGMGR}" install -y /netdata/artifacts/netdata*.rpm || exit 1
85
86 # Install testing tools
87 # shellcheck disable=SC2086
88 "${PKGMGR}" install -y ${opts} curl nc jq || exit 1
89
90 [ "$(rpm --eval '%{_build_arch}')" = "x86_64" ] || NETDATA_SKIP_EBPF=1
91 }
92
93 install_suse_like() {
94 # Using a glob pattern here because I can't reliably determine what the
95 # resulting package name will be (TODO: There must be a better way!)
96
97 # Install Netdata
98 # Strange quoting is required here so that glob matching works.
99 zypper install -y --allow-downgrade --allow-unsigned-rpm /netdata/artifacts/netdata*.rpm || exit 1
100
101 # Install testing tools
102 zypper install -y --allow-downgrade --no-recommends curl netcat-openbsd jq || exit 1
103
104 [ "$(rpm --eval '%{_build_arch}')" = "x86_64" ] || NETDATA_SKIP_EBPF=1
105 }
106
107 dump_log() {
108 cat ./netdata.log
109 }
110
111 check_topology_ip_intel_stock() {
112 stock_root="/usr/share/netdata/topology-ip-intel"
113
114 [ -d "${stock_root}" ] || return 0
115
116 for path in \
117 "${stock_root}/README.md" \
118 "${stock_root}/topology-ip-asn.mmdb" \
119 "${stock_root}/topology-ip-geo.mmdb" \
120 "${stock_root}/topology-ip-intel.json"
121 do
122 if [ ! -s "${path}" ]; then
123 printf "ERROR: missing packaged topology IP intelligence payload file: %s\n" "${path}"
124 exit 1
125 fi
126 done
127
128 if [ -e "${stock_root}/topology-ip-country.mmdb" ]; then
129 printf "ERROR: obsolete packaged topology IP intelligence file still present: %s\n" \
130 "${stock_root}/topology-ip-country.mmdb"
131 exit 1
132 fi
133 }
134
135 case "${DISTRO}" in
136 debian | ubuntu)
137 install_debian_like
138 ;;
139 fedora | oraclelinux)
140 install_fedora_like
141 ;;
142 centos | centos-stream | rockylinux | almalinux)
143 install_centos
144 ;;
145 amazonlinux)
146 install_amazon_linux
147 ;;
148 opensuse)
149 install_suse_like
150 ;;
151 *)
152 printf "ERROR: unsupported distro: %s_%s\n" "${DISTRO}" "${DISTRO_VERSION}"
153 exit 1
154 ;;
155 esac
156
157 echo "::group::Netdata buildinfo"
158 /usr/sbin/netdata -W buildinfo
159 echo "::endgroup::"
160
161 check_topology_ip_intel_stock
162
163 trap dump_log EXIT
164
165 export NETDATA_LIBEXEC_PREFIX=/usr/libexec/netdata
166 export NETDATA_SKIP_LIBEXEC_PARTS="freeipmi|xenstat|nfacct|cups"
167
168 if [ -n "${NETDATA_SKIP_EBPF}" ]; then
169 export NETDATA_SKIP_LIBEXEC_PARTS="${NETDATA_SKIP_LIBEXEC_PARTS}|ebpf"
170 fi
171
172 /usr/sbin/netdata -D > ./netdata.log 2>&1 &
173
174 "${SCRIPT_DIR}/../../packaging/runtime-check.sh" || exit 1
175
176 trap - EXIT