Autostarting InterBase/Firebird on Linux

by Jorge Alvarez

Here's what I do under Linux Mandrake. It should do the trick under Red Hat too.

  1. copy the script below as 'ibserver' to /etc/rc.d/init.d
  2. cd to this directory and chmod 700 ibserver
  3. cd /etc/rc.d/rc3.d
  4. ln -s /etc/rc.d/init.d/ibserver S86ibserver
  5. ln -s /etc/rc.d/init.d/ibserver K40ibserver

InterBase should start next time you reboot your Linux server.

Here's the script:

#!/bin/sh
# file name ibserver
# ibserver script - Start/stop the InterBase daemon
# Set these environment variables if and only if they are not set.
: ${INTERBASE:=/opt/interbase}
: ${ISC_USER:=SYSDBA}
: ${ISC_PASSWORD:=masterkey}
# WARNING: in a real-world installation, you should not put the
# SYSDBA password in a publicly-readable file. To protect it:
# chmod 700 ibserver.sh; chown root ibserver.sh
export INTERBASE
export ISC_USER
export ISC_PASSWORD
ibserver_start()
{
 # This example assumes the InterBase server is
 # being started as UNIX user ¡¯interbase¡¯.
 echo '$INTERBASE/bin/ibmgr -start -forever' | su root
}
ibserver_stop()
{
 # No need to su, since $ISC_USER and $ISC_PASSWORD validate us.
 $INTERBASE/bin/ibmgr -shut -password $ISC_PASSWORD
}
case $1 in
 'start') ibserver_start ;;
 'start_msg') echo 'InterBase Server starting...c' ;;
 'stop') ibserver_stop ;;
 'stop_msg') echo 'InterBase Server stopping...c' ;;
 *) echo 'Usage: $0 { start | stop }' ; exit 1 ;;
esac
exit 0