#!/bin/bash

# description: Start/Stop firebird15 database server
#
# This file belongs in /etc/init.d where it will be run
# on system startup and shutdown to start the background
# Firebird  database Super server daemon 


ISC_USER=SYSDBA
ISC_PASSWORD=masterkey
FBRunUser=firebird
FB=/usr/firebird/bin/fbmgr.bin
#export FB
export ISC_USER
export ISC_PASSWORD
# WARNING: in a real-world installation, you should not put the 
# SYSDBA password in a publicly-readable file. 
# Eventually this file should not need to contain any passwords.
# as root user alone should be sufficient privledge to stop/start 
# the server. 

source /etc/init.d/smgl_functions

PROGRAM=/bin/false
RUNLEVEL=3
NEEDS="+network  +remote_fs"

case $1 in
	start)
		echo "Starting Firebird Super Server"
		mkdir -p /var/run/firebird
		chown firebird:firebird /var/run/firebird
                su -l "$FBRunUser" -s /bin/sh -m -c "$FB -start -forever"
		evaluate_retval
		;;
	stop)
                echo "Stopping Firebird server"
		$FB -shut
		evaluate_retval
                ;;

        restart|reload)
                echo "Restarting Firebird server"
	        $0 stop
        	$0 start
		evaluate_retval
                ;;
        *)
                echo "Usage: $0 {start|stop|restart}"
                exit 1
		;;
esac


