Support gz for mysqls
This commit is contained in:
parent
5cdb134ebc
commit
4de0812ce7
@ -1,15 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
function mysqlo () {
|
function mysqlo () {
|
||||||
if [[ -z "$1" ]]; then
|
if [ -z "$1" ]; then
|
||||||
__func_head "SERVER_NAME"
|
__func_head "SERVER_NAME"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
PASS=$(grepmysql $1 true)
|
PASS=$(grepmysql $1 true)
|
||||||
if [[ -z "$PASS" ]]; then
|
if [ -z "$PASS" ]; then
|
||||||
echo "Server not found in config: $1"
|
echo "Server not found in config: $1"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PS_SQL=$(grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $4 }')
|
PS_SQL=$(grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $4 }')
|
||||||
@ -26,20 +25,29 @@ function mysqlo () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mysqls () {
|
function mysqls () {
|
||||||
if [[ -z "$1" ]]; then
|
if [ -z "$1" ]; then
|
||||||
__func_head "SERVER_NAME DATABASE_NAME SQL_FILE"
|
__func_head "[z] SERVER_NAME DATABASE_NAME SQL_FILE"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
|
GZIP=false
|
||||||
|
if [ "$1" == "z" ]; then
|
||||||
|
GZIP=true
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
USER=$(grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $5 }')
|
USER=$(grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $5 }')
|
||||||
PASS=$(grepmysql $1 true)
|
PASS=$(grepmysql $1 true)
|
||||||
|
|
||||||
if [[ -z "$PASS" ]]; then
|
if [ -z "$PASS" ]; then
|
||||||
echo "Server not found in config: $1"
|
echo "Server not found in config: $1"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $GZIP; then
|
||||||
|
gunzip -c $3 | mysql -u $USER --password=$PASS -D $2
|
||||||
|
else
|
||||||
mysql -u $USER --password=$PASS -D $2 < $3
|
mysql -u $USER --password=$PASS -D $2 < $3
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user