diff options
author | agc <agc@pkgsrc.org> | 1998-02-17 15:42:04 +0000 |
---|---|---|
committer | agc <agc@pkgsrc.org> | 1998-02-17 15:42:04 +0000 |
commit | 543da79c5a4591aea97fcd46977c0cd1a43b034b (patch) | |
tree | f8fe5730774e052949df03d7929d842efa4bb803 /databases | |
parent | 7933c17d7a68427b421d5a4e5ab8277e439cc2cc (diff) | |
download | pkgsrc-543da79c5a4591aea97fcd46977c0cd1a43b034b.tar.gz |
If an argument is passed to this perl script, use that as the pgsql user name.
Only add the user if it doesn't exist in the passwd file.
Work around a problem in pw_scan(3) for now.
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) = @_; |