#!/usr/bin/env perl #--------------------------------------------------------------------- #-- createuser creates a new PostgreSQL user. # #-- Usage: # createuser [options] [username] # #Options: # -d, --createdb User can create new databases # -D, --no-createdb User cannot create databases # -a, --adduser User can add new users # -A, --no-adduser User cannot add new users # -i, --sysid=SYSID Select sysid for new user # -P, --pwprompt Assign a password to new user # -E, --encrypted Encrypt stored password # -N, --unencrypted Do no encrypt stored password # -h, --host=HOSTNAME Database server host # -p, --port=PORT Database server port # -U, --username=USERNAME Username to connect as (not the one to create) # -W, --password Prompt for password to connect # -e, --echo Show the query being sent to the backend # -q, --quiet Don't write any messages # #-- If one of -d, -D, -a, -A, and 'username' is not specified, you will #-- be prompted interactively. #-------------------------------------------------------------------------------------- #--- Created S.Lebedeva #--- Last modofied 12.3.02 $qv="@"; print "Please, enter new username you wish to create: "; $buf=; chomp($buf); $newuser=$buf; print "Please, enter your username: "; $buf=; chomp($buf); $user=$buf; print "Shell a password be assigned for the new user? (y/n)"; $buf=; chomp($buf); $newpass=""; if ($buf eq "y") { $newpass="-P "; } print "Shell the password be encrypted? (y/n)"; $buf=; chomp($buf); $encrypt=""; if ($buf eq "y") { $encrypt="-E "; } print "\n"; $cmd="$ENV{UPS_PROD_DIR}/bin/createuser $newuser -U $user -W -p $ENV{PGPORT} -h $ENV{PGDATA} "; $cmd.= $newpass; $cmd.= $encrypt; #print $cmd, "\n"; system( $cmd );