diff options
Diffstat (limited to 'databases')
-rw-r--r-- | databases/postgresql/scripts/createuser | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/databases/postgresql/scripts/createuser b/databases/postgresql/scripts/createuser index ceb99626e64..678c429366b 100644 --- a/databases/postgresql/scripts/createuser +++ b/databases/postgresql/scripts/createuser @@ -10,29 +10,37 @@ if( $> ) { exit 1; } -if( getpwnam( "pgsql" ) ) { - ( $null, $null, $pgUID ) = getpwnam( "pgsql" ); +@ARGV = "pgsql" unless @ARGV; + +$pgsql = $ARGV[0]; + +if( getpwnam( $pgsql ) ) { + ( $null, $null, $pgUID ) = getpwnam( $pgsql ); + $addname = 0; } else { $pgUID = 70; while( getpwuid( $pgUID ) ) { $pgUID++; } + $addname = 1; } -if( getgrnam( "pgsql" ) ) { - ( $null, $null, $pgGID ) = getgrnam( "pgsql" ); +if( getgrnam( $pgsql ) ) { + ( $null, $null, $pgGID ) = getgrnam( $pgsql ); } else { $pgGID = 70; while( getgrgid( $pgGID ) ) { $pgGID++; } - &append_file( "/etc/group", "pgsql:*:$pgGID:" ); + &append_file( "/etc/group", "${pgsql}:*:${pgGID}:" ); } -print "pgsql user using uid $pgUID\n"; -print "pgsql user using gid $pgGID\n"; +print "pgsql user $pgsql using uid $pgUID\n"; +print "pgsql user $pgsql using gid $pgGID\n"; -system( "/usr/bin/chpass -a \"pgsql:*:$pgUID:$pgGID::0:0:PostgreSQL pseudo-user:$ENV{'PREFIX'}/pgsql:/bin/sh\"" ); +if ($addname) { + system( "/usr/bin/chpass -a \"$pgsql:tgeuR/ly70tJo:${pgUID}:${pgGID}::0:0:PostgreSQL pseudo-user:$ENV{'PREFIX'}/$pgsql:/bin/sh\"" ); +} sub append_file { local($file,@list) = @_; |