8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 06:43:03 +01:00
firebird-mirror/builds/install/arch-specific/darwin/install-script

206 lines
6.6 KiB
Bash

#!/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: ?????
# MacOS Notes
# 10.7 Lion
# 10.8 Mountain Lion
# 10.9 Mavericks - Clang not gcc
# 10.10 Yosemite - No longer uses StartupItems
# 10.11 El Capitan - Old installer deprecated -pkgbuild
OSVERSION=`sw_vers -productVersion | awk -F '.' '{print $2}'`
echo "OSVersion =" $OSVERSION
FB_FW="/Library/Frameworks/Firebird.framework"
FB_RES="$FB_FW/Versions/A/Resources"
# Now create the firebird group
echo "Create the Firebird group 10.7+"
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
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
# Now create the firebird user
echo "Create the Firebird user 10.7+"
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.7+"
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"
fi
# Shutdown any existing servers
echo "Shutdown any existing servers"
if [ -x /sbin/service ]; then
service firebird stop
fi
# Install the framework
echo "Install the framework"
chown -R firebird:firebird "$FB_FW"
# set the permissions correctly
echo "Set the permissions correctly"
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
chmod 777 "$FB_FW/Resources/English.lproj/var"
chmod 600 "$FB_FW/Resources/English.lproj/var/security2.fdb"
chmod 444 "$FB_FW/Resources/English.lproj/var/help/help.fdb"
else
chmod 777 "$FB_FW/Resources/English.lproj/var"
chmod 660 "$FB_FW/Resources/English.lproj/var/security2.fdb"
chmod 444 "$FB_FW/Resources/English.lproj/var/help/help.fdb"
chmod a+s "$FB_FW/Resources/bin/fb_inet_server"
fi
# Remove all traces of Classic first
echo "Remove all traces of Classic first"
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/.firebird.temp.install.inetd.conf
mv /etc/.firebird.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
if [ -f /Library/LaunchDaemons/org.firebird.gds.plist ]; then
launchctl unload /Library/LaunchDaemons/org.firebird.gds.plist
rm /Library/LaunchDaemons/org.firebird.gds.plist
HUPNEEDED='y'
fi
# Install ourselves in the correct place - SuperServer
echo "Install StartupItem in the correct place SuperServer"
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
rm -fr /Library/StartupItems/Firebird
cp -r "$1/Resources/StartupItem" /Library/StartupItems/Firebird
else
cp -r "$1/Resources/StartupItem" $FB_FW/Resources/FirebirdSS
rm -fr /Library/StartupItems/Firebird
fi
# Install ourselves in the correct place - Classic
echo "Install ourselves in the correct place Classic"
# launchd 10.7+
echo "Test launchd"
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
if test $OSVERSION -lt 10
then
echo -n
fi
fi
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
if test $OSVERSION -gt 9
then
echo "Yosemite and launchctl"
cp $FB_FW/Resources/org.firebird.gds.plist /Library/LaunchDaemons/org.firebird.gds.plist
launchctl load /Library/LaunchDaemons/org.firebird.gds.plist
fi
fi
if [ ! -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
cp $FB_FW/Resources/org.firebird.gds.plist /Library/LaunchDaemons/org.firebird.gds.plist
launchctl load /Library/LaunchDaemons/org.firebird.gds.plist
fi
# Make sure the hosts.equiv files are set correctly
echo "Make sure hosts.equiv files are set correctly"
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
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
fi
#Install the saved aliases.conf, if any
echo "Install the saved aliases.conf file"
if test -f /tmp/fb-aliases.conf; then
mv -f /tmp/fb-aliases.conf "$FB_RES/English.lproj/var/aliases.conf"
fi
#Install the saved UDF libraries, if any
echo "Install the saved UDF libraries"
for file in /tmp/*UDF_save_*; do
new=`echo $file | sed -e 's/UDF_save_//g'`
return=`basename $new`
cp $file "$FB_RES/English.lproj/var/UDF/$return"
rm $file
done
#If classic, add libfbclient to dynamic loader search path
echo "Add libfbclient to dynamic loader search path"
if [ ! -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
ln -s "$FB_FW/Libraries/libfbclient.dylib" /usr/local/lib/libfbclient.dylib
fi
# And last but not least, start the server
echo "Start SuperServer"
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
if test $OSVERSION -lt 10
then
echo "SuperServer uses StartupItems"
chmod u+xg+xo+x /Library/StartupItems/Firebird/Firebird
/Library/StartupItems/Firebird/Firebird start
fi
fi
if [ -f "$FB_FW/Versions/A/Resources/.SuperServer" ]; then
if test $OSVERSION -gt 9
then
echo "SuperServer uses launchctl"
launchctl load /Library/LaunchDaemons/org.firebird.gds.plist
fi
fi