#!/bin/bash
#
# Copyright:: Copyright (c) 2014 CHEF Software, Inc.
#

# Ensure the calling environment (disapproval look Bundler) does not infect our
# Ruby environment if called from a Ruby script.
for ruby_env_var in RUBYOPT \
                    BUNDLE_BIN_PATH \
                    BUNDLE_GEMFILE \
                    GEM_PATH \
                    GEM_HOME
do
  unset $ruby_env_var
done

# This bumps the default svwait timeout from 7 seconds to 30 seconds
# As documented at http://smarden.org/runit/sv.8.html
export SVWAIT=30

if [ -z "$DELIV_DEV" ];
then
    /opt/delivery/embedded/bin/omnibus-ctl delivery /opt/delivery/embedded/service/omnibus-ctl $@
else
    /opt/delivery/embedded/bin/omnibus-ctl delivery  /mnt/sync/delivery/omnibus/files/ctl-commands $@
fi
