Added
Link Here
|
1 |
#!/bin/sh |
2 |
|
3 |
# $FreeBSD$ |
4 |
|
5 |
PATH=/bin:/usr/bin:/usr/sbin |
6 |
|
7 |
case $2 in |
8 |
PRE-INSTALL) |
9 |
|
10 |
if [ -d $PKG_PREFIX ]; then |
11 |
if [ -d $PKG_PREFIX.old ]; then |
12 |
rm -rf $PKG_PREFIX.old |
13 |
fi |
14 |
cp -Rp $PKG_PREFIX $PKG_PREFIX.old |
15 |
fi |
16 |
|
17 |
if [ `id -u` -ne 0 ]; then |
18 |
echo; echo "You must be root to run this step!"; echo; echo |
19 |
exit 1 |
20 |
fi |
21 |
|
22 |
nofbuid=0 |
23 |
fbUID=`id -u firebird 2>/dev/null` |
24 |
if [ $? -ne 0 ]; then |
25 |
fbUID=90 |
26 |
while [ ! -z `id -un $fbUID 2>/dev/null` ] |
27 |
do |
28 |
fbUID=$(($fbUID+1)) |
29 |
done |
30 |
nofbuid=1 |
31 |
fi |
32 |
|
33 |
fbGID=`pw groupshow firebird 2>/dev/null` |
34 |
if [ $? -ne 0 ]; then |
35 |
fbGID=90 |
36 |
while [ ! -z `id -gn $fbGID 2>/dev/null` ] |
37 |
do |
38 |
fbGID=$(($fbGID+1)) |
39 |
done |
40 |
echo "firebird:*:$fbGID:" >> /etc/group |
41 |
else |
42 |
fbGID=`echo $fbGID | awk -F: '{print $3}'` |
43 |
fi |
44 |
|
45 |
echo "firebird user using uid $fbUID" |
46 |
echo "firebird user using gid $fbGID" |
47 |
|
48 |
if which -s pw; then |
49 |
if [ $nofbuid -ne 0 ]; then |
50 |
pw useradd firebird -u $fbUID -g $fbGID -h - -s /bin/sh \ |
51 |
-d $PKG_PREFIX -c "Firebird Database Administrator" |
52 |
fi |
53 |
else |
54 |
echo -n "unable to create user firebird - please create it manually," |
55 |
echo " before reinstalling this package." |
56 |
exit 1 |
57 |
fi |
58 |
;; |
59 |
|
60 |
POST-INSTALL) |
61 |
chown -R firebird:firebird $PKG_PREFIX |
62 |
chmod -R o= $PKG_PREFIX |
63 |
|
64 |
# Now fix up the mess. |
65 |
|
66 |
# fix up directories |
67 |
for i in `find $PKG_PREFIX -print` |
68 |
do |
69 |
FileName=$i |
70 |
if [ -d $FileName ]; then |
71 |
chmod u=rwx,go=rx $FileName |
72 |
fi |
73 |
done |
74 |
|
75 |
# make lib ldconfig-compatible |
76 |
chown -R root:wheel $PKG_PREFIX/lib |
77 |
|
78 |
# make the following read-only |
79 |
chmod -R a=r $PKG_PREFIX/WhatsNew |
80 |
for i in `find $PKG_PREFIX/doc -type f -print` |
81 |
do |
82 |
chmod a=r $i |
83 |
done |
84 |
#chmod -R a=r $PKG_PREFIX/examples/* |
85 |
chmod -R a=r $PKG_PREFIX/include/* |
86 |
chmod -R a=r $PKG_PREFIX/intl/* |
87 |
#chmod -R a=r $PKG_PREFIX/misc/* |
88 |
|
89 |
chmod -R ug=rx,o= $PKG_PREFIX/UDF/* |
90 |
chmod -R ug=rx,o= $PKG_PREFIX/intl/fbintl |
91 |
chmod -R a=rx $PKG_PREFIX/lib/* |
92 |
|
93 |
#cd $PKG_PREFIX/lib |
94 |
#ln -sf libfbembed.so libgds.so |
95 |
#ln -sf libfbembed.so.2 libgds.so.2 |
96 |
|
97 |
cd $PKG_PREFIX/bin |
98 |
for i in `ls` |
99 |
do |
100 |
chmod ug=rx,o= $i |
101 |
done |
102 |
|
103 |
chmod a=rx isql qli |
104 |
|
105 |
# SUID is needed for running server programs. |
106 |
for i in fb_lock_mgr gds_drop fb_inet_server |
107 |
do |
108 |
if [ -f $i ]; then |
109 |
chmod ug=rx,o= $i |
110 |
chmod ug+s $i |
111 |
fi |
112 |
done |
113 |
|
114 |
|
115 |
cd $PKG_PREFIX |
116 |
|
117 |
# Lock files |
118 |
|
119 |
for i in isc_init1 isc_lock1 isc_event1 |
120 |
do |
121 |
FileName=$i.`hostname` |
122 |
touch $FileName |
123 |
chmod uga=rw $FileName |
124 |
chown firebird:firebird $FileName |
125 |
done |
126 |
|
127 |
touch firebird.log |
128 |
chown firebird:firebird firebird.log |
129 |
chmod ug=rw,o= firebird.log |
130 |
chmod a=r firebird.msg README |
131 |
chown root:wheel *.sample |
132 |
chmod ug=r,o= *.sample |
133 |
|
134 |
# make databases writable by firebird only |
135 |
# local database connections are not a good idea |
136 |
#chmod ug=rw,o= examples/*.fdb |
137 |
chmod ug=rw,o= help/*.fdb |
138 |
chmod ug=rw,o= security2.fdb |
139 |
|
140 |
chmod 444 aliases.conf firebird.conf |
141 |
chmod 660 security2.fdb |
142 |
|
143 |
# remove any existing gds service |
144 |
cp /etc/services /etc/services.old |
145 |
cp /etc/inetd.conf /etc/inetd.conf.old |
146 |
cat /etc/services |grep -v gds_db >/etc/services.new |
147 |
cat /etc/inetd.conf |grep -v gds_db >/etc/inetd.conf.new |
148 |
mv /etc/services.new /etc/services |
149 |
mv /etc/inetd.conf.new /etc/inetd.conf |
150 |
|
151 |
# add the gds service and restart inetd |
152 |
cat >>/etc/services <<EOF |
153 |
gds_db 3050/tcp #InterBase Database Remote Protocol |
154 |
EOF |
155 |
cat >>/etc/inetd.conf <<EOF |
156 |
gds_db stream tcp nowait firebird $PKG_PREFIX/bin/fb_inet_server fb_inet_server |
157 |
EOF |
158 |
if [ -f /var/run/inetd.pid ]; then |
159 |
kill -HUP `cat /var/run/inetd.pid` |
160 |
fi |
161 |
|
162 |
# shared lib startup script |
163 |
if [ -d $PKG_PREFIX/etc/rc.d ]; then |
164 |
( |
165 |
echo "#!/bin/sh"; echo "[ -d $PKG_PREFIX/lib ] && /sbin/ldconfig -m $PKG_PREFIX/lib" |
166 |
) > $PKG_PREFIX/etc/rc.d/000.firebird.sh |
167 |
chmod a=rx $PKG_PREFIX/etc/rc.d/000.firebird.sh |
168 |
fi |
169 |
;; |
170 |
|
171 |
esac |