2007-03-09 11:32:58 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Script args:
|
|
|
|
# $0: full path to script
|
|
|
|
# $1: full path to top level package dir, no trailing slash
|
|
|
|
# $2: full path to installed location
|
|
|
|
# $3: ????? Path to install Volume????
|
|
|
|
# $4: ?????
|
|
|
|
|
2007-12-07 13:19:37 +01:00
|
|
|
# MacOS Notes
|
|
|
|
# 10.0 Cheetah
|
|
|
|
# 10.01 Puma
|
|
|
|
# 10.2 Jaguar
|
|
|
|
# 10.3 Panther (xinetd)
|
|
|
|
# 10.4 Tiger - Uses Launchd (xinetd for backward compatibility)
|
2007-12-10 12:13:53 +01:00
|
|
|
# 10.5 Leopard - Uses Launchd (No xinetd) (no ni* commands)
|
2007-12-07 13:19:37 +01:00
|
|
|
|
|
|
|
OSVERSION=`sw_vers -productVersion | awk -F '.' '{print $2}'`
|
|
|
|
echo $OSVERSION
|
|
|
|
|
2007-06-11 16:21:33 +02:00
|
|
|
FB_FW="/Library/Frameworks/Firebird.framework"
|
2007-03-09 11:32:58 +01:00
|
|
|
FB_RES="$FB_FW/Versions/A/Resources"
|
|
|
|
INST_RES="$FB_RES/installer_files"
|
|
|
|
|
|
|
|
# Install and start sysv semaphores
|
2007-06-11 16:21:33 +02:00
|
|
|
echo "Install and start sysv semaphores"
|
2007-03-09 11:32:58 +01:00
|
|
|
if test `uname -r | sed -e 's/\.[0-9]*//g'` -lt 6; then
|
|
|
|
if [ -e "SysV Semaphores" ]; then
|
|
|
|
mkdir -p /Library/StartupItems
|
|
|
|
if [ ! -e "/Library/StartupItems/SysV Semaphores" ]; then
|
|
|
|
cp -r "$INST_RES/SysV Semaphores" /Library/StartupItems
|
|
|
|
"/Library/StartupItems/SysV Semaphores/SysV Semaphores" start
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-12-07 13:19:37 +01:00
|
|
|
if test $OSVERSION -lt 5; then
|
|
|
|
# Setup our services entry
|
|
|
|
echo "Setup the service entry pre 10.5"
|
2007-03-09 11:32:58 +01:00
|
|
|
if niutil -list . /services/gds_db 2&>1 /dev/null ; then
|
|
|
|
echo -n
|
|
|
|
else
|
|
|
|
niutil -create . /services/gds_db
|
|
|
|
niutil -createprop . /services/gds_db port 3050
|
|
|
|
niutil -createprop . /services/gds_db protocol tcp tcp
|
|
|
|
fi
|
2007-12-07 13:19:37 +01:00
|
|
|
fi
|
2007-03-09 11:32:58 +01:00
|
|
|
|
2007-12-07 13:19:37 +01:00
|
|
|
# No niutil on 10.5
|
|
|
|
# Setup our services entry
|
|
|
|
echo "Setup the service entry 10.5+"
|
|
|
|
|
|
|
|
if test $OSVERSION -lt 5; then
|
|
|
|
# niutil works pre 10.5
|
2007-03-09 11:32:58 +01:00
|
|
|
# Now for the group. If the firebird group already exists, remember the
|
2007-12-07 13:19:37 +01:00
|
|
|
# id if we need it to create the firebird user
|
|
|
|
echo "Create the Firebird group pre 10.5"
|
2007-03-09 11:32:58 +01:00
|
|
|
if niutil -list . /groups/firebird 2&>1 /dev/null; then
|
|
|
|
NEW_GID=`niutil -readprop . /groups/firebird gid`
|
|
|
|
else
|
|
|
|
NEW_GID=`nigrep gid . /groups | grep ": gid " | awk '{ print $4 + 1 } ' | sort -n | tail -1`
|
|
|
|
niutil -create . /groups/firebird
|
|
|
|
niutil -createprop . /groups/firebird passwd "*"
|
|
|
|
niutil -createprop . /groups/firebird gid $NEW_GID
|
|
|
|
niutil -createprop . /groups/firebird users firebird
|
|
|
|
fi
|
2007-12-07 13:19:37 +01:00
|
|
|
fi
|
2007-03-09 11:32:58 +01:00
|
|
|
|
2007-12-07 13:19:37 +01:00
|
|
|
# No niutil on 10.5
|
|
|
|
# Now create the firebird group
|
|
|
|
if dscl localhost -read /Local/Default/Groups/firebird 2&>1 /dev/null; then
|
|
|
|
echo "Group Found"
|
|
|
|
else
|
|
|
|
gid=501
|
|
|
|
dscl localhost -search /Local/Default/Groups PrimaryGroupID $gid | grep $gid
|
|
|
|
while [ "$?" = "0" ]; do
|
|
|
|
let "gid =$gid+1"
|
|
|
|
dscl localhost -search /Local/Default/Groups PrimaryGroupID $gid | grep $gid
|
|
|
|
done
|
|
|
|
echo "Create the Firebird group 10.5+"
|
|
|
|
dscl localhost -create /Local/Default/Groups/firebird
|
|
|
|
dscl localhost -create /Local/Default/Groups/firebird Password "*"
|
|
|
|
dscl localhost -create /Local/Default/Groups/firebird PrimaryGroupID $gid
|
|
|
|
dscl localhost -create /Local/Default/Groups/firebird RecordName firebird
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test $OSVERSION -lt 5; then
|
|
|
|
# niutil works pre 10.5
|
2007-03-09 11:32:58 +01:00
|
|
|
# Now create the firebird user
|
2007-12-07 13:19:37 +01:00
|
|
|
echo "Create the Firebird user pre 10.5"
|
2007-03-09 11:32:58 +01:00
|
|
|
if niutil -list . /users/firebird 2&>1 /dev/null; then
|
|
|
|
echo -n
|
|
|
|
else
|
|
|
|
NEW_UID=`nigrep uid . /users | grep ": uid " | awk '{ print $4 + 1 } ' | sort -n | tail -1`
|
|
|
|
niutil -create . /users/firebird
|
|
|
|
niutil -createprop . /users/firebird uid $NEW_UID
|
|
|
|
niutil -createprop . /users/firebird home /Library/Frameworks/Firebird.framework
|
|
|
|
niutil -createprop . /users/firebird passwd "*"
|
|
|
|
niutil -createprop . /users/firebird expire 0
|
|
|
|
niutil -createprop . /users/firebird shell /bin/tcsh
|
|
|
|
niutil -createprop . /users/firebird change 0
|
|
|
|
niutil -createprop . /users/firebird gid $NEW_GID
|
2007-12-07 13:19:37 +01:00
|
|
|
niutil -createprop . /users/firebird realname "Firebird Database"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# no niutil on 10.5 use dscl
|
|
|
|
# Now create the firebird user
|
|
|
|
if dscl localhost -read /Local/Default/Users/firebird 2&>1 /dev/null; then
|
|
|
|
echo "User Found"
|
|
|
|
else
|
|
|
|
ugid=501
|
|
|
|
dscl localhost -search /Local/Default/Users UniqueID $ugid | grep $ugid
|
|
|
|
while [ "$?" = "0" ]; do
|
|
|
|
let "ugid=$ugid+1"
|
|
|
|
dscl localhost -search /Local/Default/Users UniqueID $ugid | grep $ugid
|
|
|
|
done
|
|
|
|
echo "create the firebird user 10.5+"
|
|
|
|
dscl localhost -create /Local/Default/Users/firebird
|
|
|
|
dscl localhost -create /Local/Default/Users/firebird NFSHomeDirectory /Library/Frameworks/firebird.framework
|
|
|
|
dscl localhost -create /Local/Default/Users/firebird Password "*"
|
|
|
|
dscl localhost -create /Local/Default/Users/firebird UserShell /bin/tcsh
|
|
|
|
dscl localhost -create /Local/Default/Users/firebird RecordName firebird
|
|
|
|
dscl localhost -create /Local/Default/Users/firebird PrimaryGroupID $gid
|
|
|
|
dscl localhost -create /Local/Default/Users/firebird UniqueID $ugid
|
|
|
|
dscl localhost -create /Local/Default/Users/firebird RealName "Firebird Database"
|
2007-03-09 11:32:58 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Shutdown any existing servers
|
2007-06-11 16:21:33 +02:00
|
|
|
echo "Shutdown any existing servers"
|
2007-03-09 11:32:58 +01:00
|
|
|
if [ -x /sbin/service ]; then
|
|
|
|
service firebird stop
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install the framework
|
2007-06-11 16:21:33 +02:00
|
|
|
echo "Install the framework"
|
2007-12-07 13:19:37 +01:00
|
|
|
chown -R firebird:firebird "$FB_FW"
|
2007-03-09 11:32:58 +01:00
|
|
|
|
|
|
|
# set the permissions correctly
|
2007-06-11 16:21:33 +02:00
|
|
|
echo "Set the permissions correctly"
|
2007-03-09 11:32:58 +01:00
|
|
|
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
|
|
|
|
chmod 777 "$FB_FW/Resources/English.lproj/var"
|
|
|
|
chmod 777 "$FB_FW/Resources/English.lproj/var/security2.fdb"
|
|
|
|
chmod 777 "$FB_FW/Resources/English.lproj/var/help/help.fdb"
|
|
|
|
else
|
|
|
|
chmod 777 "$FB_FW/Resources/English.lproj/var"
|
|
|
|
chmod 777 "$FB_FW/Resources/English.lproj/var/security2.fdb"
|
|
|
|
chmod 777 "$FB_FW/Resources/English.lproj/var/help/help.fdb"
|
|
|
|
|
2007-06-11 16:21:33 +02:00
|
|
|
chmod a+s "$FB_FW/Resources/bin/gds_drop"
|
2007-03-09 11:32:58 +01:00
|
|
|
chmod a+s "$FB_FW/Resources/bin/fb_lock_mgr"
|
2008-01-22 10:40:41 +01:00
|
|
|
chown root "$FB_FW/Resources/bin/fb_lock_mgr"
|
2007-03-09 11:32:58 +01:00
|
|
|
chmod a+s "$FB_FW/Resources/bin/fb_inet_server"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install the startup item
|
2007-12-22 01:53:39 +01:00
|
|
|
echo "Re-install the SuperServer startup item - if it already exists"
|
2007-03-09 11:32:58 +01:00
|
|
|
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
|
|
|
|
if [ -e "$INST_RES/Firebird.startup" ]; then
|
2007-06-11 16:21:33 +02:00
|
|
|
rm -rf /Library/StartupItems/Firebird
|
|
|
|
cp -r "$INST_RES/Firebird" /Library/StartupItems/Firebird
|
2007-03-09 11:32:58 +01:00
|
|
|
fi
|
|
|
|
else
|
2007-06-11 16:21:33 +02:00
|
|
|
rm -rf /Library/StartupItems/Firebird
|
2007-03-09 11:32:58 +01:00
|
|
|
fi
|
|
|
|
|
2007-06-11 16:21:33 +02:00
|
|
|
# Remove all traces of Classic first
|
|
|
|
echo "Remove all traces of Classic first"
|
2007-03-09 11:32:58 +01:00
|
|
|
if [ -f /etc/inetd.conf ]; then
|
|
|
|
grep -s gds_db /etc/inetd.conf > /dev/null 2>&1
|
|
|
|
if test $? != 0 ; then
|
|
|
|
cat /etc/inetd.conf | grep -v gds_db > /etc/.interbase.temp.install.inetd.conf
|
|
|
|
mv /etc/.interbase.temp.install.inetd.conf /etc/inetd.conf
|
|
|
|
HUPNEEDED='y'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /etc/xinetd.d/firebird ]; then
|
|
|
|
rm /etc/xinetd.d/firebird
|
|
|
|
HUPNEEDED='y'
|
|
|
|
fi
|
|
|
|
|
2007-12-20 12:34:29 +01:00
|
|
|
if [ -f /Library/LaunchDaemons/org.firebird.gds.plist ]; then
|
2007-12-07 13:19:37 +01:00
|
|
|
launchctl unload /Library/LaunchDaemons/org.firebird.gds.plist
|
|
|
|
rm /Library/LaunchDaemons/org.firebird.gds.plist
|
|
|
|
HUPNEEDED='y'
|
|
|
|
fi
|
|
|
|
|
2007-06-11 16:21:33 +02:00
|
|
|
# Install ourselves in the correct place - SuperServer
|
2007-12-20 12:34:29 +01:00
|
|
|
echo "Install StartupItem in the correct place SuperServer"
|
2007-06-11 16:21:33 +02:00
|
|
|
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
|
|
|
|
cp -r $1/Contents/Resources/StartupItem /Library/StartupItems/Firebird
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install ourselves in the correct place - Classic
|
2007-12-07 13:19:37 +01:00
|
|
|
echo "Install ourselves in the correct place Classic"
|
2007-06-11 16:21:33 +02:00
|
|
|
|
2007-12-07 13:19:37 +01:00
|
|
|
# inetd.d - older versions of MacOS
|
|
|
|
echo "Test inetd"
|
2008-01-22 11:30:23 +01:00
|
|
|
if [ -f /var/run/inetd.pid -a -d /etc/inetd.d ]; then
|
2007-06-11 16:21:33 +02:00
|
|
|
if [ -f /etc/inetd.conf ]; then
|
|
|
|
echo "gds_db stream tcp nowait root $FB_FW/Resources/bin/fb_inet_server fb_inet_server" > /etc/.fb.inetd.conf.entry
|
|
|
|
cat /etc/inetd.conf /etc/.fb.inetd.conf.entry > /etc/.interbase.temp.install.inetd.conf
|
|
|
|
mv /etc/.interbase.temp.install.inetd.conf /etc/inetd.conf
|
|
|
|
rm -f /etc/.fb.inetd.conf.entry
|
|
|
|
HUPNEEDED='y'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-12-07 13:19:37 +01:00
|
|
|
# xinetd.d - Pre MacOS 10.5 (Leopard)
|
|
|
|
echo "Test xinetd.d"
|
2007-03-09 11:32:58 +01:00
|
|
|
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
|
2007-06-11 16:21:33 +02:00
|
|
|
echo -n
|
2007-03-09 11:32:58 +01:00
|
|
|
else
|
2007-12-07 13:19:37 +01:00
|
|
|
if [ -f /etc/xinet.d ]; then
|
2007-06-11 16:21:33 +02:00
|
|
|
cat > /etc/xinetd.d/firebird <<EOF
|
2007-03-09 11:32:58 +01:00
|
|
|
service gds_db
|
|
|
|
{
|
|
|
|
disable = no
|
|
|
|
socket_type = stream
|
|
|
|
wait = no
|
|
|
|
user = firebird
|
|
|
|
EOF
|
2007-06-11 16:21:33 +02:00
|
|
|
echo "server = $FB_FW/Resources/bin/fb_inet_server" >> /etc/xinetd.d/firebird
|
2007-03-09 11:32:58 +01:00
|
|
|
cat >> /etc/xinetd.d/firebird << EOF
|
|
|
|
groups = yes
|
|
|
|
}
|
|
|
|
EOF
|
2007-06-11 16:21:33 +02:00
|
|
|
|
2007-03-09 11:32:58 +01:00
|
|
|
HUPNEEDED='y'
|
|
|
|
fi
|
2007-12-07 13:19:37 +01:00
|
|
|
fi
|
2007-03-09 11:32:58 +01:00
|
|
|
|
2007-12-07 13:19:37 +01:00
|
|
|
# launchd
|
|
|
|
echo "Test launchd"
|
2007-12-20 12:34:29 +01:00
|
|
|
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
|
|
|
|
echo -n
|
|
|
|
else
|
2007-12-07 13:19:37 +01:00
|
|
|
cp $FB_FW/Resources/org.firebird.gds.plist /Library/LaunchDaemons/org.firebird.gds.plist
|
|
|
|
launchctl load /Library/LaunchDaemons/org.firebird.gds.plist
|
2007-12-20 12:34:29 +01:00
|
|
|
fi
|
2007-03-09 11:32:58 +01:00
|
|
|
|
|
|
|
# Make sure the hosts.equiv files are set correctly
|
2007-06-11 16:21:33 +02:00
|
|
|
echo "Make sure hosts.equiv files are set correctly"
|
2007-03-09 11:32:58 +01:00
|
|
|
cp /etc/hosts.equiv /etc/hosts.equiv.fbsave
|
|
|
|
if grep -x "localhost" /etc/hosts.equiv > /dev/null; then
|
|
|
|
echo -n
|
|
|
|
else
|
|
|
|
echo "localhost" >> /etc/hosts.equiv
|
|
|
|
fi
|
|
|
|
if grep -x "localhost.localdomain" /etc/hosts.equiv > /dev/null; then
|
|
|
|
echo -n
|
|
|
|
else
|
|
|
|
echo "localhost.localdomain" >> /etc/hosts.equiv
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install the saved security database, if any
|
2007-06-11 16:21:33 +02:00
|
|
|
echo "Install the saved security database"
|
|
|
|
if test -f /tmp/fb-security-database-update2.fdb; then
|
|
|
|
mv -f /tmp/fb-security-database-update2.fdb "$FB_RES/English.lproj/var/security2.fdb"
|
|
|
|
rm -f /tmp/fb-security-database-update2.fdb
|
2007-03-09 11:32:58 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Tell inetd/xinetd to reload their configuration files.
|
2007-06-11 16:21:33 +02:00
|
|
|
echo "Tell inetd/xinetd to reload configuration files"
|
2007-03-09 11:32:58 +01:00
|
|
|
if [ "$HUPNEEDED" = 'y' ]
|
|
|
|
then
|
|
|
|
#INETPID=`ps -axe | grep inetd | awk '{print $1}'`
|
|
|
|
if [ -f /var/run/inetd.pid ]
|
|
|
|
then
|
|
|
|
kill -HUP `cat /var/run/inetd.pid`
|
|
|
|
fi
|
|
|
|
if [ -f /var/run/xinetd.pid ]
|
|
|
|
then
|
|
|
|
kill -HUP `cat /var/run/xinetd.pid`
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-12-20 12:34:29 +01:00
|
|
|
And last but not least, start the server
|
|
|
|
echo "Start SuperServer"
|
|
|
|
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
|
|
|
|
chmod u+xg+xo+x /Library/StartupItems/Firebird/Firebird
|
|
|
|
/Library/StartupItems/Firebird/Firebird start
|
|
|
|
fi
|