From 0fecd1f748e578cb247e10e81bec352c8cf97448 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Fri, 7 Oct 2011 18:37:09 +0530 Subject: helper_scripts/glusterfs_uninstall: scripts for uninstalling glusterfs scripts which uninstalls glusterfs on the local machine and on a set of machines. --- helper_scrips/INFO | 4 +++ helper_scrips/glusterfs_uninstall.sh | 46 +++++++++++++++++++++++++ helper_scrips/multi_uninstall.sh | 66 ++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100755 helper_scrips/glusterfs_uninstall.sh create mode 100755 helper_scrips/multi_uninstall.sh diff --git a/helper_scrips/INFO b/helper_scrips/INFO index c349fba..ad0d600 100644 --- a/helper_scrips/INFO +++ b/helper_scrips/INFO @@ -15,3 +15,7 @@ The above scripts are usable with the passwordless ssh connection setup between ============================================================================================================================================= helper_scripts/install_parallel_glusterfs.sh --------> executes the download_and_install.sh scripts prallely on multiple machines, such that glusterfs gets installed on multiple machines simultaneously. + +============================================================================================================================================= +helper_scrips/glusterfs_uninstall.sh ------> uninstalls the specified glusterfs version if it finds the source directory. +herper_scripts/multi_uninstall.sh -------> uninstalls the specified glusterfs from multiple machines, by executing glusterfs_uninstall.sh script. diff --git a/helper_scrips/glusterfs_uninstall.sh b/helper_scrips/glusterfs_uninstall.sh new file mode 100755 index 0000000..31a000d --- /dev/null +++ b/helper_scrips/glusterfs_uninstall.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +#set -x; + +function _init () +{ + # echo $0; + # echo $#; + # echo $1; + set -u; + if [ $# -lt 1 ]; then + echo "usage: download_and_install "; + exit 1; + fi + + version=$1; + echo $version; + echo $version | grep "glusterfs" 2>/dev/null 1>/dev/null; + if [ $? -ne 0 ]; then + echo "given argument is not glusterfs"; + exit 1; + fi +} + +function un_install () +{ + cd /root/$version; + + cd build; + make uninstall && make clean && make distclean; + + cd /root; +} + +main () +{ + + if [ ! -d $version ]; then + echo "the glusterfs version ($version) directory is not there." + return 1; + fi + + un_install; +} + +_init "$@" && main "$@" diff --git a/helper_scrips/multi_uninstall.sh b/helper_scrips/multi_uninstall.sh new file mode 100755 index 0000000..dca2350 --- /dev/null +++ b/helper_scrips/multi_uninstall.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +#!/bin/bash + +function _init () +{ + set -u; + VERSION=$1; +} + +function uninstall_glusterfs () +{ + local remote_server=; + + if [ $# -eq 1 ]; then + remote_server=$1; + fi + + if [ $remote_server ]; then + ssh $remote_server cp -f /root/scripts/glusterfs_uninstall.sh /root/; + ssh $remote_server /root/glusterfs_uninstall.sh $VERSION; + return 0; + fi + + j=0; + for i in $(cat /root/machines) + do + j=$(($j+1)); + (uninstall_glusterfs $i)& + done + +} + +function uninstall_my_glusterfs () +{ + old_PWD=$PWD; + + cd /root; + cp -f /root/scripts/glusterfs_uninstall.sh /root/; + /root/glusterfs_uninstall.sh $VERSION; + + cd $old_PWD; + return 0; +} + +function main () +{ + stat --printf=%i /root/machines 2>/dev/null 1>/dev/null; + if [ $? -ne 0 ]; then + echo "servers file is not present /root. Cannot execute further."; + + exit 1; + fi + + uninstall_glusterfs; + for i in $(1 $j) + do + wait %$j; + done + + uninstall_my_glusterfs; + + return 0; +} + +_init "$@" && main "$@" -- cgit