|
From: <haw...@us...> - 2007-10-02 19:47:09
|
Revision: 169
http://pgsqlformac.svn.sourceforge.net/pgsqlformac/?rev=169&view=rev
Author: hawkmoon
Date: 2007-10-02 12:46:55 -0700 (Tue, 02 Oct 2007)
Log Message:
-----------
updated to address Leopard/Tiger compat. Dropped Panther Compat
Modified Paths:
--------------
trunk/Installers/PostgreSQL8/Resources/postflight
trunk/Installers/PostgreSQL8/Resources/preflight
Modified: trunk/Installers/PostgreSQL8/Resources/postflight
===================================================================
--- trunk/Installers/PostgreSQL8/Resources/postflight 2007-05-25 18:14:42 UTC (rev 168)
+++ trunk/Installers/PostgreSQL8/Resources/postflight 2007-10-02 19:46:55 UTC (rev 169)
@@ -3,56 +3,64 @@
# first let's make sure the the postgres user does
# not currently exist
-# set -e
+# Leopard/Tiger - this no longer works on Panther
-PG_GID=`/usr/bin/nifind -p //groups/postgres | grep "gid:.[0-9]" | sed 's/.*: //' | sed 's/ //'`
-
-# Group Doesn't Exist, create it
-if ! test $PG_GID; then
+echo Checking for Postgres group...
+PG_GID=`/usr/bin/dscl . read /groups/postgres PrimaryGroupID | grep "PrimaryGroupID:.[0-9]" | sed 's/.*: //' | sed 's/ //'`
+if test $PG_GID; then
+ echo ...found Postgres with GID of $PG_GID
+else
+ echo ...Postgres group not found
+
# loop through the '400's' until we find an available gid
X=401
until test $PG_GID; do
- TEST_GID=`/usr/bin/nidump -r /groups / | grep $X `
- if ! test "$TEST_GID"; then
+ TEST_GID=`/usr/bin/dscl . search /groups PrimaryGroupID $X | grep $X `
+
+ if test $TEST_GID; then
+ echo ...Group ID $X is not available
+ else
+ echo ...Group ID $X is available,
PG_GID=$X
fi
X=`expr $X + 1`
done
+
+ sudo /usr/bin/dscl . -create /groups/postgres PrimaryGroupID $PG_GID
+ echo ...Group postgres created with GID $PG_GID
- sudo /usr/bin/niutil -create / /groups/postgres
- sudo /usr/bin/niutil -createprop / /groups/postgres gid $PG_GID
fi
-# Display the GID for user information
-echo Postgres Group ID: $PG_GID
-
-# Now that the group exists, create the user
-
-PG_UID=`/usr/bin/nifind -p //users/postgres | grep "^uid:.[0-9]" | sed 's/.*: //' | sed 's/ //'`
+echo Checking for Postgres user...
+PG_UID=`/usr/bin/dscl . -read /users/postgres | grep "^UniqueID:.[0-9]" | sed 's/.*: //' | sed 's/ //'`
+if test $PG_UID; then
+ echo ...found user postgres with UID of $PG_UID
+else
+ echo ...user postgres not found
-# User Doesn't Exist, create it
-if ! test $PG_UID; then
- # loop through the '400's' until we find an available uid (start with the GID)
- X=$PG_GID
+ # loop through the '400's' until we find an available gid
+ X=401
until test $PG_UID; do
- TEST_UID=`/usr/bin/nidump -r /users / | grep "\"uid\" \= \( \"$X\" \);" `
- if ! test "$TEST_UID"; then
+ TEST_UID=`/usr/bin/dscl . -search /users UniqueID $X | grep $X `
+
+ if test $TEST_UID; then
+ echo ...Unique ID $X is not available
+ else
+ echo ...Unique ID $X is available,
PG_UID=$X
fi
X=`expr $X + 1`
done
-
- sudo /usr/bin/niutil -create / /users/postgres
- sudo /usr/bin/niutil -createprop / /users/postgres gid $PG_GID
- sudo /usr/bin/niutil -createprop / /users/postgres uid $PG_UID
- sudo /usr/bin/niutil -createprop / /users/postgres home "/Library/PostgreSQL8"
+
+ sudo /usr/bin/dscl . -create /users/postgres UniqueID $PG_UID
+ sudo /usr/bin/dscl . -append /users/postgres PrimaryGroupID $PG_GID
+ sudo /usr/bin/dscl . -append /users/postgres UserShell /usr/bin/false
+ sudo /usr/bin/dscl . -append /users/postgres RealName "PostgreSQL Server"
+ sudo /usr/bin/dscl . -append /users/postgres NFSHomeDirectory /var/empty
+
+ echo ...User postgres created with UID $PG_UID
fi
-
-sudo /usr/bin/niutil -resync /
-
-# Display the GID for user information
-echo Postgres User ID: $PG_UID
-
+
echo The Postgres user is configured, but you should set a
echo password on the newly created account. \(sudo passwd postgres\)
@@ -65,6 +73,7 @@
if test ! -f /Library/Logs/PostgreSQL8.log; then
sudo ln -s /Library/PostgreSQL8/log/PostgreSQL8.log /Library/Logs/PostgreSQL8.log
fi
+
sudo chown -R root:admin /Library/PostgreSQL8
sudo chown -R root:admin /Applications/PostgreSQL
sudo chown -R postgres:admin /Library/PostgreSQL8/log
@@ -74,6 +83,8 @@
sudo mkdir /Library/PostgreSQL8/data
sudo chown -R postgres:postgres /Library/PostgreSQL8/data
su -m postgres -c '/Library/PostgreSQL8/bin/initdb -D /Library/PostgreSQL8/data'
+else
+ sudo chown -R postgres:postgres /Library/PostgreSQL8/data
fi
echo Permissions have been altered to allow the automated startup
Modified: trunk/Installers/PostgreSQL8/Resources/preflight
===================================================================
--- trunk/Installers/PostgreSQL8/Resources/preflight 2007-05-25 18:14:42 UTC (rev 168)
+++ trunk/Installers/PostgreSQL8/Resources/preflight 2007-10-02 19:46:55 UTC (rev 169)
@@ -2,7 +2,7 @@
# check to see if PostgreSQL is running.
-x=`ps -auxwc | grep postgres |grep postmaster | awk -F" " '{print $2}'`
+x=`ps -auxwc | grep '^postgres' |grep 'postgres$' | awk -F" " '{print $2}'`
if /bin/test -n "$x"
then
# call shutdown...
@@ -11,7 +11,7 @@
su -m postgres -c '/Library/PostgreSQL8/bin/pg_ctl stop -D /Library/PostgreSQL8/data'
fi
- x=`ps -aux | grep postgres | grep postmaster | awk -F" " '{print $2}'`
+ x=`ps -auxwc | grep '^postgres' |grep 'postgres$' | awk -F" " '{print $2}'`
if /bin/test "$x"
then
set $x
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|