Debian Codegraph @

builds/install/arch-specific/linux/firebird.init.d.debian.in

raw
1 #!/bin/sh
2
3 # chkconfig: 345 80 20
4 # description: Start/Stop firebird database server
5 #
6 # This file belongs in /etc/init.d where it will be run
7 # on system startup and shutdown to start the background
8 # Firebird database server daemon
9
10 ### BEGIN INIT INFO
11 # Provides: firebird
12 # Required-Start: $remote_fs $syslog $named
13 # Required-Stop: $remote_fs
14 # Default-Start: 2 3 4 5
15 # Default-Stop: 0 1 6
16 # Short-Description: Start firebird server
17 # Description: Start the firebird guardian process (fbguard)
18 # which starts the actual firebird server process
19 # (firebird) and makes sure there is always firebird
20 # running
21 ### END INIT INFO
22
23 fb_install_prefix=@prefix@
24
25 # This init script contains functions specific for debian.
26 # Source LSB function library.
27 . /lib/lsb/init-functions
28
29
30 FIREBIRD=@FB_CONFDIR@
31 FBRunUser=firebird
32
33 makeFbDir() {
34 mDir=${1}
35 mode=${2}
36 if [ ! -d $mDir ]; then
37 rm -rf $mDir
38 mkdir $mDir
39 if [ "$mode" ]; then
40 chmod $mode $mDir
41 fi
42 fi
43 chown $FBRunUser:$FBRunUser $mDir
44 }
45 runDir=/var/run/firebird
46 makeFbDir $runDir
47 lockDir=/tmp/firebird
48 makeFbDir $lockDir 0770
49
50 pidfile="$runDir/`basename $0`.pid"
51 FB_OPTS="-pidfile $pidfile -daemon -forever"
52 export FIREBIRD
53
54 ISC_USER=
55 ISC_PASSWORD=
56 export ISC_USER ISC_PASSWORD
57
58 GUARDIAN=$FIREBIRD/bin/fbguard
59 if [ ! -x $GUARDIAN ]; then
60 GUARDIAN=@FB_SBINDIR@/fbguard
61 fi
62
63 # See how we were called.
64 case "$1" in
65 start)
66 printf %s "Starting Firebird server: "
67 start-stop-daemon --start --quiet --oknodo --chuid $FBRunUser --exec $GUARDIAN -- $FB_OPTS
68 RETVAL=$?
69 ;;
70 stop)
71 if pidof $GUARDIAN > /dev/null; then
72 printf %s "Stopping Guardian server: "
73 start-stop-daemon --stop --quiet --oknodo --retry 10 --exec $GUARDIAN
74 fi
75 printf %s "Stopping Firebird server: "
76 if [ -f $pidfile ]
77 then
78 kill `cat $pidfile`
79 fi
80 RETVAL=$?
81 ;;
82 restart|reload)
83 $0 stop
84 $0 start
85 RETVAL=$?
86 ;;
87 shutdown)
88 printf %s "Forcibly killing Firebird server..."
89 killall fbguard
90 killall firebird
91 echo "done."
92 RETVAL=0
93 ;;
94 *)
95 echo "Usage: firebird {start|stop|shutdown|restart|reload}"
96 exit 1
97 esac
98
99 exit $RETVAL