2b22fd541cfcb80b56e95d15a82997e7277162cf
[releng/builder.git] / jjb / packaging / include-raw-test-deb.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 # Wait for any background apt processes to finish
10 # There seems to be a backgroud apt process that locks /var/lib/dpkg/lock
11 # and causes our apt commands to fail.
12 while pgrep apt > /dev/null; do sleep 1; done
13
14 # Install ODL from .deb link or .repo url
15 if [[ $PACKAGE == *.deb ]]
16 then
17   # shellcheck disable=SC2154
18   pkg_basename="${{PACKAGE##*/}}"
19   # NB: Apt can't install directly from URL, so need this intermediary file
20   curl -o "$pkg_basename" "$PACKAGE"
21   sudo dpkg --install ./"$pkg_basename"
22 elif [[ $PACKAGE == ppa:* ]]
23 then
24   sudo add-apt-repository "$PACKAGE"
25   sudo apt-get update
26   sudo apt-get install -y opendaylight
27 else
28   echo "URL is not a link to a PPA repo or .deb"
29 fi
30
31 # Install expect to interact with karaf shell
32 sudo apt-get install -y expect
33
34 # Start OpenDaylight
35 sudo systemctl start opendaylight
36
37 # Check status of OpenDaylight
38 sudo systemctl status opendaylight
39
40 # Get process id of Java
41 pgrep java