vm/static/change_db_pass.sh

29 строки
886 B
Bash
Исходник Обычный вид История

2018-05-06 19:08:18 +03:00
#!/bin/bash
# shellcheck disable=2034,2059
true
# shellcheck source=lib.sh
NCDBPASS=1 . <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
unset NCDBPASS
2018-05-06 19:08:18 +03:00
# T&M Hansson IT AB © - 2020, https://www.hanssonit.se/
2018-05-06 19:08:18 +03:00
# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode
# Change PostgreSQL Password
cd /tmp
sudo -u www-data php "$NCPATH"/occ config:system:set dbpassword --value="$NEWPGPASS"
2018-05-06 19:08:18 +03:00
if [ "$(sudo -u postgres psql -c "ALTER USER $NCUSER WITH PASSWORD '$NEWPGPASS'";)" == "ALTER ROLE" ]
then
2019-05-14 18:19:24 +03:00
sleep 1
2018-05-06 19:08:18 +03:00
else
print_text_in_color "$IRed" "Changing PostgreSQL Nextcloud password failed."
2018-05-06 19:08:18 +03:00
sed -i "s| 'dbpassword' =>.*| 'dbpassword' => '$NCCONFIGDBPASS',|g" /var/www/nextcloud/config/config.php
print_text_in_color "$IRed" "Nothing is changed. Your old password is: $NCCONFIGDBPASS"
2018-05-06 19:08:18 +03:00
exit 1
fi