summaryrefslogtreecommitdiff
path: root/japanese/postgresql7/scripts/createuser
diff options
context:
space:
mode:
authorJun Kuriyama <kuriyama@FreeBSD.org>2000-07-19 01:18:08 +0000
committerJun Kuriyama <kuriyama@FreeBSD.org>2000-07-19 01:18:08 +0000
commit45436e156d55e87d8edfe41d4cf59a935a00eb1e (patch)
tree349e474d914789c501935ba7f0586305e281e302 /japanese/postgresql7/scripts/createuser
parentFix build failure on -current. (Another fix regarding Perl 5.6.0 update) (diff)
Japannese configured PostgreSQL v7.
(after repository copy from japanese/postgresql).
Notes
Notes: svn path=/head/; revision=30809
Diffstat (limited to '')
-rw-r--r--japanese/postgresql7/scripts/createuser50
1 files changed, 50 insertions, 0 deletions
diff --git a/japanese/postgresql7/scripts/createuser b/japanese/postgresql7/scripts/createuser
new file mode 100644
index 000000000000..2abe201e7a4b
--- /dev/null
+++ b/japanese/postgresql7/scripts/createuser
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+#
+
+eval '(exit $?0)' && eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
+& eval 'exec /usr/bin/perl -S $0 $argv:q'
+if 0;
+
+if( $> ) {
+ print "\nYou must be root to run this step!\n\n";
+ exit 1;
+}
+
+if( getpwnam( "pgsql" ) ) {
+ ( $null, $null, $pgUID ) = getpwnam( "pgsql" );
+} else {
+ $pgUID = 70;
+ while( getpwuid( $pgUID ) ) {
+ $pgUID++;
+ }
+}
+
+if( getgrnam( "pgsql" ) ) {
+ ( $null, $null, $pgGID ) = getgrnam( "pgsql" );
+} else {
+ $pgGID = 70;
+ while( getgrgid( $pgGID ) ) {
+ $pgGID++;
+ }
+ &append_file( "/etc/group", "pgsql:*:$pgGID:" );
+}
+
+print "pgsql user using uid $pgUID\n";
+print "pgsql user using gid $pgGID\n";
+
+system( "/usr/bin/chpass -a \"pgsql:*:$pgUID:$pgGID\:\:0:0:PostgreSQL pseudo-user:$ENV{'PREFIX'}/pgsql:/bin/sh\"" );
+
+sub append_file {
+ local($file,@list) = @_;
+ local($LOCK_EX) = 2;
+ local($LOCK_NB) = 4;
+ local($LOCK_UN) = 8;
+
+ open(F, ">> $file") || die "$file: $!\n";
+ while( ! flock( F, $LOCK_EX | $LOCK_NB ) ) {
+ exit 1;
+ }
+ print F join( "\n", @list) . "\n";
+ close F;
+ flock( F, $LOCK_UN );
+}