| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# description: Start/Stop firebird database server |
| 4 |
|
| 5 |
fb_install_prefix=@prefix@ |
| 6 |
|
| 7 |
# To run more instances of firebird: |
| 8 |
# Copy @prefix@ somewhere |
| 9 |
# Copy this script under a new name |
| 10 |
# Change INSTANCE and FIREBIRD below (all instance names should be unique) |
| 11 |
# Edit the copied firebird.conf to change at least RemoteServicePort |
| 12 |
INSTANCE=default |
| 13 |
FIREBIRD=@FB_CONFDIR@ |
| 14 |
|
| 15 |
# No changes needed below for multiple instances |
| 16 |
FBRunUser=firebird |
| 17 |
|
| 18 |
makeFbDir() { |
| 19 |
mDir=${1} |
| 20 |
mode=${2} |
| 21 |
if [ ! -d $mDir ]; then |
| 22 |
rm -rf $mDir |
| 23 |
mkdir $mDir |
| 24 |
if [ "$mode" ]; then |
| 25 |
chmod $mode $mDir |
| 26 |
fi |
| 27 |
fi |
| 28 |
chown $FBRunUser:$FBRunUser $mDir |
| 29 |
} |
| 30 |
runDir=/var/run/firebird |
| 31 |
makeFbDir $runDir |
| 32 |
lockDir=/tmp/firebird |
| 33 |
makeFbDir $lockDir 0770 |
| 34 |
|
| 35 |
pidfile="$runDir/$INSTANCE.pid" |
| 36 |
FULLNAME="Firebird server [$INSTANCE]" |
| 37 |
LD_LIBRARY_PATH=$FIREBIRD/lib:$LD_LIBRARY_PATH |
| 38 |
|
| 39 |
export FIREBIRD LD_LIBRARY_PATH |
| 40 |
|
| 41 |
ISC_USER= |
| 42 |
ISC_PASSWORD= |
| 43 |
export ISC_USER ISC_PASSWORD |
| 44 |
|
| 45 |
GUARDIAN=$FIREBIRD/bin/fbguard |
| 46 |
if [ ! -x $GUARDIAN ]; then |
| 47 |
GUARDIAN=@FB_SBINDIR@/fbguard |
| 48 |
fi |
| 49 |
|
| 50 |
# See how we were called. |
| 51 |
case "$1" in |
| 52 |
start) |
| 53 |
printf %s "Starting $FULLNAME: " |
| 54 |
echo "$GUARDIAN -pidfile $pidfile -daemon -forever" | su $FBRunUser |
| 55 |
RETVAL=$? |
| 56 |
;; |
| 57 |
stop) |
| 58 |
printf %s "Stopping $FULLNAME: " |
| 59 |
if [ -f $pidfile ] |
| 60 |
then |
| 61 |
kill `cat $pidfile` |
| 62 |
fi |
| 63 |
echo "stopped." |
| 64 |
RETVAL=$? |
| 65 |
;; |
| 66 |
status) |
| 67 |
if [ -f $pidfile ] |
| 68 |
then |
| 69 |
pid=`cat $pidfile` |
| 70 |
ps -p $pid >/dev/null 2>&1 |
| 71 |
RETVAL=$? |
| 72 |
else |
| 73 |
RETVAL=1 |
| 74 |
fi |
| 75 |
if [ $RETVAL -eq 0 ] |
| 76 |
then |
| 77 |
echo "$FULLNAME is running, pid $pid" |
| 78 |
else |
| 79 |
echo "$FULLNAME is stopped." |
| 80 |
fi |
| 81 |
;; |
| 82 |
restart|reload) |
| 83 |
$0 stop |
| 84 |
sleep 1 |
| 85 |
$0 start |
| 86 |
RETVAL=$? |
| 87 |
;; |
| 88 |
*) |
| 89 |
echo "Usage: firebird {start|stop|status|restart|reload}" |
| 90 |
exit 1 |
| 91 |
esac |
| 92 |
|
| 93 |
exit $RETVAL |
| 94 |
|