Skip to content

Commit

Permalink
improved shell scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
fatz committed Aug 22, 2023
1 parent b82ba66 commit bf1be8a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion scripts/common/clean_authorized_keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cloud-init --version
test -n "${BASE_IMAGE_SSH_USER}"

# echo "Cleaning authorized_keys for ${BASE_IMAGE_SSH_USER}"
echo "" > /home/$BASE_IMAGE_SSH_USER/.ssh/authorized_keys
echo "" > "/home/$BASE_IMAGE_SSH_USER/.ssh/authorized_keys"
13 changes: 6 additions & 7 deletions scripts/common/cloudinit_from_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ else
fi

function fatal {
msg=$1
echo $1 >2
echo "$1" >&2
exit 1
}

Expand All @@ -24,9 +23,9 @@ function download {
filename=$2

if [ -x "$(which wget)" ] ; then
wget -q $url -O $2
wget -q "$url" -O "$filename"
elif [ -x "$(which curl)" ]; then
curl -o $2 -sfL $url
curl -o "$filename" -sfL "$url"
else
echo "Could not find curl or wget, please install one." >&2
exit 1
Expand All @@ -37,12 +36,12 @@ function download {
type ${PYTHON_CMD} || fatal "${PYTHON_CMD} not found"
type ${PIP_CMD} || fatal "${PIP_CMD} not found"

download https://github.com/canonical/cloud-init/archive/refs/tags/${CLOUDINIT_VERSION}.tar.gz ${CLOUDINIT_DOWNLOADFILE}
download "https://github.com/canonical/cloud-init/archive/refs/tags/${CLOUDINIT_VERSION}.tar.gz" ${CLOUDINIT_DOWNLOADFILE}
mkdir -p ${CLOUDINIT_EXTRACT_FOLDER}
tar xzf ${CLOUDINIT_DOWNLOADFILE} -C ${CLOUDINIT_EXTRACT_FOLDER}

${PIP_CMD} install -r ${CLOUDINIT_EXTRACT_FOLDER}/cloud-init-${CLOUDINIT_VERSION}/requirements.txt
( cd ${CLOUDINIT_EXTRACT_FOLDER}/cloud-init-${CLOUDINIT_VERSION}
${PIP_CMD} install -r "${CLOUDINIT_EXTRACT_FOLDER}/cloud-init-${CLOUDINIT_VERSION}/requirements.txt"
( cd "${CLOUDINIT_EXTRACT_FOLDER}/cloud-init-${CLOUDINIT_VERSION}" || exit 1
${PYTHON_CMD} setup.py build
${PYTHON_CMD} setup.py install -O1 --skip-build --init-system systemd --install-scripts /usr/bin
)
Expand Down
6 changes: 3 additions & 3 deletions scripts/el/rhn_add_subscription.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh -eu
#!/bin/bash -eu

if [[ "${RHN_SUBSCRIPTION_KEY}" != "" && "${RHN_SUBSCRIPTION_ORG}" != "" ]]; then
subscription-manager register --org=${RHN_SUBSCRIPTION_ORG} --activationkey=${RHN_SUBSCRIPTION_KEY}
subscription-manager register --org="${RHN_SUBSCRIPTION_ORG}" --activationkey="${RHN_SUBSCRIPTION_KEY}"
exit 0
fi

Expand All @@ -16,4 +16,4 @@ if [[ "${RHN_PASSWORD}" == "" ]]; then
exit 1
fi

subscription-manager register --username $RHN_USERNAME --password $RHN_PASSWORD --auto-attach
subscription-manager register --username "$RHN_USERNAME" --password "$RHN_PASSWORD" --auto-attach

0 comments on commit bf1be8a

Please sign in to comment.