updated on Mon Jan 16 20:00:43 UTC 2012
[aur-mirror.git] / firebird-superserver / firebird
blobb9c3e95f91afe01e00bd5d22836192f3024bf4d4
1 #!/bin/bash
3 # description: Start/Stop firebird database server
5 # To run more instances of firebird:
6 # Copy /opt/firebird somewhere
7 # Copy this script under a new name
8 # Change INSTANCE and FIREBIRD below (all instance names should be unique)
9 # Edit the copied firebird.conf to change at least RemoteServicePort
11 . /etc/rc.conf
12 . /etc/rc.d/functions
14 INSTANCE=default
15 FIREBIRD=/opt/firebird
16 DAEMON_NAME=`basename $0`
18 # No changes needed below for multiple instances
19 FBRunUser=firebird
21 makeFbDir() {
22 mDir=${1}
23 mode=${2}
24 if [ ! -d $mDir ]; then
25 rm -rf $mDir
26 mkdir $mDir
27 if [ "$mode" ]; then
28 chmod $mode $mDir
31 chown $FBRunUser:$FBRunUser $mDir
33 runDir=/var/run/firebird
34 makeFbDir $runDir
35 lockDir=/tmp/firebird
36 makeFbDir $lockDir 0770
38 pidfile="$runDir/$INSTANCE.pid"
39 FULLNAME="Firebird server [$INSTANCE]"
40 LD_LIBRARY_PATH=$FIREBIRD/lib
42 export FIREBIRD LD_LIBRARY_PATH
44 GUARDIAN=$FIREBIRD/bin/fbguard
45 if [ ! -x $GUARDIAN ]; then
46 GUARDIAN=/opt/firebird/bin/fbguard
49 # See how we were called.
50 case "$1" in
51 start)
52 stat_busy "Starting $FULLNAME"
53 echo "$GUARDIAN -pidfile $pidfile -daemon -forever" | su -s /bin/sh $FBRunUser
54 #su $FBRunUser "$GUARDIAN -pidfile $pidfile -daemon -forever"
55 RETVAL=$?
56 if [ $RETVAL -gt 0 ]; then
57 stat_fail
58 else
59 add_daemon $DAEMON_NAME
60 stat_done
63 stop)
64 stat_busy "Stopping $FULLNAME"
65 RETVAL=1
66 if [ -f $pidfile ]; then
67 kill `cat $pidfile`
68 RETVAL=$?
70 if [ $RETVAL -gt 0 ]; then
71 stat_fail
72 else
73 rm_daemon $DAEMON_NAME
74 stat_done
77 status)
78 if [ -f $pidfile ]
79 then
80 pid=`cat $pidfile`
81 ps -p $pid >/dev/null 2>&1
82 RETVAL=$?
83 else
84 RETVAL=1
86 if [ $RETVAL -eq 0 ]
87 then
88 echo "$FULLNAME is running, pid $pid"
89 else
90 echo "$FULLNAME is stopped."
93 restart|reload)
94 $0 stop
95 sleep 1
96 $0 start
99 echo "Usage: firebird {start|stop|status|restart|reload}"
100 exit 1
101 esac
103 exit 0