Skip to content

Instantly share code, notes, and snippets.

@dstreev
Created August 30, 2016 19:06
Show Gist options
  • Save dstreev/baec49347e2805a1aff256ba46f63a78 to your computer and use it in GitHub Desktop.
Save dstreev/baec49347e2805a1aff256ba46f63a78 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#########################
#
# WARNING: I make NO guarantees, test it first. This can be VERY destructive!! You've been warned... again..
#
# Usage: ./remove-hdp.sh <hdp-version>
#
# This will yum erase the hdp version specified on the host. To use this on the cluster,
# try copying to an Ambari Servers resources directory. /var/lib/ambari-server/resources
#
# Then from each host, fetch the file to /tmp
# pdsh -g <server_group> wget http://<ambari-host:port>/resources/remove-hdp.sh -O /tmp/remove-hdp.sh
#
# Set the permissions:
# pdsh -g <server_group> sudo chmod 777 /tmp/remove-hdp.sh
#
# Remove Versions, for example:
# pdsh -g <server_group> sudo /tmp/remove-hdp.sh 2.3.5.1-285
#
#
#########################
# Example Version 2_3_0_0_2557
HDP_VERSION=$1
if [ "${HDP_VERSION}x" == "x" ]; then
echo "Need to specify an HDP version".
exit
fi
# Convert name to package version
HDP_VERSION=`echo ${HDP_VERSION} | tr '.' '_' | tr '-' '_'`
echo "Checking for HDP RPM Package Version: ${HDP_VERSION}"
for i in `yum info *${HDP_VERSION}* | grep ^Name.*${HDP_VERSION}.* | awk '{ print $3 }'`; do
echo "Removing Package: ${i}"
yum -y erase ${i}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment