-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathINSTALL.sh
50 lines (45 loc) · 1.5 KB
/
INSTALL.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
#!/bin/sh
set -e
if type dpkg 1> /dev/null 2> /dev/null; then
extension=deb
elif type rpm 1> /dev/null 2> /dev/null; then
extension=rpm
else
echo "Unsupported operating system (no apt-get and no rpm available)" >&2
exit 1
fi
package="$(mktemp -u)"."$extension"
curl --no-progress-meter https://api.github.com/repos/plengauer/opentelemetry-bash/releases/latest | jq -r '.assets[].browser_download_url' | grep '.'"$extension"'$' | xargs wget -O "$package" \
|| curl -v --no-progress-meter https://github.com/plengauer/opentelemetry-bash/releases/latest/download/opentelemetry-shell."$extension" 2>&1 | grep location | awk -F\ '{ print $3 }' | awk -F/ '{ print $8 }' | awk -Fv '{ print $2 }' | xargs -I '{}' wget -O "$package" https://github.com/plengauer/opentelemetry-bash/releases/latest/download/opentelemetry-shell_'{}'."$extension"
if [ "$(whoami)" = "root" ]; then
wrapper=env
else
wrapper=sudo
fi
case "$extension" in
deb)
if type apt-get; then
$wrapper apt-get install -y "$package"
elif type apt; then
$wrapper apt install -y "$package"
else
$wrapper dpkg --install "$package"
fi
;;
rpm)
if type dnf; then
$wrapper dnf -y install "$package"
elif type yum; then
$wrapper yum -y install "$package"
elif type zypper; then
$wrapper zypper --non-interactive install --allow-unsigned-rpm "$package"
else
$wrapper rpm --install "$package"
fi
;;
*)
echo Here be dragons >&2
exit 1
;;
esac
rm "$package"