RHEL/Update: replace wc by yum to check updates

Similar to I8bd89f2b24bafc6c991382b9eb484cfa9a2f8968,
use yum to check if updates are available during RHEL registration and
run upgrades only when there are some.

Change-Id: I42cd699d21cbec7d754edf1b8d83e75de0f2c7d9
This commit is contained in:
Emilien Macchi 2017-11-21 15:00:23 -08:00
parent 35c5e7a122
commit b336b45102
1 changed files with 17 additions and 9 deletions

View File

@ -173,18 +173,26 @@ resources:
config: | config: |
#!/bin/bash #!/bin/bash
set -x set -x
num_updates=$(yum list -q updates | wc -l) # yum check-update exits 100 if updates are available
if [ "$num_updates" -eq "0" ]; then set +e
check_update=$(yum check-update 2>&1)
check_update_exit=$?
set -e
if [[ "$check_update_exit" == "100" ]]; then
full_command="yum -q -y update"
echo "Running: $full_command"
result=$($full_command)
return_code=$?
echo "$result"
echo "yum return code: $return_code"
exit $return_code
elif [[ "$check_update_exit" == "1" ]]; then
echo "Failed to check for package updates"
echo "$check_update"
else
echo "No packages require updating" echo "No packages require updating"
exit 0 exit 0
fi fi
full_command="yum -q -y update"
echo "Running: $full_command"
result=$($full_command)
return_code=$?
echo "$result"
echo "yum return code: $return_code"
exit $return_code
UpdateDeploymentAfterRHELRegistration: UpdateDeploymentAfterRHELRegistration:
type: OS::Heat::SoftwareDeployment type: OS::Heat::SoftwareDeployment