summaryrefslogtreecommitdiff
path: root/databases/postgresql
diff options
context:
space:
mode:
authoragc <agc>1998-02-17 15:42:04 +0000
committeragc <agc>1998-02-17 15:42:04 +0000
commit2cec21bd7574e2299f31ab9656e6a659ac0125ac (patch)
treef8fe5730774e052949df03d7929d842efa4bb803 /databases/postgresql
parente2be877124621ccf908da4f4d2994bd9db2ebb45 (diff)
downloadpkgsrc-2cec21bd7574e2299f31ab9656e6a659ac0125ac.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/postgresql')
-rw-r--r--databases/postgresql/scripts/createuser24
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) = @_;