#!/bin/sh

### BEGIN INIT INFO
# Provides:          firebird2.5-classic
# Required-Start:    $remote_fs $syslog
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Initialise firebird directory inder /var/run
# Description:       Creates /var/run/firebird/2.5 and sets appropriate
#                    ownership/permissions
#                    Does not start any service, but required by firebird
#                    classic-server variant if /var/run is mounted on tmpfs
### END INIT INFO


# Source LSB function library.
. /lib/lsb/init-functions

set -u

FB_VER="2.5"
FB_FLAVOUR="classic"

FUNCTIONS="/usr/share/firebird${FB_VER}-common/functions.sh"
[ -e "$FUNCTIONS" ] || exit 0
. "$FUNCTIONS"

# Check the manager is there and is executable.
SERVER=/usr/sbin/fb_inet_server
[ -x $SERVER ] || exit 0

# workaround of splashy's #400598
# define RUNLEVEL to avoid unbound variable error
RUNLEVEL=${RUNLEVEL:-}


# See how we were called.
case "${1:-}" in
    start|restart|force-reload)
    log_action_begin_msg "Preparing $RUN"
    create_var_run_firebird
    RETVAL=$?
    log_action_end_msg $RETVAL
    ;;

    stop)
    RETVAL=0
    ;;

    status)
    RETVAL=0
    ;;

    *)
    echo "Usage: firebird {start|stop|restart|force-reload}"
    RETVAL=2
    ;;
esac

exit $RETVAL
