Debian Codegraph @

builds/install/arch-specific/hpux/super/preInstall.sh.in

raw
1 #!/bin/sh
2
3 #------------------------------------------------------------------------
4 # Prompt for response, store result in Answer
5
6 Answer=""
7
8 AskQuestion() {
9 Test=$1
10 DefaultAns=$2
11 echo -n "${1}"
12 Answer="$DefaultAns"
13 read Answer
14 }
15
16
17 #------------------------------------------------------------------------
18 # stop super server if it is running
19 # Also will only stop firebird, since that has the init script
20
21
22 stopServerIfRunning() {
23
24 checkString=`ps -ef | egrep "(fbserver|fbguard)" |grep -v grep`
25
26 if [ ! -z "$checkString" ]
27 then
28 if [ -f /sbin/init.d/firebird ]
29 then
30 /sbin/init.d/firebird stop
31 fi
32 fi
33 }
34
35 #------------------------------------------------------------------------
36 # stop server if it is running
37
38
39 checkIfServerRunning() {
40
41
42 stopServerIfRunning
43
44
45 checkString=`ps -ef | egrep "(fbserver|fbguard)" |grep -v grep`
46
47 if [ ! -z "$checkString" ]
48 then
49 echo "An instance of the Firebird SuperServer seems to be running."
50 echo "(the fbserver/fbguard process was detected running on your system)"
51 echo "Please quit all Firebird applications and then proceed"
52 exit -1
53 fi
54
55
56
57 checkString=`ps -ef | egrep "(fb_inet_server|fb_smp_server)" |grep -v grep`
58
59 if [ ! -z "$checkString" ]
60 then
61 echo "An instance of the Firebird Classic server seems to be running."
62 echo "Please quit all interbase applications and then proceed."
63 exit 1
64 fi
65
66
67
68 # Stop lock manager if it is the only thing running.
69
70 for i in `ps -ef | egrep "fb_lock_mgr" | awk '{print $2}' `
71 do
72 kill $i
73 done
74
75
76 }
77
78
79 #------------------------------------------------------------------------
80 # Run process and check status
81
82
83 runAndCheckExit() {
84 Cmd=$*
85
86 # echo $Cmd
87 $Cmd
88
89 ExitCode=$?
90
91 if [ $ExitCode -ne 0 ]
92 then
93 echo "Install aborted: The command $Cmd "
94 echo " failed with error code $ExitCode"
95 exit $ExitCode
96 fi
97 }
98
99
100 #------------------------------------------------------------------------
101 # Display message if this is being run interactively.
102
103
104 displayMessage() {
105
106 msgText=$1
107 if [ ! -z "$InteractiveInstall" ]
108 then
109 echo $msgText
110 fi
111 }
112
113
114 #------------------------------------------------------------------------
115 # Archive any existing prior installed files.
116 # The 'cd' stuff is to avoid the "leading '/' removed message from tar.
117 # for the same reason the DestFile is specified without the leading "/"
118
119
120 archivePriorInstallSystemFiles() {
121
122 oldPWD=`pwd`
123 archiveFileList=""
124
125 cd /
126
127 DestFile=${FBRootDir#/} # strip off leading /
128 if [ -e "$DestFile" ]
129 then
130 echo ""
131 echo ""
132 echo ""
133 echo "--- Warning ----------------------------------------------"
134 echo " The installation target directory: $FBRootDir"
135 echo " Already contains a prior installation of Firebird."
136 echo " This and files found in /usr/include and @libdir@ will be"
137 echo " archived in the file : ${ArchiveMainFile}"
138 echo ""
139
140 if [ ! -z "$InteractiveInstall" ]
141 then
142 AskQuestion "Press return to continue or ^C to abort"
143 fi
144
145 if [ -e $DestFile ]
146 then
147 archiveFileList="$archiveFileList $DestFile"
148 fi
149 fi
150
151
152 for i in ibase.h ib_util.h
153 do
154 DestFile=usr/include/$i
155 if [ -e $DestFile ]
156 then
157 archiveFileList="$archiveFileList $DestFile"
158 fi
159 done
160
161 for i in libib_util.so libfbclient.so.1.5.0 libfbclient.so.1 libfbclient.so
162 do
163 DestFile=usr/lib/$i
164 if [ -e $DestFile ]
165 then
166 archiveFileList="$archiveFileList $DestFile"
167 fi
168 done
169
170 if [ ! -z "$archiveFileList" ]
171 then
172
173 displayMessage "Archiving..."
174
175 runAndCheckExit "tar -cvf $ArchiveMainFile $archiveFileList"
176
177
178 displayMessage "Done."
179 displayMessage "Deleting..."
180
181 for i in $archiveFileList
182 do
183 rm -rf $i
184 done
185
186 displayMessage "Done."
187
188 fi
189 cd $oldPWD
190
191 }
192
193
194
195 #== Main Pre =================================================================
196
197 ArchiveDateTag=`date +"%Y%m%d_%H%M"`
198 ArchiveMainFile="${FBRootDir}_${ArchiveDateTag}.tar"
199
200 # Ok so any of the following packages are a problem
201 # these don't work at least in the latest rpm manager, since it
202 # has the rpm database locked and it fails.
203
204 # checkForRPMInstall InterBase
205 # checkForRPMInstall FirebirdCS
206 # checkForRPMInstall FirebirdSS
207
208
209 checkIfServerRunning
210
211
212 # Failing that we archive any files we find
213
214 archivePriorInstallSystemFiles
215