-
Notifications
You must be signed in to change notification settings - Fork 27
/
GetAmznLx.sh
executable file
·48 lines (45 loc) · 1.3 KB
/
GetAmznLx.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
#!/bin/sh
# shellcheck disable=SC2086,SC2046,SC2010,SC2207
#
# Attempt to auto-populate the AWSpkgs directory
#
#################################################################
SCRIPTROOT="$(dirname ${0})"
CHROOT="${CHROOT:-/mnt/ec2-root}"
PROJECT="Lx-GetAMI-Utils"
AMZNLXGIT="${1:-https://github.com/ferricoxide/${PROJECT}.git}"
ELVERSION="el$(rpm --qf '%{version}' -q $(rpm -qf /etc/redhat-release)| cut -d . -f 1)"
# Fetch Amzn.Linux RPMs if necessary
if [[ -d ${SCRIPTROOT}/../${PROJECT} ]]
then
echo "Amzn.Linux project-dir exits"
else
echo "Attempting to fetch project..."
( cd "${SCRIPTROOT}/".. || exit 1
git clone "${AMZNLXGIT}" )
if [[ ! -d ${SCRIPTROOT}/../${PROJECT} ]]
then
echo "Failed to download ${AMZNLXGIT}. Aborting..." > /dev/stderr
exit 1
fi
fi
# Grab platform RPMs
case ${ELVERSION} in
el6)
RPMLIST=($(ls -1 "${SCRIPTROOT}"/../"${PROJECT}"/*.rpm | grep -v el7))
;;
el7)
RPMLIST=($(ls -1 "${SCRIPTROOT}"/../"${PROJECT}"/*.rpm | grep -v el6))
;;
*) echo "Platform not supported. Aborting..." > /dev/stederr
exit 1
;;
esac
LOOP=0
while [[ ${LOOP} -lt ${#RPMLIST[@]} ]]
do
echo "Copying ${RPMLIST[${LOOP}]} to AWSpkgs"
ln "${RPMLIST[${LOOP}]}" AWSpkgs
# shellcheck disable=SC2004
LOOP=$(($LOOP + 1))
done