mirror of
https://0xacab.org/liberate/backupninja.git
synced 2024-11-12 22:02:33 +01:00
Cherry-picked "fixes for mysql handler for mysqld inside a vserver"
This commit (64edfccf76
) was wrongly committed to
the debian branch.
Conflicts:
handlers/mysql.in
This commit is contained in:
parent
d4c5f73ad7
commit
d65fa0c058
@ -88,29 +88,35 @@ defaultsfile=""
|
|||||||
|
|
||||||
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
|
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
|
||||||
then
|
then
|
||||||
if [ $usevserver = yes ]
|
if [ $usevserver = yes ]
|
||||||
then
|
then
|
||||||
vhome=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'`
|
home=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'`
|
||||||
home="$vroot$vhome"
|
else
|
||||||
else
|
home=`getent passwd "root" | @AWK@ -F: '{print $6}'`
|
||||||
home=`getent passwd "root" | @AWK@ -F: '{print $6}'`
|
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 [ $usevserver = yes ]
|
||||||
|
then
|
||||||
|
workcnf="$vroot$mycnf"
|
||||||
|
else
|
||||||
|
workcnf="$mycnf"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f $mycnf ]
|
if [ -f $workcnf ]
|
||||||
then
|
then
|
||||||
# rename temporarily
|
# rename temporarily
|
||||||
tmpcnf="$home/my.cnf.disable"
|
tmpcnf="$workcnf.disable"
|
||||||
debug "mv $mycnf $tmpcnf"
|
debug "mv $workcnf $tmpcnf"
|
||||||
mv $mycnf $tmpcnf
|
mv $workcnf $tmpcnf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
oldmask=`umask`
|
oldmask=`umask`
|
||||||
umask 077
|
umask 077
|
||||||
cat > $mycnf <<EOF
|
cat > $workcnf <<EOF
|
||||||
# auto generated backupninja mysql conf
|
# auto generated backupninja mysql conf
|
||||||
[mysql]
|
[mysql]
|
||||||
host=$dbhost
|
host=$dbhost
|
||||||
@ -126,14 +132,14 @@ password="$dbpassword"
|
|||||||
host=$dbhost
|
host=$dbhost
|
||||||
user=$dbusername
|
user=$dbusername
|
||||||
password="$dbpassword"
|
password="$dbpassword"
|
||||||
|
|
||||||
|
[mysqladmin]
|
||||||
|
host=$dbhost
|
||||||
|
user=$dbusername
|
||||||
|
password="$dbpassword"
|
||||||
EOF
|
EOF
|
||||||
umask $oldmask
|
umask $oldmask
|
||||||
if [ $usevserver = yes ]
|
defaultsfile="--defaults-extra-file=$mycnf"
|
||||||
then
|
|
||||||
defaultsfile="--defaults-extra-file=$vhome/.my.cnf"
|
|
||||||
else
|
|
||||||
defaultsfile="--defaults-extra-file=$mycnf"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if a user is not set, use $configfile, otherwise use $mycnf
|
# if a user is not set, use $configfile, otherwise use $mycnf
|
||||||
@ -141,27 +147,28 @@ if [ "$user" == "" ]; then
|
|||||||
user=root;
|
user=root;
|
||||||
defaultsfile="--defaults-extra-file=$configfile"
|
defaultsfile="--defaults-extra-file=$configfile"
|
||||||
else
|
else
|
||||||
userset=true;
|
userset=true;
|
||||||
if [ $usevserver = yes ]
|
if [ $usevserver = yes ]
|
||||||
then
|
then
|
||||||
vuserhome=`$VSERVER $vsname exec getent passwd "$user" | @AWK@ -F: '{print $6}'`
|
userhome=`$VSERVER $vsname exec getent passwd "$user" | @AWK@ -F: '{print $6}'`
|
||||||
if [ $? -eq 2 ]
|
if [ $? -eq 2 ]
|
||||||
then
|
then
|
||||||
fatal "User $user not found in /etc/passwd"
|
fatal "User $user not found in /etc/passwd"
|
||||||
fi
|
fi
|
||||||
userhome="$vroot$vuserhome"
|
debug "User home set to: $vroot$userhome"
|
||||||
else
|
[ -f $vroot$userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
|
||||||
userhome=`getent passwd "$user" | @AWK@ -F: '{print $6}'`
|
else
|
||||||
if [ $? -eq 2 ]
|
userhome=`getent passwd "$user" | @AWK@ -F: '{print $6}'`
|
||||||
then
|
if [ $? -eq 2 ]
|
||||||
fatal "User $user not found in /etc/passwd"
|
then
|
||||||
fi
|
fatal "User $user not found in /etc/passwd"
|
||||||
fi
|
fi
|
||||||
|
debug "User home set to: $userhome"
|
||||||
debug "User home set to: $userhome"
|
[ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
|
||||||
[ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
|
fi
|
||||||
defaultsfile="--defaults-extra-file=$userhome/.my.cnf"
|
|
||||||
debug "using $defaultsfile"
|
defaultsfile="--defaults-extra-file=$userhome/.my.cnf"
|
||||||
|
debug "using $defaultsfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
@ -308,14 +315,14 @@ fi
|
|||||||
# clean up tmp config file
|
# clean up tmp config file
|
||||||
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
|
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
|
||||||
then
|
then
|
||||||
## clean up tmp config file
|
## clean up tmp config file
|
||||||
debug "rm $mycnf"
|
debug "rm $workcnf"
|
||||||
rm $mycnf
|
rm $workcnf
|
||||||
if [ -f "$tmpcnf" ]
|
if [ -f "$tmpcnf" ]
|
||||||
then
|
then
|
||||||
debug "mv $tmpcnf $mycnf"
|
debug "mv $tmpcnf $workcnf"
|
||||||
mv $tmpcnf $mycnf
|
mv $tmpcnf $workcnf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user