mirror of
https://github.com/myvesta/vesta
synced 2025-07-05 20:41:53 -07:00
v-change-database-password-for-all-wordpress: Using existing password for $db_user
This commit is contained in:
parent
294c8ba516
commit
97e5fc0677
2 changed files with 25 additions and 2 deletions
|
@ -19,6 +19,8 @@ source $VESTA/func/main.sh
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
touch /root/remember-db-user-pass.txt
|
||||||
|
|
||||||
for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
|
for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
|
||||||
if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
|
if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
|
||||||
continue;
|
continue;
|
||||||
|
@ -33,6 +35,9 @@ for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# cat /root/remember-db-user-pass.txt
|
||||||
|
rm /root/remember-db-user-pass.txt
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -69,10 +69,28 @@ if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
|
||||||
chown $user:$user $wp_config_path
|
chown $user:$user $wp_config_path
|
||||||
fi
|
fi
|
||||||
db_name=$(grep "DB_NAME" $wp_config_path | grep -oP "define\s*\(\s*'DB_NAME'\s*,\s*'\K[^']+")
|
db_name=$(grep "DB_NAME" $wp_config_path | grep -oP "define\s*\(\s*'DB_NAME'\s*,\s*'\K[^']+")
|
||||||
new_password=$(generate_password)
|
db_user=$(grep "DB_USER" $wp_config_path | grep -oP "define\s*\(\s*'DB_USER'\s*,\s*'\K[^']+")
|
||||||
|
new_password=''
|
||||||
|
found_existing_password=0
|
||||||
|
if [ -f "/root/remember-db-user-pass.txt" ]; then
|
||||||
|
db_user_pass=$(grep "$db_user:" /root/remember-db-user-pass.txt)
|
||||||
|
if [ -n "$db_user_pass" ]; then
|
||||||
|
new_password=$(echo "$db_user_pass" | cut -d':' -f2)
|
||||||
|
echo "= Using existing password for $db_user"
|
||||||
|
found_existing_password=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$new_password" ]; then
|
||||||
|
new_password=$(generate_password)
|
||||||
|
fi
|
||||||
|
|
||||||
echo "DB name: $db_name"
|
echo "DB name: $db_name"
|
||||||
|
echo "DB user: $db_user"
|
||||||
echo "New DB password: $new_password"
|
echo "New DB password: $new_password"
|
||||||
# echo "executing: /usr/local/vesta/bin/v-change-database-password \"$user\" \"$db_name\" \"$new_password\""
|
if [ $found_existing_password -eq 0 ] && [ -f "/root/remember-db-user-pass.txt" ]; then
|
||||||
|
echo "$db_user:$new_password" >> /root/remember-db-user-pass.txt
|
||||||
|
fi
|
||||||
/usr/local/vesta/bin/v-change-database-password "$user" "$db_name" "$new_password"
|
/usr/local/vesta/bin/v-change-database-password "$user" "$db_name" "$new_password"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "*************** ERROR: Failed to change database password ***************"
|
echo "*************** ERROR: Failed to change database password ***************"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue