Merge "Switch the csit-3node-docker to use job prefix"
[releng/builder.git] / jjb / packaging / install-rpm.sh
1 #!/bin/bash
2
3 # Options:
4 #   -x: Echo commands
5 #   -e: Fail on errors
6 #   -o pipefail: Fail on errors in scripts this calls, give stacktrace
7 set -ex -o pipefail
8
9 # Update mirror list to avoid slow/hung one
10 sudo yum update -y yum-plugin-fastestmirror
11
12 # Install ODL from RPM path, RPM URL or .repo file url
13 # NB: Paths must be anchored at root
14 if [[ $URL == /*  ]]; then
15   # If path is globbed (/path/to/*.rpm), expand it
16   path=$(sudo find / -wholename $URL)
17   sudo yum install -y "$path"
18 elif [[ $URL == *.rpm ]]; then
19   sudo yum install -y "$URL"
20 elif [[ $URL == *.repo ]]; then
21   # shellcheck disable=SC2154
22   repo_file="${URL##*/}"
23   sudo curl --silent -o /etc/yum.repos.d/"$repo_file" "$URL"
24   sudo yum install -y opendaylight
25 else
26   echo "URL is not a link to .rpm or .repo"
27   exit 1
28 fi