Skip to content
Snippets Groups Projects
Commit 06edbbdd authored by micah's avatar micah :speech_balloon:
Browse files

r219@um: micah | 2005-12-27 10:32:24 -0500

 Defaults file is now set correctly for vservers
 dbhost is now added to the .my.cnf
parent 603c0154
No related branches found
No related tags found
No related merge requests found
...@@ -115,19 +115,21 @@ fi ...@@ -115,19 +115,21 @@ fi
# specify the password on the command line. # specify the password on the command line.
defaultsfile="" defaultsfile=""
if [ "$dbusername" != "" -a "$dbpassword" != "" ] if [ "$dbusername" != "" -a "$dbpassword" != "" ]
then then
if [ $usevserver ] if [ $usevserver ]
then then
home=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'` vhome=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'`
home="$vroot$home" home="$vroot$vhome"
debug "Home set to: $home"
else else
home=`getent passwd "root" | awk -F: '{print $6}'` home=`getent passwd "root" | awk -F: '{print $6}'`
debug "Home set to: $home"
fi fi
[ -d $home ] || fatal "Can't find root's home directory ($home)." [ -d $home ] || fatal "Can't find root's home directory ($home)."
mycnf="$home/.my.cnf" mycnf="$home/.my.cnf"
if [ -f $mycnf ] if [ -f $mycnf ]
then then
# rename temporarily # rename temporarily
...@@ -135,27 +137,37 @@ then ...@@ -135,27 +137,37 @@ then
debug "mv $mycnf $tmpcnf" debug "mv $mycnf $tmpcnf"
mv $mycnf $tmpcnf mv $mycnf $tmpcnf
fi fi
oldmask=`umask` oldmask=`umask`
umask 077 umask 077
cat > $mycnf <<EOF cat > $mycnf <<EOF
# auto generated backupninja mysql conf # auto generated backupninja mysql conf
[mysql] [mysql]
host=$dbhost
user=$dbusername user=$dbusername
password="$dbpassword" password="$dbpassword"
[mysqldump] [mysqldump]
host=$dbhost
user=$dbusername user=$dbusername
password="$dbpassword" password="$dbpassword"
[mysqlhotcopy] [mysqlhotcopy]
host=$dbhost
user=$dbusername user=$dbusername
password="$dbpassword" password="$dbpassword"
EOF EOF
umask $oldmask umask $oldmask
defaultsfile="--defaults-file=$mycnf" if [ $usevserver ]
then
defaultsfile="--defaults-file=$vhome/.my.cnf"
else
defaultsfile="--defaults-file=$mycnf"
fi
# if user is set, don't use $mycnf
elif [ "$userset" == "false" ]; then elif [ "$userset" == "false" ]; then
# if user is set, don't use $mycnf defaultsfile="--defaults-file=$configfile"
defaultsfile="--defaults-file=$configfile"
fi fi
####################################################################### #######################################################################
...@@ -223,11 +235,11 @@ then ...@@ -223,11 +235,11 @@ then
then then
if [ $usevserver ] if [ $usevserver ]
then then
databases=`echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database` databases=`echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database`
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
fatal "Something unexpected happened, the defaults file may have gone missing or is corrupt" fatal "Something unexpected happened, the defaults file may have gone missing or is corrupt"
fi fi
else else
databases=`echo 'show databases' | su $user -c "$MYSQL $defaultsfile" | grep -v Database` databases=`echo 'show databases' | su $user -c "$MYSQL $defaultsfile" | grep -v Database`
if [ $? -ne 0 ] if [ $? -ne 0 ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment