caddy_install () { local target local dir="$(dirname $(realpath "${BASH_SOURCE:-$0}"))" target=${1:-/opt/caddy} [[ -d $target ]] || mkdir -p $target echo installing caddy to $target if /bin/cp -r -f $dir/caddy/* $target; then pushd $target || return echo CADDY_DIR=$target >> .env source .env cp conf/example.conf conf/$CONF ./config else echo unable to copy caddy files to $target, install aborted fi popd || return } # if script was executed then call the function (return 0 2>/dev/null) || caddy_install $@