Debian Codegraph @

builds/install/arch-specific/netbsd/install.sh.in

raw
1 #!/bin/sh
2 #
3 # This library is part of the FirebirdSQL project
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 # You may obtain a copy of the Licence at
10 # http://www.gnu.org/licences/lgpl.html
11 #
12 # As a special exception this file can also be included in modules
13 # with other source code as long as that source code has been
14 # released under an Open Source Initiative certificed licence.
15 # More information about OSI certification can be found at:
16 # http://www.opensource.org
17 #
18 # This module is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU Lesser General Public Licence for more details.
22 #
23 # This module was created by members of the firebird development
24 # team. All individual contributions remain the Copyright (C) of
25 # those individuals and all rights are reserved. Contributors to
26 # this file are either listed below or can be obtained from a CVS
27 # history command.
28 #
29 # Created by: Chris Knight <[email protected]>
30 #
31 # Contributor(s):
32 # James K. Lowden <[email protected]>
33 #
34 #
35
36 # Install script for FirebirdSQL database engine
37
38 #------------------------------------------------------------------------
39
40 #
41 # Copy file if it exists
42 #
43 copyIfExists() {
44 OldFile=$1
45 NewFile=$2
46
47 if [ -f $OldFile ]
48 then
49 cp $OldFile $NewFile
50 fi
51
52 }
53
54 InstallFirebirdPrefix=@prefix@
55 InstallPrefix=${InstallFirebirdPrefix%/firebird}
56 unset InstallFirebirdPrefix
57
58 if [ -d @prefix@ ]; then
59 echo Backing up @prefix@ to $InstallPrefix/firebird.old
60 if [ -d $InstallPrefix/firebird.old ]; then
61 rm -rf $InstallPrefix/firebird.old
62 fi
63 cp -Rp @prefix@ $InstallPrefix/firebird.old
64 fi
65
66 if [ `id -u` -ne 0 ]; then
67 echo; echo "You must be root to run this step!"; echo; echo
68 exit 1
69 fi
70
71 #
72 # Establish the values of the Firebird user and group ids
73 #
74 echo Establishing user 'firebird'
75 fbGID=0
76 if ! groupinfo -e firebird; then # create the group
77 fbGID=90
78 while [ ! -z `id -gn $fbGID 2>/dev/null` ]
79 do
80 fbGID=$(($fbGID+1))
81 done
82 # Create the Firebird group
83 groupadd -v -g $fbGID firebird
84 else
85 fbGID=$(groupinfo firebird |grep ^gid |awk '{print $2}')
86 fi
87
88 # make sure we have the group
89 groupinfo -e firebird
90 if [ $? -eq 0 -a $fbGID -ne 0 ]; then
91 echo "user 'firebird' has gid $fbGID".
92 else
93 echo "Unable to create group 'firebird' - please create it manually."
94 echo "You might also wish to create the 'firebird' user at this time, as well."
95 exit 1
96 fi
97
98 #
99 # Create the Firebird user, if not extant
100 #
101 fbUID=0
102 if ! userinfo -e firebird; then # create the user
103 fbUID=90
104 while [ ! -z `id -un $fbUID 2>/dev/null` ]
105 do
106 fbUID=$(($fbUID+1))
107 done
108 if [ ! -d @prefix@ ]; then
109 $m=-m
110 fi
111 useradd -v -u $fbUID -g $fbGID -s /bin/sh \
112 $m -d @prefix@ \
113 -c "Firebird Database Administrator" \
114 firebird
115 else
116 fbUID=`id -u firebird 2>/dev/null`
117 fi
118
119 # Make sure we have the user.
120 userinfo -e firebird
121 if [ $? -eq 0 -a $fbUID -ne 0 ]; then
122 echo "user 'firebird' has uid $fbUID".
123 else
124 echo "Unable to create user 'firebird' - please create it manually."
125 exit 1
126 fi
127
128 # Making an assumption that this program is being run in the gen directory
129 BuildRootDir=..
130 BuiltFBDir=./firebird # Location of the just-built fb.
131 DestDir=@prefix@
132
133 # The guts of the tranfer of files and other directories
134 # (mkdir -p <dirname> does not elicit an error message if the <dirname> exists.)
135 echo Installing binaries
136 for D in "bin examples help include intl doc/sql.extensions UDF"
137 do
138 mkdir -p $DestDir/$D || exit
139 done
140
141 cp -f $BuiltFBDir/bin/fb_inet_server $DestDir/bin/fb_smp_server || exit
142 cp $BuiltFBDir/bin/gbak $DestDir/bin/gbak || exit
143 cp $BuiltFBDir/bin/gds_drop $DestDir/bin/gds_drop || exit
144 copyIfExists $BuiltFBDir/bin/fb_lock_mgr $DestDir/bin/fb_lock_mgr || exit
145 copyIfExists $BuiltFBDir/bin/fb_lock_print $DestDir/bin/fb_lock_print || exit
146 copyIfExists $BuiltFBDir/bin/gds_pipe $DestDir/bin/gds_pipe || exit
147 cp $BuiltFBDir/bin/gfix $DestDir/bin/gfix || exit
148 cp $BuiltFBDir/bin/gpre $DestDir/bin/gpre || exit
149 cp $BuiltFBDir/bin/gsec $DestDir/bin/gsec || exit
150 copyIfExists $BuiltFBDir/bin/gsplit $DestDir/bin/gsplit || exit
151 cp $BuiltFBDir/bin/gstat $DestDir/bin/gstat || exit
152 copyIfExists $BuiltFBDir/bin/isc4.gbak $DestDir/bin/isc4.gbk || exit
153 cp $BuiltFBDir/bin/isql $DestDir/bin/isql || exit
154 cp $BuiltFBDir/bin/qli $DestDir/bin/qli || exit
155
156 # Copy examples only if we have them
157 exampleFiles=`find $BuiltFBDir/examples/ -type f -print`
158 if [ -z "$exampleFiles" ]; then
159 echo "Example files have not been built!"
160 else
161 echo Installing examples
162 for i in $exampleFiles
163 do
164 cp $i $DestDir/examples || exit
165 done
166 fi
167
168 copyIfExists $BuiltFBDir/help/help.gbak $DestDir/help || exit
169 cp $BuiltFBDir/help/help.fdb $DestDir/help || exit
170
171 cp $BuiltFBDir/firebird.msg $DestDir/firebird.msg || exit
172 cp $BuiltFBDir/security2.fdb $DestDir/security2.fdb.sample || exit
173
174 cp $BuiltFBDir/include/*.h $DestDir/include || exit
175
176 cp -Rf $BuiltFBDir/lib/libfbembed.so* $DestDir/lib || exit
177 cp -Rf $BuiltFBDir/lib/libfbclient.so* $DestDir/lib || exit
178
179 cp -f $BuiltFBDir/lib/libib_util.so $DestDir/lib/libib_util.so || exit
180
181 cp $BuiltFBDir/intl/libfbintl.so $DestDir/intl/fbintl || exit
182
183 # Note that this copies files from outside the build tree.
184 echo Installing documentation
185 cp $BuildRootDir/doc/README.* $DestDir/doc || exit
186 cp $BuildRootDir/*.md $DestDir || exit
187
188 SQLEXTENSIONS=`find $BuildRootDir/doc/sql.extensions ! -type d | grep -v CVS`
189 cp ${SQLEXTENSIONS} $DestDir/doc/sql.extensions || exit
190
191 cp $BuiltFBDir/misc/firebird.conf $DestDir/firebird.conf.sample || exit
192
193 echo "#" >> $DestDir/databases.conf.sample
194 echo "# List of known database aliases" >> $DestDir/databases.conf.sample
195 echo "# ------------------------------" >> $DestDir/databases.conf.sample
196 echo "#" >> $DestDir/databases.conf.sample
197 echo "# Examples:" >> $DestDir/databases.conf.sample
198 echo "#" >> $DestDir/databases.conf.sample
199 echo "# employee = /$DestDir/examples/employee.fdb" >> $DestDir/databases.conf.sample
200 echo "#" >> $DestDir/databases.conf.sample
201
202
203 echo Setting ownership and permissions on installed files
204
205 chown -R firebird:firebird @prefix@ || exit
206 chmod -R o= @prefix@ || exit
207
208 # Now fix up the mess.
209
210 # fix up directories
211 for i in `find @prefix@ -print`
212 do
213 FileName=$i
214 if [ -d $FileName ]; then
215 chmod u=rwx,go=rx $FileName || exit
216 fi
217 done
218
219 # make lib ldconfig-compatible
220 chown -R root:wheel @prefix@/lib || exit
221
222 # make the following read-only
223 chmod -R a=r @prefix@/*.md || exit
224 for i in `find @prefix@/doc -type f -print`
225 do
226 chmod a=r $i || exit
227 done
228
229 chmod -R a=r @prefix@/include/* || exit
230 chmod -R a=r @prefix@/intl/* || exit
231
232 chmod -R ug=rx,o= @prefix@/UDF/* || exit
233 chmod -R ug=rx,o= @prefix@/intl/fbintl || exit
234 chmod -R a=rx @prefix@/lib/* || exit
235
236
237 cd @prefix@/bin
238 for i in `ls`
239 do
240 chmod ug=rx,o= $i || exit
241 done
242
243 chmod a=rx isql qli
244
245 # SUID is needed for running server programs.
246 for i in fb_lock_mgr gds_drop fb_smp_server
247 do
248 if [ -f $i ]; then
249 chmod ug=rx,o= $i || exit
250 chmod ug+s $i || exit
251 fi
252 done
253
254
255 cd @prefix@
256
257 # Lock files
258
259 for i in fb_guard
260 do
261 FileName=$i
262 touch $FileName
263 chmod ug=rw,o= $FileName || exit
264 chown firebird:firebird $FileName || exit
265 done
266
267 touch firebird.log
268 chown firebird:firebird firebird.log || exit
269 chmod ug=rw,o= firebird.log || exit
270 chmod a=r firebird.msg README || exit
271 chown root:wheel *.sample || exit
272 chmod ug=r,o= *.sample || exit
273
274 # make databases writable by firebird only
275 # local database connections are not a good idea
276 chmod ug=rw,o= examples/*.fdb || exit
277 chmod ug=rw,o= help/*.fdb || exit
278
279 # install the samples if they don't exist
280 [ -f databases.conf ] || install -o firebird -g firebird -m 440 databases.conf.sample databases.conf
281 [ -f firebird.conf ] || install -o firebird -g firebird -m 440 firebird.conf.sample firebird.conf
282 [ -f security2.fdb ] || install -o firebird -g firebird -m 660 security2.fdb.sample security2.fdb
283
284 #
285 # add the gds service, if need be, and restart inetd
286 #
287 if ! grep ^@FB_SERVICE_NAME@ /etc/services
288 then
289 echo Adding Firebird Database Remote Protocol to /etc/services
290 cat >>/etc/services <<EOF
291 @FB_SERVICE_NAME@ @FB_SERVICE_PORT@/tcp #Firebird Database Remote Protocol
292 EOF
293 fi
294
295 if ! grep ^@FB_SERVICE_NAME@ /etc/inetd.conf
296 then
297 echo Adding firebird to /etc/inetd.conf
298 cat >>/etc/inetd.conf <<EOF
299 @FB_SERVICE_NAME@ stream tcp nowait firebird @prefix@/bin/fb_smp_server fb_smp_server
300 EOF
301 fi
302
303 if [ -f /var/run/inetd.pid ]
304 then
305 echo Reloading inetd
306 /etc/rc.d/inetd reload
307 fi
308
309 # shared lib startup script
310 if [ -d $InstallPrefix/etc/rc.d ]
311 then
312 echo Installing $InstallPrefix/etc/rc.d/000.firebird.sh
313 (
314 echo "#! /bin/sh"; echo "[ -d @prefix@/lib ] && /sbin/ldconfig -m @prefix@/lib"
315 ) > $InstallPrefix/etc/rc.d/000.firebird.sh
316 chmod a=rx $InstallPrefix/etc/rc.d/000.firebird.sh
317 fi
318
319 echo Done installing Firebird