Permalink
Switch branches/tags
ver2.2.m4 vXAP9.0.2 vXAP-9.0.2 v2.2.0m2 v2.2.0M3_2491_59 v2.2.m5 v2.2.m4 v2.1.1GA Chef-10.12.0-Cloudify-2.2m4 2.7.1_m5_build6205_04_13_2014 2.7.1_m4_build6204_04_01_2014 2.7.1_m3_build6203_03_18_2014 2.7.1_m2_build6202_03_03_2014 2.7.1_m1_build6201_02_17_2014 2.7.1_ga_build6300_08_14_2014 2.7.1_ga_build6210_08_07_2014 2.7.0_rc2_build6000_11_27_2014 2.7.0_rc2_build5999_04_08_2014 2.7.0_rc2_build5999_03_26_2014 2.7.0_rc2_build5998_03_28_2014 2.7.0_rc2_build5997_03_25_2014 2.7.0_rc2_build5995_01_07_2014 2.7.0_rc_build5994_12_23_2013 2.7.0_m8_build5993_12_11_2013 2.7.0_m7_build5992_11_27_2013 2.7.0_m6_build5991_11_13_2013 2.7.0_m5_build5988_10_30_2013 2.7.0_m4_build5987_10_01_2013 2.7.0_m3_build5985_09_08_2013 2.7.0_m2_build5984_08_19_2013 2.7.0_m1_build5985_08_06_2013 2.7.0_m1_build5981_08_01_2013 2.7.0_ga_build5996_01_20_2014 2.6.2_ga_build5400_10_13_2013 2.6.1_ga_build5223_11_25_2013 2.6.1_ga_build5222_11_22_2013 2.6.1_ga_build5221_11_12_2013 2.6.1_ga_build5220_10_29_2013 2.6.1_ga_build5210_10_25_2013 2.6.1_ga_build5200_08_29_2013 2.6.0_rc_build4986_06_26_2013 2.6.0_rc_build4985_06_11_2013 2.6.0_m4_build4985_06_12_2013 2.6.0_m4_build4984_06_11_2013 2.6.0_m3_build4983_05_21_2013 2.6.0_m2_build4982_05_06_2013 2.6.0_m1_build4981_04_22_2013 2.6.0_ga_build5000_07_09_2013 2.5.2_ga_build4400_06_23_2013 2.5.1_ga_build4200_05_01_2013 2.5.0_rc_build3993_03_11_2013 2.5.0_m7_build3991_02_27_2013 2.5.0_m6_build3987_02_04_2013 2.5.0_m5_build3986_01_24_2013 2.5.0_m4_build3985_01_06_2013 2.5.0_m3_build3984_12_30_2012 2.5.0_ga_build4510_04_09_2013 2.5.0_ga_build4023_07_03_2013 2.5.0_ga_build4022_04_28_2013 2.5.0_ga_build4021_04_28_2013 2.5.0_ga_build4020_04_23_2013 2.5.0_ga_build4010_04_10_2013 2.5.0_ga_build4000_04_03_2013 2.3.1_ga_build3720_02_10_2013 2.3.1_ga_build3720_02_09_2013 2.3.1_ga_build3700_01_23_2013 2.3.0_rc_build3483_12_06_2012 2.3.0_m2_build3482_11_20_2012 2.3.0_m1_build3481_11_06_2012 2.3.0_ga_build3510_01_14_2013 2.3.0_ga_build3500_12_16_2012 2.3.0_ga_build3500_12_13_2012 2.2.0_rc_build2496_10_03_2012 2.2.0_m5_build2495_09_21_2012 2.2.0_m4_build2494_09_09_2012 2.2.0_ga_build2500_10_19_2012
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
95 lines (75 sloc) 3.29 KB
#!/bin/bash -x
# args:
# $1 A command separated list of my.cnf section names
# $2 A command separated list of my.cnf variable names
# $3 A command separated list of my.cnf values for the above variable names
#
sectionNames=$1
variableNames=$2
newValues=$3
# args:
# $1 the error code of the last command (should be explicitly passed)
# $2 the message to print in case of an error
#
# an error message is printed and the script exists with the provided error code
function error_exit {
echo "$2 : error code: $1"
exit ${1}
}
function killMySqlProcess {
sudo service mysql stop
ps -ef | grep -iE "mysqld" | grep -ivE "gigaspaces|GSC|GSA|grep"
if [ $? -eq 0 ] ; then
ps -ef | grep -iE "mysqld" | grep -ivE "gigaspaces|GSC|GSA|grep" | awk '{print $2}' | xargs sudo kill -9
fi
}
export PATH=$PATH:/usr/sbin:/sbin:/usr/bin || error_exit $? "Failed on: export PATH=$PATH:/usr/sbin:/sbin"
if sudo grep -q -E '[^!]requiretty' /etc/sudoers; then
echo "Defaults:`whoami` !requiretty" | sudo tee /etc/sudoers.d/`whoami` >/dev/null
sudo chmod 0440 /etc/sudoers.d/`whoami`
fi
# The existence of the usingAptGet file in the ext folder will later serve as a flag that "we" are on Ubuntu or Debian or Mint
echo "Using apt-get. Updating apt-get on one of the following : Ubuntu, Debian, Mint" > usingAptGet
sudo apt-get -y -q update || error_exit $? "Failed on: sudo apt-get -y update"
echo "#1 Killing old mysql process if exists..."
killMySqlProcess
# Removing previous mysql installation if exists
echo "Purging previous mysql installation if exists..."
sudo apt-get -y -q purge mysql-client* mysql-server* mysql-common*
# The following two statements are used since in some cases, there are leftovers after uninstall
echo "Removing old stuff if exists..."
sudo rm -rf /etc/mysql || error_exit $? "Failed on: sudo rm -rf /etc/mysql"
echo "Using apt-get. Updating apt-get on one of the following : Ubuntu, Debian, Mint"
sudo DEBIAN_FRONTEND='noninteractive' apt-get -o Dpkg::Options::='--force-confnew' -q -y install mysql-server-core mysql-server mysql-client mysql-common || error_exit $? "Failed on: sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -q mysql-server ... "
echo "Killing old mysql process if exists b4 ending the installation..."
killMySqlProcess
sectionNamesLen=`expr length "$sectionNames"`
if [ $sectionNamesLen -gt 0 ] ; then
myCnfPath=`sudo find / -name "my.cnf"`
if [ -f "${myCnfPath}" ] ; then
sectionNames=$1
variableNames=$2
newValues=$3
IFS=, read -a sectionNamesArr <<< "$sectionNames"
IFS=, read -a variableNamesArr <<< "$variableNames"
IFS=, read -a newValuesArr <<< "$newValues"
echo "IFS is ${IFS}"
echo "${sectionNamesArr[@]}"
echo "${variableNamesArr[@]}"
echo "${newValuesArr[@]}"
variableCounter=${#variableNamesArr[@]}
for (( i=0; i<${variableCounter}; i++ ));
do
currSection="\[${sectionNamesArr[$i]}\]"
currVariable="${variableNamesArr[$i]}"
currNewValue="${newValuesArr[$i]}"
currNewLine="${currVariable}=${currNewValue}"
echo "Commenting $currVariable in $myCnfPath ... "
sudo sed -i -e "s/^$currVariable/#$currVariable/g" $myCnfPath
jointStr="${currSection}\n${currNewLine}"
echo "Setting ${currNewLine} in the ${currSection} section of $myCnfPath ... "
sudo sed -i -e "s/$currSection/$jointStr/g" $myCnfPath
done
fi
fi
echo "End of $0"