2018-05-06 19:08:18 +03:00
|
|
|
#!/bin/bash
|
|
|
|
# shellcheck disable=2034,2059
|
|
|
|
true
|
|
|
|
# shellcheck source=lib.sh
|
2020-05-31 16:02:43 +03:00
|
|
|
NCDBPASS=1 . <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
|
|
|
|
unset NCDBPASS
|
2018-05-06 19:08:18 +03:00
|
|
|
|
2020-01-11 14:42:22 +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
|
2019-05-14 18:15:38 +03:00
|
|
|
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
|
2019-08-13 15:02:15 +03:00
|
|
|
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
|
2019-08-13 15:02:15 +03:00
|
|
|
print_text_in_color "$IRed" "Nothing is changed. Your old password is: $NCCONFIGDBPASS"
|
2018-05-06 19:08:18 +03:00
|
|
|
exit 1
|
|
|
|
fi
|