#!/bin/sh # # This library is part of the FirebirdSQL project # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # You may obtain a copy of the Licence at # http://www.gnu.org/licences/lgpl.html # # As a special exception this file can also be included in modules # with other source code as long as that source code has been # released under an Open Source Initiative certificed licence. # More information about OSI certification can be found at: # http://www.opensource.org # # This module is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public Licence for more details. # # This module was created by members of the firebird development # team. All individual contributions remain the Copyright (C) of # those individuals and all rights are reserved. Contributors to # this file are either listed below or can be obtained from a CVS # history command. # # Created by: Mark O'Donohue # # Contributor(s): # # # $Id: preinstall.sh.in,v 1.4 2004-04-27 12:36:30 brodsom Exp $ # # The pre install routine for Firebird Classic #------------------------------------------------------------------------ # Prompt for response, store result in Answer Answer="" AskQuestion() { Test=$1 DefaultAns=$2 echo -n "${1}" Answer="$DefaultAns" read Answer } #------------------------------------------------------------------------ # stop super server if it is running # Also will only stop firebird, since that has the init script stopServerIfRunning() { checkString=`ps -efww| egrep "(fbserver|fbguard)" |grep -v grep` if [ ! -z "$checkString" ] then if [ -f /etc/init.d/firebird ] then /etc/init.d/firebird stop elif [ -f /etc/rc.d/init.d/firebird ] then /etc/rc.d/init.d/firebird stop fi fi } #------------------------------------------------------------------------ # stop server if it is running checkIfServerRunning() { stopServerIfRunning # Check is server is being actively used. checkString=`ps -efww| egrep "(fbserver|fbguard)" |grep -v grep` if [ ! -z "$checkString" ] then echo "An instance of the Firebird Super server seems to be running." echo "(the ibserver or ibguard process was detected running on your system)" echo "Please quit all Firebird applications and then proceed" exit 1 fi checkString=`ps -efww| egrep "(fb_inet_server|gds_pipe)" |grep -v grep` if [ ! -z "$checkString" ] then echo "An instance of the Firebird classic server seems to be running." echo "(the gds_inet_server or gds_pipe process was detected running on your system)" echo "Please quit all Firebird applications and then proceed." exit 1 fi # The following check for running interbase or firebird 1.0 servers. checkString=`ps -efww| egrep "(ibserver|ibguard)" |grep -v grep` if [ ! -z "$checkString" ] then echo "An instance of the Firebird/InterBase Super server seems to be running." echo "(the ibserver or ibguard process was detected running on your system)" echo "Please quit all Firebird applications and then proceed" exit 1 fi checkString=`ps -efww| egrep "(gds_inet_server|gds_pipe)" |grep -v grep` if [ ! -z "$checkString" ] then echo "An instance of the Firebird/InterBase classic server seems to be running." echo "(the gds_inet_server or gds_pipe process was detected running on your system)" echo "Please quit all Firebird applications and then proceed." exit 1 fi # This one is commented out, since it usually works out ok, we have # checked that no procesers are active, but inetd/xinetd is still listening # the best thing would be to turn the service off, but I don't have time # to do all the xinetd/inetd stuff, see the preunistall.sh script for details # # checkString=`netstat -an | egrep '3050.*LISTEN'` # # if [ ! -z "$checkString" ] # then # echo "An instance of the Firebird/InterBase server seems to be running." # echo "(netstat -an reports a process is already listening on port 3050)" # echo "Please quit all Firebird applications and then proceed." # exit 1 # fi # Stop lock manager if it is the only thing running. for i in `ps -efww | egrep "[gds|fb]_lock_mgr" | awk '{print $2}' ` do kill $i done } #------------------------------------------------------------------------ # Run process and check status runAndCheckExit() { Cmd=$* # echo $Cmd $Cmd ExitCode=$? if [ $ExitCode -ne 0 ] then echo "Install aborted: The command $Cmd " echo " failed with error code $ExitCode" exit $ExitCode fi } #------------------------------------------------------------------------ # Display message if this is being run interactively. displayMessage() { msgText=$1 if [ ! -z "$InteractiveInstall" ] then echo $msgText fi } #------------------------------------------------------------------------ # Archive any existing prior installed files. # The 'cd' stuff is to avoid the "leading '/' removed message from tar. # for the same reason the DestFile is specified without the leading "/" archivePriorInstallSystemFilesX() { oldPWD=`pwd` archiveFileList="" cd / DestFile="$FBRootDir" if [ -e "$DestFile" ] then echo "" echo "" echo "" echo "--- Warning ----------------------------------------------" echo " The installation target directory: $FBRootDir" echo " Already contains a prior installation of Firebird." echo " This and files found in /usr/include and @libdir@ will be" echo " archived in the file : ${ArchiveMainFile}" echo "" if [ ! -z "$InteractiveInstall" ] then AskQuestion "Press return to continue or ^C to abort" fi if [ -e $DestFile ] then archiveFileList="$archiveFileList $DestFile" fi fi for i in ibase.h iberror.h ib_util.h do DestFile=usr/include/$i if [ -e $DestFile ] then archiveFileList="$archiveFileList $DestFile" fi done for i in gds_pyxis.a gds.a libfbembed.so.@FIREBIRD_VERSION@ libfbclient.so.@FIREBIRD_VERSION@ libib_util.so libgds.a do DestFile=usr/lib/$i if [ -e $DestFile ] then archiveFileList="$archiveFileList $DestFile" fi done for i in usr/sbin/rcfirebird etc/init.d/firebird etc/rc.d/init.d/firebird do DestFile=$i if [ -e $DestFile ] then archiveFileList="$archiveFileList $DestFile" fi done if [ ! -z "$archiveFileList" ] then displayMessage "Archiving..." runAndCheckExit "tar -czf $ArchiveMainFile $archiveFileList" displayMessage "Done." displayMessage "Deleting..." for i in $archiveFileList do rm -rf $i done displayMessage "Done." fi cd $oldPWD } #------------------------------------------------------------------------ # Archive any existing prior installed files. # This is mainly for the .tar.gz install since rpm packages take care of # thier own. archivePriorInstallSystemFiles() { if [ ! -f manifest.txt ] then return fi archiveFileList="" for i in `cat manifest.txt` do if [ ! -d /$i ] # Ignore directories then if [ -e /$i ] then archiveFileList="$archiveFileList $i" fi fi done for i in usr/sbin/rcfirebird etc/init.d/firebird etc/rc.d/init.d/firebird do DestFile=./$i if [ -e /$DestFile ] then archiveFileList="$archiveFileList $DestFile" fi done deleteFileList="$archiveFileList" DestFile="$FBRootDir" if [ ! -z "$archiveFileList" ] then cat <