#!/bin/bash -x
#
# Installs app if not already installed
. /etc/federated
. /federated/lib/functions.sh
trap cleanup `seq 1 15`

usage() {
cat << EOF
Install application
Usage: $0 appname
Arguments:
    appname         Application to install. bookstack,espocrm,freescout,etc

EOF
exit 2;
}

[ $# != 1 ] && usage
APP=$1

[ ! -f /federated/lib/$APP.sh ] && failcheck "/federated/lib/$APP.sh doesn't exist."
[ -d /federated/apps/$APP ] && failcheck "/federated/apps/$APP already exists. $APP is installed?"
. /federated/lib/$APP.sh
config_$APP
start_$APP
email_$APP
