Debian Codegraph @

builds/install/arch-specific/linux/firebird.init.d.mandrake.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 ### BEGIN INIT INFO
10 # Provides: firebird
11 # Required-Start: $local_fs $syslog
12 # Required-Stop:
13 # Default-Start: 3 4 5
14 # Default-Stop: 0 1 2 6
15 # Short-Description: Firebird server database
16 # Description: Starts and stops the Firebird database server backend daemon.
17 ### END INIT INFO
18
19 # Source function library - RedHat or Mandriva specific
20 # functions actually used: checkpid killproc daemon
21 . /etc/rc.d/init.d/functions
22
23 fb_install_prefix=@prefix@
24
25 # To run more instances of firebird:
26 # Copy @prefix@ somewhere
27 # Copy this script under a new name
28 # Change at least INSTANCE and FIREBIRD below
29 # Edit the copied firebird.conf to change at least RemoteServicePort
30 # Optionally run chkconfig to autostart the new service
31 INSTANCE=default
32 FIREBIRD=@FB_CONFDIR@
33
34 # No changes needed below for multiple instances
35 name=$(basename `readlink -f $0`)
36 FBRunUser=firebird
37
38 makeFbDir() {
39 mDir=${1}
40 mode=${2}
41 if [ ! -d $mDir ]; then
42 rm -rf $mDir
43 mkdir $mDir
44 if [ "$mode" ]; then
45 chmod $mode $mDir
46 fi
47 fi
48 chown $FBRunUser:$FBRunUser $mDir
49 }
50 runDir=/var/run/firebird
51 makeFbDir $runDir
52 lockDir=/tmp/firebird
53 makeFbDir $lockDir 0770
54
55 pidfile="$runDir/$INSTANCE.pid"
56 FULLNAME="Firebird server [$INSTANCE]"
57 LD_LIBRARY_PATH=$FIREBIRD/lib:$LD_LIBRARY_PATH
58
59 export FIREBIRD LD_LIBRARY_PATH
60
61 ISC_USER=
62 ISC_PASSWORD=
63 export ISC_USER ISC_PASSWORD
64
65 GUARDIAN=$FIREBIRD/bin/fbguard
66 if [ ! -x $GUARDIAN ]; then
67 GUARDIAN=@FB_SBINDIR@/fbguard
68 fi
69
70 # initialize as "success"
71 RETVAL=0
72
73 # See how we were called.
74 case "$1" in
75 start)
76 echo -n "Starting $FULLNAME "
77 daemon --user=$FBRunUser "export FIREBIRD LD_LIBRARY_PATH; $GUARDIAN -pidfile $pidfile -daemon -forever"
78 RETVAL=$?
79 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$name
80 echo
81 ;;
82 stop)
83 if [ -f $pidfile ]
84 then
85 echo -n "Stopping $FULLNAME: "
86 killproc -p $pidfile $name
87 RETVAL=$?
88 echo
89 else
90 echo -n "$FULLNAME server is stopped"
91 echo
92 fi
93 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$name
94 ;;
95 status)
96 if [ -f $pidfile ]
97 then
98 pid=`cat $pidfile`
99 checkpid $pid
100 RETVAL=$?
101 [ $RETVAL -eq 0 ] && echo "$FULLNAME is running (pid $pid)" || echo "$FULLNAME is dead but pid file exists"
102 else
103 echo "$FULLNAME is stopped"
104 RETVAL=3
105 fi
106 ;;
107 restart|reload)
108 $0 stop
109 sleep 1
110 $0 start
111 RETVAL=$?
112 ;;
113 *)
114 echo "Usage: $0 {start|stop|status|restart|reload}"
115 exit 1
116 esac
117
118 exit $RETVAL