Skip to content

Commit

Permalink
(maint) shellcheck task scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tw1r3 committed May 12, 2024
1 parent 9f90812 commit 3cead50
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
21 changes: 9 additions & 12 deletions tasks/install_pe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,31 @@ else
PE_RELEASE=$PT_version
fi

PE_LATEST=$(curl https://artifactory.delivery.puppetlabs.net/artifactory/generic_enterprise__local/${PE_RELEASE}/ci-ready/LATEST)
PE_LATEST=$(curl https://artifactory.delivery.puppetlabs.net/artifactory/generic_enterprise__local/"${PE_RELEASE}"/ci-ready/LATEST)
PE_FILE_NAME=puppet-enterprise-${PE_LATEST}-el-7-x86_64
TAR_FILE=${PE_FILE_NAME}.tar
DOWNLOAD_URL=https://artifactory.delivery.puppetlabs.net/artifactory/generic_enterprise__local/${PE_RELEASE}/ci-ready/${TAR_FILE}

## Download PE
curl -o ${TAR_FILE} ${DOWNLOAD_URL}
if [[ $? -ne 0 ]];then
echo “Error: wget failed to download [${DOWNLOAD_URL}]”
if ! curl -o "${TAR_FILE}" "${DOWNLOAD_URL}" ; then
echo "Error: failed to download [${DOWNLOAD_URL}]"
exit 2
fi

## Install PE
tar xvf ${TAR_FILE}
if [[ $? -ne 0 ]];then
echo “Error: Failed to untar [${TAR_FILE}]”
if ! tar xvf "${TAR_FILE}" ; then
echo "Error: Failed to untar [${TAR_FILE}]"
exit 2
fi

cd ${PE_FILE_NAME}
DISABLE_ANALYTICS=1 ./puppet-enterprise-installer -y -c ./conf.d/pe.conf
if [[ $? -ne 0 ]];then
echo “Error: Failed to install Puppet Enterprise. Please check the logs and call Bryan.x ”
cd "${PE_FILE_NAME}" || exit 1
if ! DISABLE_ANALYTICS=1 ./puppet-enterprise-installer -y -c ./conf.d/pe.conf ; then
echo "Error: Failed to install Puppet Enterprise. Please check the logs and call Bryan.x"
exit 2
fi

## Finalize configuration
echo Finalize PE install
echo "Finalize PE install"
puppet agent -t
# if [[ $? -ne 0 ]];then
# echo “Error: Agent run failed. Check the logs above...”
Expand Down
21 changes: 10 additions & 11 deletions tasks/install_puppetserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fi

parse_platform() {
data=()
for x in $(echo $1 | tr "[/|-|-|:]" "\n")
for x in $(echo "$1" | tr "/|-|-|:" "\n")
do
data+=("$x")
done
Expand Down Expand Up @@ -59,9 +59,8 @@ fetch_osfamily() {
}

fetch_collection() {
data=$(echo $1 | tr "-" "\n")
myarr=()
for x in $(echo $1 | tr "-" "\n")
for x in $(echo "$1" | tr "-" "\n")
do
myarr+=("$x")
done
Expand Down Expand Up @@ -100,14 +99,14 @@ fetch_codename() {
}

run_cmd() {
eval $1
eval "$1"
rc=$?

if test $rc -ne 0; then
attempt_number=0
while test $attempt_number -lt $retry; do
while test $attempt_number -lt "$retry"; do
echo "Retrying... [$((attempt_number + 1))/$retry]"
eval $1
eval "$1"
rc=$?

if test $rc -eq 0; then
Expand All @@ -133,10 +132,10 @@ if [[ "$platform" == "null" || "$collection" == "null" ]]; then
exit 1
fi

osname=$(parse_platform $platform "osname")
major_version=$(parse_platform $platform "majorversion")
osfamily=$(fetch_osfamily $osname)
collection=$(fetch_collection $collection)
osname=$(parse_platform "$platform" "osname")
major_version=$(parse_platform "$platform" "majorversion")
osfamily=$(fetch_osfamily "$osname")
collection=$(fetch_collection "$collection")

if [[ "$collection" == "puppet5" ]]; then
echo "puppet5 eol!"
Expand All @@ -149,7 +148,7 @@ if [[ "$osfamily" == "unsupported" ]]; then
fi

if [[ "$osfamily" == "debian" ]]; then
codename=$(fetch_codename $collection $major_version)
codename=$(fetch_codename "$collection $major_version")
if [[ "$codename" == "unsupported" ]]; then
echo "No builds for $platform"
exit 1
Expand Down

0 comments on commit 3cead50

Please sign in to comment.