#!/bin/sh

### BEGIN INIT INFO
# Provides:          omniorb-bindings
# Required-Start:    $local_fs $remote_fs $network omniorb-nameserver
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Sets bindings for OmniOrb
# Description:       Sets bindings for OmniOrb  
### END INIT INFO

do_bind () {
    environment=$(cat /etc/yandex/environment.type) 
    if [[ $environment != "development" && $environment != "testing" && $environment != "production" ]]; then
	environment=default
    fi
    cat /etc/omniorb-bindings/${environment}/* | sed 's/;/\n/g' | sed 's/&/\n/g' | egrep '(nameclt|echo|rebind)' | /bin/bash
}

case "$1" in
  start|restart)
	echo "Binding:"
	do_bind
	;;

  stop)
	echo stopping
	;;

  *)
	echo "Use $0 start or $0 restart to apply bindings"
	;;

esac

exit 0
