# -*- mode: shell-script -*-
# Configuration file that is supposed to be sourced into bash scripts.

DEFAULT_PREFIX="{{prefix}}"
DEFAULT_PREFIX="${DEFAULT_PREFIX:-/opt/cfengine/federation/}"

WORKDIR="{{workdir}}"
WORKDIR="${WORKDIR:-/var/cfengine/}"

# generic configuration
CFE_BIN_DIR="{{bindir}}"
CFE_BIN_DIR="${CFE_BIN_DIR:-/var/cfengine/bin}"
CFE_FR_SED_ARGS="{{sed_args}}" # no extra args by default
CFE_FR_AWK_ARGS="{{awk_args}}" # no extra args by default
CFE_VERSION="{{cf_version}}"

# specific feeder name
CFE_FR_FEEDER="{{feeder}}"
CFE_FR_FEEDER="${CFE_FR_FEEDER:-$(hostname)}"

# tables to dump and import
DEFAULT_TABLES="__agentstatus
__contexts
__hosts
__filechangeslog
__lastseenhosts
__software
__softwareupdates
__variables
__benchmarkslog
__contextslog
__promiseexecutions
__promiselog_*
__inventory
contextcache"
CFE_FR_TABLES="{{tables}}"
CFE_FR_TABLES="${CFE_FR_TABLES:-$DEFAULT_TABLES}"

# dump phase
CFE_FR_COMPRESSOR="{{compressor}}"
CFE_FR_COMPRESSOR="${CFE_FR_COMPRESSOR:-gzip}"
CFE_FR_COMPRESSOR_ARGS="{{compressor_args}}" # no extra args by default
CFE_FR_COMPRESSOR_EXT="{{compressor_ext}}"
CFE_FR_COMPRESSOR_EXT="${CFE_FR_COMPRESSOR_EXT:-gz}"
CFE_FR_DECOMPRESS_ARGS="{{decompress_args}}"
CFE_FR_DECOMPRESS_ARGS="${CFE_FR_DECOMPRESS_ARGS:--d -c}"
CFE_FR_DUMP_DIR="{{dump_dir}}"
CFE_FR_DUMP_DIR="${CFE_FR_DUMP_DIR:-$DEFAULT_PREFIX/fedhub/dump}"
CFE_FR_DUMP_FILTERS_DIR="{{dump_filters_dir}}"
CFE_FR_DUMP_FILTERS_DIR="${CFE_FR_DUMP_FILTERS_DIR:-$DEFAULT_PREFIX/fedhub/dump/filters}"

# transport phase
CFE_FR_FEEDER_USERNAME="{{feeder_username}}"
CFE_FR_FEEDER_USERNAME="${CFE_FR_FEEDER_USERNAME:-cftransport}"
CFE_FR_SUPERHUB_DROP_DIR="{{drop_dir}}"
CFE_FR_SUPERHUB_DROP_DIR="${CFE_FR_SUPERHUB_DROP_DIR:-$DEFAULT_PREFIX/$CFE_FR_FEEDER_USERNAME/destination}"
CFE_FR_SUPERHUB_IMPORT_DIR="{{import_dir}}"
CFE_FR_SUPERHUB_IMPORT_DIR="${CFE_FR_SUPERHUB_IMPORT_DIR:-$DEFAULT_PREFIX/superhub/import}"
CFE_FR_SUPERHUB_LOGIN="{{login}}"
CFE_FR_SUPERHUB_LOGIN="${CFE_FR_SUPERHUB_LOGIN:-cftransport@superhub}"
CFE_FR_SUPERHUB_HOSTKEYS="{{superhub_hostkeys}}"
CFE_FR_THIS_HOSTKEY="{{this_hostkey}}"
CFE_FR_TRANSPORT_DIR="{{transport_dir}}"
CFE_FR_TRANSPORT_DIR="${CFE_FR_TRANSPORT_DIR:-$DEFAULT_PREFIX/$CFE_FR_FEEDER_USERNAME/source}"
CFE_FR_TRANSPORTER="{{transporter}}"
CFE_FR_TRANSPORTER="${CFE_FR_TRANSPORTER:-/var/cfengine/bin/rsync}"
CFE_FR_TRANSPORTER_ARGS="{{transporter_args}}"
CFE_FR_TRANSPORTER_ARGS="${CFE_FR_TRANSPORTER_ARGS:--av --rsync-path=$CFE_BIN_DIR/rsync}"
CFE_FR_SSH="{{ssh}}"
CFE_FR_SSH="${CFE_FR_SSH:-ssh}"
CFE_FR_SSH_ARGS="{{ssh_args}}" # no extra args by default

# import phase
CFE_FR_EXTRACTOR="{{extractor}}"
CFE_FR_EXTRACTOR="${CFE_FR_EXTRACTOR:-zcat}"
CFE_FR_EXTRACTOR_ARGS="{{extractor_args}}" # no extra args by default
CFE_FR_IMPORT_NJOBS="{{n_jobs}}"           # no explicit limit of jobs by default
                                           # (will use all the CPUs available)
CFE_FR_IMPORT_FILTERS_DIR="{{import_filters_dir}}"
CFE_FR_IMPORT_FILTERS_DIR="${CFE_FR_IMPORT_FILTERS_DIR:-$DEFAULT_PREFIX/superhub/import/filters}"
CFE_FR_INVENTORY_REFRESH_CMD="{{inventory_refresh_cmd}}"
CFE_FR_DB_USER="{{db_user}}"
CFE_FR_DB_USER="${CFE_FR_DB_USER:-cfpostgres}"
CFE_FR_HANDLE_DUPLICATES="{{handle_duplicates}}"   # default is no (don't handle duplicates as it adds to time to import)
CFE_FR_HANDLE_DUPLICATES="${CFE_FR_HANDLE_DUPLICATES:-no}"
CFE_FR_DEBUG_IMPORT="{{debug_import}}" # default is no (don't run imports with debug level logging)
CFE_FR_DEBUG_IMPORT="${CFE_FR_DEBUG_IMPORT:-no}"

# distributed_cleanup dir
CFE_FR_DISTRIBUTED_CLEANUP_DIR="{{distributed_cleanup_dir}}"
CFE_FR_DISTRIBUTED_CLEANUP_DIR="${CFE_FR_DISTRIBUTED_CLEANUP_DIR:-$DEFAULT_PREFIX/$CFE_FR_FEEDER_USERNAME/distributed_cleanup}"
