48 lines
1.6 KiB
Bash
48 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
# $1 - parameter like
|
|
# $2 - hostname
|
|
# $3 - filename
|
|
function modify_hostname()
|
|
{
|
|
if [ -e $3 ] ;then
|
|
tmpfile=$3_bak
|
|
sed "s/^\s*$1\s*=\s*.*-/$1 = $2-/" $3 > $tmpfile
|
|
mv -f $tmpfile $3
|
|
chmod 644 $3
|
|
fi
|
|
}
|
|
|
|
|
|
|
|
nowHostname=`hostname -s`
|
|
#echo hostname=$nowHostname
|
|
|
|
nowHostnamePrefix=`echo $nowHostname|awk -F'-' '{print $1}'`
|
|
#echo nowHostnamePrefix=$nowHostnamePrefix
|
|
|
|
configDir=/usr/local/omc/config
|
|
binconfDir=/usr/local/omc/bin/conf
|
|
|
|
modify_hostname master-host $nowHostnamePrefix $configDir/my.cnf_omc-0
|
|
modify_hostname master-host $nowHostnamePrefix $configDir/my.cnf_omc-0.ES
|
|
modify_hostname master-host $nowHostnamePrefix $configDir/my.cnf_omc-1
|
|
modify_hostname master-host $nowHostnamePrefix $configDir/my.cnf_omc-1.ES
|
|
|
|
modify_hostname master-host $nowHostnamePrefix $binconfDir/my.cnf_omc-0
|
|
modify_hostname master-host $nowHostnamePrefix $binconfDir/my.cnf_omc-0.ES
|
|
modify_hostname master-host $nowHostnamePrefix $binconfDir/my.cnf_omc-1
|
|
modify_hostname master-host $nowHostnamePrefix $binconfDir/my.cnf_omc-1.ES
|
|
|
|
|
|
modify_hostname omc_master $nowHostnamePrefix $configDir/server.conf
|
|
modify_hostname mysql_master $nowHostnamePrefix $configDir/server.conf
|
|
modify_hostname omc_slave $nowHostnamePrefix $configDir/server.conf
|
|
modify_hostname mysql_slave $nowHostnamePrefix $configDir/server.conf
|
|
|
|
modify_hostname omc_master $nowHostnamePrefix $binconfDir/server.conf
|
|
modify_hostname mysql_master $nowHostnamePrefix $binconfDir/server.conf
|
|
modify_hostname omc_slave $nowHostnamePrefix $binconfDir/server.conf
|
|
modify_hostname mysql_slave $nowHostnamePrefix $binconfDir/server.conf
|
|
|