From 76f64d863d4d1fbcc512fa849de00a74ba1c3d81 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 8 Mar 2007 11:26:25 +1300 Subject: [PATCH] Improved layout and comments. --- dba/create-database.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dba/create-database.sh b/dba/create-database.sh index 96f7da24..3bd9fe3d 100755 --- a/dba/create-database.sh +++ b/dba/create-database.sh @@ -34,13 +34,20 @@ if [ "${ADMINPW}" = "" ] ; then # Generate a random administrative password. If pwgen is available we'll use that, # otherwise try and hack something up using a few standard utilities ADMINPW="`pwgen -Bcny 2>/dev/null | tr \"\\\'\" '^='`" - if [ "$ADMINPW" = "" ] ; then - ADMINPW="`dd if=/dev/urandom bs=512 count=1 2>/dev/null | tr -c -d "[:alnum:]" | cut -c2-9`" - fi - if [ "$ADMINPW" = "" ] ; then - ADMINPW="please change this password" - fi fi + +if [ "$ADMINPW" = "" ] ; then + # OK. They didn't supply one, and pwgen didn't work, so we hack something + # together from /dev/random ... + ADMINPW="`dd if=/dev/urandom bs=512 count=1 2>/dev/null | tr -c -d "[:alnum:]" | cut -c2-9`" +fi + +if [ "$ADMINPW" = "" ] ; then + # Right. We're getting desperate now. We'll have to use a default password + # and hope that they change it to something more sensible. + ADMINPW="please change this password" +fi + psql -q -c "UPDATE usr SET password = '**${ADMINPW}' WHERE user_no = 1;" "${DBNAME}" echo "The password for the 'admin' user has been set to '${ADMINPW}'"