aboutsummaryrefslogtreecommitdiffstats
path: root/databases/firebird2-server/pkg-install
blob: e716ae8fa917671a6f326b6f1617218b64d1cccb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/sh

# $FreeBSD$

PATH=/bin:/usr/bin:/usr/sbin

case $2 in
PRE-INSTALL)

if [ `id -u` -ne 0 ]; then
    echo; echo "You must be root to run this step!"; echo; echo
  exit 1
fi

nofbuid=0
fbUID=`id -u firebird 2>/dev/null`
if [ $? -ne 0 ]; then
    fbUID=90
    while [ ! -z `id -un $fbUID 2>/dev/null` ]
    do
        fbUID=$(($fbUID+1))
    done
    nofbuid=1
fi

fbGID=`pw groupshow firebird 2>/dev/null`
if [ $? -ne 0 ]; then
    fbGID=90
    while [ ! -z `id -gn $fbGID 2>/dev/null` ]
    do
        fbGID=$(($fbGID+1))
    done
    echo "firebird:*:$fbGID:" >> /etc/group
else
    fbGID=`echo $fbGID | awk -F: '{print $3}'`
fi

echo "firebird user using uid $fbUID"
echo "firebird user using gid $fbGID"

if which -s pw; then
    if [ $nofbuid -ne 0 ]; then
        pw useradd firebird -u $fbUID -g $fbGID -h - -s /bin/sh \
        -d $PKG_PREFIX/firebird -c "Firebird Database Administrator"
    fi
else
    echo -n "unable to create user firebird - please create it manually,"
    echo " before reinstalling this package."
    exit 1
fi
;;

POST-INSTALL)
chown -R firebird:firebird $PKG_PREFIX/firebird
chmod -R o= $PKG_PREFIX/firebird

# Now fix up the mess.

# fix up directories
for i in `find $PKG_PREFIX/firebird -print`
do
    FileName=$i
    if [ -d $FileName ]; then
        chmod u=rwx,go=rx $FileName
    fi
done

# make lib ldconfig-compatible
chown -R root:wheel $PKG_PREFIX/firebird/lib

# make the following read-only
chmod -R a=r $PKG_PREFIX/firebird/WhatsNew
for i in `find $PKG_PREFIX/firebird/doc -type f -print`
do
    chmod a=r $i
done
chmod -R a=r $PKG_PREFIX/firebird/examples/*
chmod -R a=r $PKG_PREFIX/firebird/include/*
chmod -R a=r $PKG_PREFIX/firebird/intl/*
#chmod -R a=r $PKG_PREFIX/firebird/misc/*

chmod -R ug=rx,o= $PKG_PREFIX/firebird/UDF/*
chmod -R ug=rx,o= $PKG_PREFIX/firebird/intl/fbintl
chmod -R a=rx $PKG_PREFIX/firebird/lib/*

cd $PKG_PREFIX/firebird/lib
ln -sf libfbembed.so libgds.so
ln -sf libfbembed.so.1 libgds.so.1

cd $PKG_PREFIX/firebird/bin
for i in `ls`
do
    chmod ug=rx,o= $i
done

chmod a=rx isql qli

# SUID is needed for running server programs.
for i in fb_lock_mgr gds_drop fb_inet_server
do
    if [ -f $i ]; then
        chmod ug=rx,o= $i
        chmod ug+s $i
    fi
done


cd $PKG_PREFIX/firebird

# Lock files

for i in isc_init1 isc_lock1 isc_event1
do
    FileName=$i.`hostname`
    touch $FileName
    chmod uga=rw $FileName
    chown firebird:firebird $FileName
done

touch firebird.log
chown firebird:firebird firebird.log
chmod ug=rw,o= firebird.log
chmod a=r firebird.msg README
chown root:wheel *.sample
chmod ug=r,o= *.sample

# make databases writable by firebird only
# local database connections are not a good idea
chmod ug=rw,o= examples/*.fdb
chmod ug=rw,o= help/*.fdb
chmod ug=rw,o= security.fdb

chmod 444 aliases.conf firebird.conf
chmod 660 security.fdb

# shared lib startup script
if [ -d $PKG_PREFIX/etc/rc.d ]; then
    (
    echo "#!/bin/sh"; echo "[ -d $PKG_PREFIX/firebird/lib ] && /sbin/ldconfig -m $PKG_PREFIX/firebird/lib"
    ) > $PKG_PREFIX/etc/rc.d/000.firebird.sh
  chmod a=rx $PKG_PREFIX/etc/rc.d/000.firebird.sh
fi
;;

esac