#!/bin/bash #set default privileges to -rw-r----- umask 027 set -a if [ -r "/etc/default/<%= EZBake::Config[:project] -%>" ] ; then . /etc/default/<%= EZBake::Config[:project] %> elif [ -r "/etc/sysconfig/<%= EZBake::Config[:project] -%>" ] ; then . /etc/sysconfig/<%= EZBake::Config[:project] %> elif [ `uname` == "OpenBSD" ] ; then JAVA_BIN=$(javaPathHelper -c <%= EZBake::Config[:project] %>) JAVA_ARGS="<%= EZBake::Config[:java_args] %>" TK_ARGS="<%= EZBake::Config[:tk_args] %>" USER="_<%= EZBake::Config[:user] %>" INSTALL_DIR="/opt/puppetlabs/server/apps/<%= EZBake::Config[:project] %>" CONFIG="/etc/puppetlabs/<%= EZBake::Config[:project] %>/conf.d" else echo "You seem to be missing some important configuration files; could not find /etc/default/<%= EZBake::Config[:project] -%> or /etc/sysconfig/<%= EZBake::Config[:project] -%>" >&2 exit 1 fi set +a CLI_DIR="${INSTALL_DIR}/cli" CLI_APP_DIR="${CLI_DIR}/apps" APPS=`ls ${CLI_APP_DIR} 2>/dev/null` ############# # FUNCTIONS # ############# # Display usage then exit function usage { if [ "$APPS" == "" ]; then echo "ERROR: No sub-commands found in ${CLI_APP_DIR}" exit 1 fi cat < [] The most commonly used <%= EZBake::Config[:real_name] %> commands are: EOD # Iterate and display commands in the CLI_APP_DIR for f in $APPS; do echo " $f" done cat << EOD See '$(basename $0) -h' for more information on a specific command. EOD exit 0 } function show_version { cat < version: <%= Pkg::Config.version %> EOD exit 0 } # Execute the subcommand if available. # # $1 - subcommand # $n - arguments # # Example: # # execsubcommand export -o test.dump -H 1.1.1.1 # function execsubcommand { sub=$1 shift cmd="${CLI_APP_DIR}/${sub}" if [ -e ${cmd} ]; then exec "${cmd}" "$@" else echo "<%= EZBake::Config[:real_name] %>: '${sub}' is not a <%= EZBake::Config[:real_name] %> command. See '$(basename $0) --help'." fi } ######## # MAIN # ######## if [ -z $1 ] || [ $1 = "--help" ] || [ $1 = "-h" ]; then usage fi if [ $1 = "--version" ] || [ $1 = "-v" ]; then show_version fi execsubcommand "$@"