summaryrefslogtreecommitdiffstats
path: root/helper_scrips
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendrabhat@gluster.com>2011-09-13 17:09:34 +0530
committerRaghavendra Bhat <raghavendrabhat@gluster.com>2011-09-13 17:09:34 +0530
commit9f10e75b5cd5ef1dc2a0d166d6de6f8c0ef662a0 (patch)
tree16e7e1b9ebe87d2e4e0c3a37bfa477897ecadc75 /helper_scrips
parent2bd023293d115a68f5f81376d9ba1378f4ee7808 (diff)
some helper scripts for glusterfs installation and setup
Diffstat (limited to 'helper_scrips')
-rw-r--r--helper_scrips/INFO15
-rwxr-xr-xhelper_scrips/clean_glusterd.sh50
-rwxr-xr-xhelper_scrips/clean_logs.sh54
-rwxr-xr-xhelper_scrips/clean_rpm_logs.sh54
-rwxr-xr-xhelper_scrips/download_and_install.sh154
-rwxr-xr-xhelper_scrips/probe.sh43
-rwxr-xr-xhelper_scrips/rpm_qa_download_install.sh113
-rwxr-xr-xhelper_scrips/start_glusterd.sh48
-rwxr-xr-xhelper_scrips/start_stop.sh31
9 files changed, 562 insertions, 0 deletions
diff --git a/helper_scrips/INFO b/helper_scrips/INFO
new file mode 100644
index 0000000..1f09a1b
--- /dev/null
+++ b/helper_scrips/INFO
@@ -0,0 +1,15 @@
+helper_scripts/download_and_install.sh ----> it downloads the specified version of glusterfs (both main release as well as qa release), builds it and installs it. The prefix for the installation can be given as the argument, otherwise it installs in the default directory. If the tarball or the untarred directory of the specified glusterfs version is already present in the present directory, it uses them to install.
+
+=============================================================================================================================================
+
+helper_scrips/rpm_qa_download_install.sh -----> downloads the rpms for the specified qa release and installs them. An option whether to upgrade to the specified version or install from scratch to the specified version can be provided as the command line argument.
+
+=============================================================================================================================================
+
+herper_scripts/clean_glusterd.sh
+helper_scripts/clean_logs.sh
+helper_scripts/start_glusterd.sh
+helper_scripts/probe.sh
+
+The above scripts are usable with the passwordless ssh connection setup between the glusterfs servers, which helps in cleaning the logs, probing, cleaning glusterd, starting glusterd etc.
+
diff --git a/helper_scrips/clean_glusterd.sh b/helper_scrips/clean_glusterd.sh
new file mode 100755
index 0000000..2ccbeb2
--- /dev/null
+++ b/helper_scrips/clean_glusterd.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+function _init ()
+{
+ set -u;
+}
+
+function clean_glusterd ()
+{
+ local remote_server=;
+
+ if [ $# -eq 1 ]; then
+ remote_server=$1;
+ fi
+
+ if [ $remote_server ]; then
+ ssh $remote_server rm -rf /etc/glusterd;
+ return 0;
+ fi
+
+ for i in $(cat /root/servers)
+ do
+ clean_glusterd $i;
+ done
+
+}
+
+function clean_my_glusterd ()
+{
+ rm -rf /etc/glusterd;
+ return 0;
+}
+
+function main ()
+{
+ stat --printf=%i /root/servers 2>/dev/null 1>/dev/null;
+ if [ $? -ne 0 ]; then
+ echo "servers file is not present /root. Cannot execute further."
+ exit 1
+ fi
+
+ clean_my_glusterd;
+ clean_glusterd;
+
+ return 0;
+}
+
+_init && main "$@"
+
+
diff --git a/helper_scrips/clean_logs.sh b/helper_scrips/clean_logs.sh
new file mode 100755
index 0000000..7d30bd9
--- /dev/null
+++ b/helper_scrips/clean_logs.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+function _init ()
+{
+ set -u;
+}
+
+function clean_logs ()
+{
+ local remote_server=;
+
+ if [ $# -eq 1 ]; then
+ remote_server=$1;
+ fi
+
+ if [ $remote_server ]; then
+ ssh $remote_server rm -rf /usr/local/var/log/glusterfs/*.log;
+ ssh $remote_server rm -rf /usr/local/var/log/glusterfs/bricks/*;
+ return 0;
+ fi
+
+ for i in $(cat /root/servers)
+ do
+ clean_logs $i;
+ done
+
+}
+
+function clean_my_logs ()
+{
+ rm -rf /usr/local/var/log/glusterfs/*.log;
+ rm -rf /usr/local/var/log/glusterfs/bricks/*;
+
+ return 0;
+}
+
+function main ()
+{
+ stat --printf=%i /root/servers 2>/dev/null 1>/dev/null;
+ if [ $? -ne 0 ]; then
+ echo "servers file is not present /root. Cannot execute further.";
+
+ exit 1;
+ fi
+
+ clean_my_logs;
+ clean_logs;
+
+ return 0;
+}
+
+_init && main "$@"
+
+
diff --git a/helper_scrips/clean_rpm_logs.sh b/helper_scrips/clean_rpm_logs.sh
new file mode 100755
index 0000000..c5c5a5d
--- /dev/null
+++ b/helper_scrips/clean_rpm_logs.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+function _init ()
+{
+ set -u;
+}
+
+function clean_logs ()
+{
+ local remote_server=;
+
+ if [ $# -eq 1 ]; then
+ remote_server=$1;
+ fi
+
+ if [ $remote_server ]; then
+ ssh $remote_server rm -rf /var/log/glusterfs/*.log;
+ ssh $remote_server rm -rf /var/log/glusterfs/bricks/*;
+ return 0;
+ fi
+
+ for i in $(cat /root/servers)
+ do
+ clean_logs $i;
+ done
+
+}
+
+function clean_my_logs ()
+{
+ rm -rf /var/log/glusterfs/*.log;
+ rm -rf /var/log/glusterfs/bricks/*;
+
+ return 0;
+}
+
+function main ()
+{
+ stat --printf=%i /root/servers 2>/dev/null 1>/dev/null;
+ if [ $? -ne 0 ]; then
+ echo "servers file is not present /root. Cannot execute further.";
+
+ exit 1;
+ fi
+
+ clean_my_logs;
+ clean_logs;
+
+ return 0;
+}
+
+_init && main "$@"
+
+
diff --git a/helper_scrips/download_and_install.sh b/helper_scrips/download_and_install.sh
new file mode 100755
index 0000000..505d591
--- /dev/null
+++ b/helper_scrips/download_and_install.sh
@@ -0,0 +1,154 @@
+#!/bin/bash
+
+#set -x;
+
+function _init ()
+{
+ # echo $0;
+ # echo $#;
+ # echo $1;
+ set -u;
+ if [ $# -lt 1 ]; then
+ echo "usage: download_and_install <glusterfs-version> [install prefix]";
+ 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
+
+ check_if_qa_release $version;
+ op_ret=$?;
+
+ if [ $op_ret -eq 0 ]; then
+ download_address="http://bits.gluster.com/pub/gluster/glusterfs/src/"$version".tar.gz";
+ else
+ echo $version | grep "3.2" 2>/dev/null 1>/dev/null;
+ if [ $? -eq 0 ]; then
+ version_number=$(echo $version | cut -f 2 -d "-");
+ download_address="http://ftp.gluster.com/pub/gluster/glusterfs/3.2/$version_number/"$version".tar.gz";
+ else
+ grep "3.1" $version 2>/dev/null 1>/dev/null;
+ echo "haha yes"
+ if [ $? -eq 0 ]; then
+ version_number=$(echo $version | cut -f 2 -d "-");
+ download_address="http://ftp.gluster.com/pub/gluster/glusterfs/3.1/$version_number/"$version".tar.gz";
+ else
+ grep "3.0" $version 2>/dev/null 1>/dev/null;
+ if [ $? -eq 0 ]; then
+ version_number=$(cut -f 2 -d "-" $version);
+ download_address="http://ftp.gluster.com/pub/gluster/glusterfs/3.2/$version_number/"$version".tar.gz";
+ fi
+ fi
+ fi
+ fi
+
+echo "KK: $download_address"
+# ls -l "$version".tar.gz 2>/dev/null 1>/dev/null
+# if [ $? -ne 0 ]; then
+}
+
+function check_if_qa_release ()
+{
+ glusterfs_version=$1;
+
+ echo $glusterfs_version | grep "qa" 2>/dev/null 1>/dev/null;
+ ret=$?;
+
+ return $ret;
+}
+
+function download_tarball ()
+{
+ address=$1;
+
+ wget $address;
+}
+
+function untar_tarball ()
+{
+ gluster_version=$1;
+
+ tar xzf $PWD/"$gluster_version".tar.gz;
+}
+
+function configure ()
+{
+ if [ $# -eq 1 ]; then
+ prefix_dir=$1;
+ else
+ prefix_dir="default";
+ fi
+
+ old_pwd=$PWD;
+
+ cd $PWD/$version;
+ check_if_qa_release $version;
+
+ if [ $? -eq 0 ]; then
+ export CFLAGS="-g -O0 -DDEBUG";
+ else
+ export CFLAGS="-g -O0";
+ fi
+
+ if [ ! -d build ]; then
+ mkdir build;
+ fi
+
+ cd build;
+
+ echo "KKKKK: $prefix_dir"
+ sleep 1;
+ if [ $prefix_dir != "default" ]; then
+ ../configure --prefix=$prefix_dir --quiet;
+ else
+ ../configure --quiet;
+ fi
+
+ cd $old_pwd;
+}
+
+function build_install ()
+{
+ cd $PWD/$version;
+
+ cd build;
+ make -j 32 >/dev/null && make -j 32 install >/dev/null;
+
+ cd /root;
+}
+
+main ()
+{
+ if [ ! -e $version.tar.gz ]; then
+ echo $download_address;
+ download_tarball $download_address;
+ else
+ echo "tarball already present in the directory";
+ fi
+
+ if [ ! -d $version ]; then
+ untar_tarball $version;
+ else
+ echo "Source directory already present in the directory";
+ fi
+
+ install_prefix="default";
+ if [ $# -eq 2 ]; then
+ install_prefix=$2;
+ fi
+
+ if [ $install_prefix != "default" ]; then
+ configure $install_prefix;
+ else
+ configure;
+ fi
+
+ build_install;
+}
+
+_init "$@" && main "$@"
diff --git a/helper_scrips/probe.sh b/helper_scrips/probe.sh
new file mode 100755
index 0000000..b804c7f
--- /dev/null
+++ b/helper_scrips/probe.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+function _init ()
+{
+ set -u;
+}
+
+function clean_logs ()
+{
+ local remote_server=;
+
+ if [ $# -eq 1 ]; then
+ remote_server=$1;
+ fi
+
+ if [ $remote_server ]; then
+ gluster peer probe $remote_server;
+ return 0;
+ fi
+
+ for i in $(cat /root/servers)
+ do
+ clean_logs $i;
+ done
+
+}
+
+function main ()
+{
+ stat --printf=%i /root/servers 2>/dev/null 1>/dev/null;
+ if [ $? -ne 0 ]; then
+ echo "servers file is not present /root. Cannot execute further."
+ exit 1
+ fi
+
+ clean_logs;
+
+ return 0;
+}
+
+_init && main "$@"
+
+
diff --git a/helper_scrips/rpm_qa_download_install.sh b/helper_scrips/rpm_qa_download_install.sh
new file mode 100755
index 0000000..32fc2e1
--- /dev/null
+++ b/helper_scrips/rpm_qa_download_install.sh
@@ -0,0 +1,113 @@
+#!/bin/bash
+
+#set -x;
+
+function _init ()
+{
+ # echo $0;
+ # echo $#;
+ # echo $1;
+ set -u;
+ if [ $# -lt 1 ]; then
+ echo "usage: download_and_install <glusterfs-version> [upgrade decision]";
+ 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
+
+ version_number=$(echo $version | cut -f 2 -d "-");
+ check_if_qa_release $version;
+ op_ret=$?;
+
+ if [ $op_ret -eq 0 ]; then
+ download_address="http://bits.gluster.com/pub/gluster/glusterfs/";
+ fi
+
+ echo "KK: $download_address"
+# ls -l "$version".tar.gz 2>/dev/null 1>/dev/null
+# if [ $? -ne 0 ]; then
+}
+
+function check_if_qa_release ()
+{
+ glusterfs_version=$1;
+
+ echo $glusterfs_version | grep "qa" 2>/dev/null 1>/dev/null;
+ ret=$?;
+
+ return $ret;
+}
+
+function download_rpms ()
+{
+ address=$1;
+
+ mkdir $PWD/rpms/$version_number;
+
+ cd $PWD/rpms/$version_number;
+
+ echo version_number | grep "3.2";
+ is_32=$?;
+
+ wget $address/$version_number/x86_64/glusterfs-core-$version_number-1.x86_64.rpm;
+ wget $address/$version_number/x86_64/glusterfs-debuginfo-$version_number-1.x86_64.rpm;
+ wget $address/$version_number/x86_64/glusterfs-fuse-$version_number-1.x86_64.rpm;
+ if [ $is_32 -eq 0 ]; then
+ wget $address/$version_number/x86_64/glusterfs-geo-replication-$version_number-1.x86_64.rpm;
+ fi
+}
+
+
+function install_or_upgrade ()
+{
+ cd /root/rpms/$version_number;
+ if [ $upgrade != "yes" ]; then
+ for i in $(ls)
+ do
+ rpm -ivh $i;
+ done
+ else
+ for i in $(ls)
+ do
+ rpm -Uvh $i;
+ done
+ fi
+
+ ret=$?;
+ cd /root;
+
+ return $ret;
+}
+
+main ()
+{
+ echo $download_address;
+ download_rpms $download_address;
+
+ upgrade="no";
+ if [ $# -eq 2 ]; then
+ upgrade=$2;
+ fi
+
+ if [ $upgrade != "yes" ] && [ $upgrade != "no" ]; then
+ echo "Invalid upgrade decision $upgrade";
+ rm -rf /root/rpms/$version_number;
+ exit 1;
+ fi
+
+ install_or_upgrade $upgrade;
+ ret=$?;
+ if [ $ret -ne 0 ]; then
+ rm -rf /root/rpms/$version_number;
+ fi
+}
+
+_init "$@" && main "$@"
+
+ \ No newline at end of file
diff --git a/helper_scrips/start_glusterd.sh b/helper_scrips/start_glusterd.sh
new file mode 100755
index 0000000..5bc0901
--- /dev/null
+++ b/helper_scrips/start_glusterd.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+function _init ()
+{
+ set -u;
+}
+
+function start_glusterd ()
+{
+ local remote_server=;
+
+ if [ $# -eq 1 ]; then
+ remote_server=$1;
+ fi
+
+ if [ $remote_server ]; then
+ ssh $remote_server glusterd;
+ return 0;
+ fi
+
+ for i in $(cat /root/servers)
+ do
+ start_glusterd $i;
+ done
+
+}
+
+function start_my_glusterd ()
+{
+ glusterd;
+ return $?;
+}
+
+function main ()
+{
+ stat --printf=%i /root/servers 2>/dev/null 1>/dev/null;
+ if [ $? -ne 0 ]; then
+ echo "servers file is not present /root. Cannot execute further."
+ exit 1
+ fi
+
+ start_glusterd;
+ start_my_glusterd;
+
+ return 0;
+}
+
+_init && main "$@"
diff --git a/helper_scrips/start_stop.sh b/helper_scrips/start_stop.sh
new file mode 100755
index 0000000..83ad1bf
--- /dev/null
+++ b/helper_scrips/start_stop.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+
+function _init ()
+{
+ set -u;
+ volume_name=$1;
+}
+
+function start_and_stop ()
+{
+ while true;
+ do
+ gluster --mode=script volume stop $volume_name;
+ sleep 1;
+ gluster volume start $volume_name;
+ sleep 1;
+ done
+
+ return 0;
+}
+
+function main ()
+{
+
+ start_and_stop;
+
+ return 0;
+}
+
+_init "$@" && main "$@" \ No newline at end of file