mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 02:28:05 -07:00
Mysql password change
This commit is contained in:
parent
527e4a9a62
commit
b8f5a1161f
1 changed files with 68 additions and 0 deletions
68
bin/v-change-database-host-password
Executable file
68
bin/v-change-database-host-password
Executable file
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
# info: change database server password
|
||||
# options: TYPE HOST USER PASSWORD
|
||||
#
|
||||
# The function changes database server password.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
type=$1
|
||||
host=$2
|
||||
dbuser=$3
|
||||
password=$4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/db.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
# Hiding password
|
||||
A4='******'
|
||||
EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
args_usage='TYPE HOST DBUSER DBPASS'
|
||||
check_args '4' "$#" "$args_usage"
|
||||
validate_format 'host' 'dbuser'
|
||||
is_object_valid "../../conf/$type" 'HOST' "$host"
|
||||
dbpass="$password"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Define email
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f2 -d \')
|
||||
subj="v-change-database-host-password $*"
|
||||
|
||||
case $type in
|
||||
mysql) mysql_connect $host;
|
||||
query="USE mysql; UPDATE user SET"
|
||||
query="$query password=PASSWORD('$dbpass')"
|
||||
query="$query WHERE User='$dbuser';"
|
||||
query="$query FLUSH PRIVILEGES;"
|
||||
mysql_query "$query" ;;
|
||||
pgsql) echo "TBD" >/dev/null;;
|
||||
esac
|
||||
|
||||
update_object_value "../../conf/$type" 'HOST' "$host" '$USER' "$dbuser"
|
||||
update_object_value "../../conf/$type" 'HOST' "$host" '$PASSWORD' "$dbpass"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue