change postgres password during first start

hregis

Well-Known Member
Feb 11, 2011
49
0
46
France
www.inodbox.com
Hi,

have you a script or procedure for change/defined the password of "postgres" (admin postgresql) during the first start of appliance ?

Thanks
Régis
 
hi,

i found this solution, had this in Makefile:

Code:
dab task postgres --version=8.4
install -m 0755 pgsql_setup ${BASEDIR}/tmp/pgsql_setup
install -m 0755 pgsql_passwd ${BASEDIR}/tmp/pgsql_pwd
dab task postgres --start
dab exec /tmp/pgsql_setup
rm -f ${BASEDIR}/tmp/pgsql_setup

the content of "pgsql_setup"

Code:
#!/bin/sh

# change postgres password
su - postgres -c "/tmp/pgsql_pwd"
rm -f /tmp/pgsql_pwd

the content of "pgsql_pwd"

Code:
#!/bin/bash

psql -c "ALTER USER postgres WITH PASSWORD 'password'" -d template1

same password for all templates, but my application create a new user/pwd with the new database.

its possible to use this function to create aleatory password with no specific caracters:

Code:
# Generate a random password
#  $1 = number of characters; defaults to 32
#  $2 = include special characters; 1 = yes, 0 = no; defaults to 1
function randpass() {
  [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
    cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-32}
    echo
}

# create random password
PASSDBADMIN=`randpass 12 0`
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!