add possibility to run db-statement on connectdb
This commit is contained in:
parent
797e4da5d1
commit
255fbf0907
1 changed files with 17 additions and 4 deletions
19
functions.sh
19
functions.sh
|
@ -1179,18 +1179,31 @@ function connectdb () {
|
||||||
getdbcreds_cnf $2
|
getdbcreds_cnf $2
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "wrong argument"
|
echo "wrong argument" >&2
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF >&2
|
||||||
connect to ${DB_HOST}:${DB_PORT}/${DB_NAME}
|
connect to ${DB_HOST}:${DB_PORT}/${DB_NAME}
|
||||||
with user: ${DB_USER}
|
with user: ${DB_USER}
|
||||||
and passwd: ${DB_PWD}
|
and passwd: ${DB_PWD:+********}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]
|
||||||
|
then
|
||||||
|
case $1 in
|
||||||
|
-c)
|
||||||
|
shift
|
||||||
|
PGPASSWORD=$DB_PWD psql -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME -c "$@"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
PGPASSWORD=$DB_PWD psql -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME $@
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
PGPASSWORD=$DB_PWD psql -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME
|
PGPASSWORD=$DB_PWD psql -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue