6 # -o pipefail: Fail on errors in scripts this calls, give stacktrace
9 # Use local RPM in build-out dir if URL not passed
10 URL=${URL:-"$HOME/rpmbuild/RPMS/noarch/*.rpm"}
12 if [ -f /usr/bin/yum ]; then
13 # Update mirror list to avoid slow/hung one
14 sudo yum update -y yum-plugin-fastestmirror
16 # Install ODL from RPM path, RPM URL or .repo file url
17 # NB: Paths must be anchored at root
18 if [[ $URL == /* ]]; then
19 # If path is globbed (/path/to/*.rpm), expand it
20 path=$(sudo find / -wholename "$URL")
21 sudo yum install -y "$path"
22 elif [[ $URL == *.rpm ]]; then
23 sudo yum install -y "$URL"
24 elif [[ $URL == *.repo ]]; then
25 # shellcheck disable=SC2154
26 repo_file="${URL##*/}"
27 sudo curl --silent -o /etc/yum.repos.d/"$repo_file" "$URL"
28 sudo yum install -y opendaylight
30 echo "URL is not a link to .rpm or .repo"
33 elif [ -f /usr/bin/zypper ]; then
34 # Install ODL from RPM path, RPM URL or .repo file url
35 # NB: Paths must be anchored at root
36 if [[ $URL == /* ]]; then
37 # If path is globbed (/path/to/*.rpm), expand it
38 path=$(sudo find /root -wholename "$URL")
39 sudo zypper -n --no-gpg-checks install "$path"
40 elif [[ $URL == *.rpm ]]; then
41 sudo zypper -n --no-gpg-checks install "$URL"
42 elif [[ $URL == *.repo ]]; then
43 # shellcheck disable=SC2154
44 repo_file="${URL##*/}"
45 sudo curl --silent -o /etc/zypp/repos.d/"$repo_file" "$URL"
46 sudo zypper -n --no-gpg-checks install opendaylight
48 echo "URL is not a link to .rpm or .repo"
52 echo "The package manager is not supported (not yum or zypper)"