Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 2 | ### |
| 3 | # Script source: https://gerrit.mcp.mirantis.com/#/admin/projects/salt-formulas/cookiecutter-salt-formula |
| 4 | # Script requirments: |
| 5 | #apt-get install -y python-yaml virtualenv git |
| 6 | __ScriptVersion="2019.01.07" |
| 7 | __ScriptName="run_tests.sh" |
| 8 | __ScriptFullName="$0" |
| 9 | __ScriptArgs="$*" |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 10 | set -e |
| 11 | [ -n "$DEBUG" ] && set -x |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 12 | CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 13 | METADATA=${CURDIR}/../metadata.yml |
| 14 | FORMULA_NAME=$(cat $METADATA | python -c "import sys,yaml; print yaml.load(sys.stdin)['name']") |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 15 | FORMULA_META_DIR=${CURDIR}/../${FORMULA_NAME}/meta |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 16 | ## Overrideable parameters |
| 17 | PILLARDIR=${PILLARDIR:-${CURDIR}/pillar} |
| 18 | BUILDDIR=${BUILDDIR:-${CURDIR}/build} |
| 19 | VENV_DIR=${VENV_DIR:-${BUILDDIR}/virtualenv} |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 20 | MOCK_BIN_DIR=${MOCK_BIN_DIR:-${CURDIR}/mock_bin} |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 21 | DEPSDIR=${BUILDDIR}/deps |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 22 | SCHEMARDIR=${SCHEMARDIR:-"${CURDIR}/../${FORMULA_NAME}/schemas/"} |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 23 | SALT_FILE_DIR=${SALT_FILE_DIR:-${BUILDDIR}/file_root} |
| 24 | SALT_PILLAR_DIR=${SALT_PILLAR_DIR:-${BUILDDIR}/pillar_root} |
| 25 | SALT_CONFIG_DIR=${SALT_CONFIG_DIR:-${BUILDDIR}/salt} |
| 26 | SALT_CACHE_DIR=${SALT_CACHE_DIR:-${SALT_CONFIG_DIR}/cache} |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 27 | SALT_CACHE_EXTMODS_DIR=${SALT_CACHE_EXTMODS_DIR:-${SALT_CONFIG_DIR}/cache_master_extmods} |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 28 | SALT_OPTS="${SALT_OPTS} --retcode-passthrough --local -c ${SALT_CONFIG_DIR} --log-file=/dev/null" |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 29 | IGNORE_MODELVALIDATE_MASK=${IGNORE_MODELVALIDATE_MASK:-"novalidate"} |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 30 | if [ "x${SALT_VERSION}" != "x" ]; then |
| 31 | PIP_SALT_VERSION="==${SALT_VERSION}" |
| 32 | fi |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 33 | ## Functions |
| 34 | log_info() { |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 35 | echo -e "[INFO] $*" |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 36 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 37 | log_err() { |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 38 | echo -e "[ERROR] $*" >&2 |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 39 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 40 | setup_virtualenv() { |
| 41 | log_info "Setting up Python virtualenv" |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 42 | dependency_check virtualenv |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 43 | virtualenv $VENV_DIR |
| 44 | source ${VENV_DIR}/bin/activate |
Jakub Josef | 5e7c0a0 | 2018-02-08 13:22:17 +0100 | [diff] [blame] | 45 | python -m pip install salt${PIP_SALT_VERSION} |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 46 | if [[ -f ${CURDIR}/test-requirements.txt ]]; then |
| 47 | python -m pip install -r ${CURDIR}/test-requirements.txt |
| 48 | fi |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 49 | } |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 50 | setup_mock_bin() { |
| 51 | # If some state requires a binary, a lightweight replacement for |
| 52 | # such binary can be put into MOCK_BIN_DIR for test purposes |
| 53 | if [ -d "${MOCK_BIN_DIR}" ]; then |
| 54 | PATH="${MOCK_BIN_DIR}:$PATH" |
| 55 | export PATH |
| 56 | fi |
| 57 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 58 | setup_pillar() { |
| 59 | [ ! -d ${SALT_PILLAR_DIR} ] && mkdir -p ${SALT_PILLAR_DIR} |
| 60 | echo "base:" > ${SALT_PILLAR_DIR}/top.sls |
| 61 | for pillar in ${PILLARDIR}/*; do |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 62 | grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 63 | state_name=$(basename ${pillar%.sls}) |
| 64 | echo -e " ${state_name}:\n - ${state_name}" >> ${SALT_PILLAR_DIR}/top.sls |
| 65 | done |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 66 | for pillar in $(find $PILLARDIR -mindepth 2 -type f -iname *.sls); do |
| 67 | state_name=$(basename "${pillar%*.sls}") |
| 68 | os_release=$(echo $pillar | rev | cut -d'/' -f2 | rev) |
| 69 | grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue |
| 70 | echo -e " ${os_release}_${state_name}:\n - ${os_release}.${state_name}" >> ${SALT_PILLAR_DIR}/top.sls |
| 71 | done |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 72 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 73 | setup_salt() { |
| 74 | [ ! -d ${SALT_FILE_DIR} ] && mkdir -p ${SALT_FILE_DIR} |
| 75 | [ ! -d ${SALT_CONFIG_DIR} ] && mkdir -p ${SALT_CONFIG_DIR} |
| 76 | [ ! -d ${SALT_CACHE_DIR} ] && mkdir -p ${SALT_CACHE_DIR} |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 77 | [ ! -d ${SALT_CACHE_EXTMODS_DIR} ] && mkdir -p ${SALT_CACHE_EXTMODS_DIR} |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 78 | echo "base:" > ${SALT_FILE_DIR}/top.sls |
| 79 | for pillar in ${PILLARDIR}/*.sls; do |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 80 | grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 81 | state_name=$(basename ${pillar%.sls}) |
| 82 | echo -e " ${state_name}:\n - ${FORMULA_NAME}" >> ${SALT_FILE_DIR}/top.sls |
| 83 | done |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 84 | for pillar in $(find $PILLARDIR -mindepth 2 -type f -iname *.sls); do |
| 85 | state_name=$(basename "${pillar%*.sls}") |
| 86 | os_release=$(echo $pillar | rev | cut -d'/' -f2 | rev) |
| 87 | grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue |
| 88 | echo -e " ${os_release}_${state_name}:\n - ${FORMULA_NAME}" >> ${SALT_FILE_DIR}/top.sls |
| 89 | done |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 90 | cat << EOF > ${SALT_CONFIG_DIR}/minion |
| 91 | file_client: local |
| 92 | cachedir: ${SALT_CACHE_DIR} |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 93 | extension_modules: ${SALT_CACHE_EXTMODS_DIR} |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 94 | verify_env: False |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 95 | minion_id_caching: False |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 96 | file_roots: |
| 97 | base: |
| 98 | - ${SALT_FILE_DIR} |
| 99 | - ${CURDIR}/.. |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 100 | pillar_roots: |
| 101 | base: |
| 102 | - ${SALT_PILLAR_DIR} |
| 103 | - ${PILLARDIR} |
| 104 | EOF |
| 105 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 106 | fetch_dependency() { |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 107 | # example: fetch_dependency "linux:https://github.com/salt-formulas/salt-formula-linux" |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 108 | dep_name="$(echo $1|cut -d : -f 1)" |
| 109 | dep_source="$(echo $1|cut -d : -f 2-)" |
| 110 | dep_root="${DEPSDIR}/$(basename $dep_source .git)" |
| 111 | dep_metadata="${dep_root}/metadata.yml" |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 112 | dependency_check git |
| 113 | [ -d $dep_root ] && { log_info "Dependency $dep_name already fetched"; return 0; } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 114 | log_info "Fetching dependency $dep_name" |
| 115 | [ ! -d ${DEPSDIR} ] && mkdir -p ${DEPSDIR} |
| 116 | git clone $dep_source ${DEPSDIR}/$(basename $dep_source .git) |
| 117 | ln -s ${dep_root}/${dep_name} ${SALT_FILE_DIR}/${dep_name} |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 118 | METADATA="${dep_metadata}" install_dependencies |
| 119 | } |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 120 | link_modules(){ |
| 121 | # Link modules *.py files to temporary salt-root |
| 122 | local SALT_ROOT=${1:-$SALT_FILE_DIR} |
| 123 | local SALT_ENV=${2:-$DEPSDIR} |
| 124 | mkdir -p "${SALT_ROOT}/_modules/" |
| 125 | # from git, development versions |
| 126 | find ${SALT_ENV} -maxdepth 3 -mindepth 3 -path '*_modules*' -iname "*.py" -type f -print0 | while read -d $'\0' file; do |
| 127 | ln -fs $(readlink -e ${file}) "$SALT_ROOT"/_modules/$(basename ${file}) ; |
| 128 | done |
| 129 | salt_run saltutil.sync_all |
| 130 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 131 | install_dependencies() { |
| 132 | grep -E "^dependencies:" ${METADATA} >/dev/null || return 0 |
| 133 | (python - | while read dep; do fetch_dependency "$dep"; done) << EOF |
| 134 | import sys,yaml |
| 135 | for dep in yaml.load(open('${METADATA}', 'ro'))['dependencies']: |
| 136 | print '%s:%s' % (dep["name"], dep["source"]) |
| 137 | EOF |
| 138 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 139 | clean() { |
| 140 | log_info "Cleaning up ${BUILDDIR}" |
| 141 | [ -d ${BUILDDIR} ] && rm -rf ${BUILDDIR} || exit 0 |
| 142 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 143 | salt_run() { |
Jakub Josef | 8f60082 | 2017-12-15 16:58:30 +0100 | [diff] [blame] | 144 | [ -e ${VENV_DIR}/bin/activate ] && source ${VENV_DIR}/bin/activate |
Jakub Josef | 5e7c0a0 | 2018-02-08 13:22:17 +0100 | [diff] [blame] | 145 | python $(which salt-call) ${SALT_OPTS} $* |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 146 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 147 | prepare() { |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 148 | if [[ -f ${BUILDDIR}/.prepare_done ]]; then |
| 149 | log_info "${BUILDDIR}/.prepare_done exist, not rebuilding BUILDDIR" |
| 150 | return |
| 151 | fi |
| 152 | [[ -d ${BUILDDIR} ]] && mkdir -p ${BUILDDIR} |
| 153 | [[ ! -f "${VENV_DIR}/bin/activate" ]] && setup_virtualenv |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 154 | setup_mock_bin |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 155 | setup_pillar |
| 156 | setup_salt |
| 157 | install_dependencies |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 158 | link_modules |
| 159 | touch ${BUILDDIR}/.prepare_done |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 160 | } |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 161 | lint_releasenotes() { |
| 162 | [[ ! -f "${VENV_DIR}/bin/activate" ]] && setup_virtualenv |
| 163 | source ${VENV_DIR}/bin/activate |
| 164 | reno lint ${CURDIR}/../ |
| 165 | } |
| 166 | lint() { |
| 167 | # lint_releasenotes |
| 168 | log_err "TODO: lint_releasenotes" |
| 169 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 170 | run() { |
| 171 | for pillar in ${PILLARDIR}/*.sls; do |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 172 | grep ${FORMULA_NAME}: ${pillar} &>/dev/null || continue |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 173 | state_name=$(basename ${pillar%.sls}) |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 174 | salt_run grains.set 'noservices' False force=True |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 175 | echo "Checking state ${FORMULA_NAME}.${state_name} ..." |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 176 | salt_run --id=${state_name} state.show_sls ${FORMULA_NAME} || (log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1) |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 177 | # Check that all files in 'meta' folder can be rendered using any valid pillar |
| 178 | for meta in `find ${FORMULA_META_DIR} -type f`; do |
| 179 | meta_name=$(basename ${meta}) |
| 180 | echo "Checking meta ${meta_name} ..." |
| 181 | salt_run --out=quiet --id=${state_name} cp.get_template ${meta} ${SALT_CACHE_DIR}/${meta_name} \ |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 182 | || { log_err "Failed to render meta ${meta} using pillar ${FORMULA_NAME}.${state_name}"; exit 1; } |
Dennis Dmitriev | 1b93de2 | 2017-07-06 21:07:27 +0300 | [diff] [blame] | 183 | cat ${SALT_CACHE_DIR}/${meta_name} |
| 184 | done |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 185 | done |
| 186 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 187 | real_run() { |
| 188 | for pillar in ${PILLARDIR}/*.sls; do |
| 189 | state_name=$(basename ${pillar%.sls}) |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 190 | salt_run --id=${state_name} state.sls ${FORMULA_NAME} || { log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1; } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 191 | done |
| 192 | } |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 193 | run_model_validate(){ |
| 194 | # Run modelschema.model_validate validation. |
| 195 | # TEST iterateble, run for `each formula ROLE against each ROLE_PILLARNAME` |
| 196 | # Pillars should be named in conviend ROLE_XXX.sls or ROLE.sls |
| 197 | # Example: |
| 198 | # client.sls client_auth.sls server.sls server_auth.sls |
| 199 | if [ -d ${SCHEMARDIR} ]; then |
| 200 | # model validator require py modules |
| 201 | fetch_dependency "salt:https://github.com/salt-formulas/salt-formula-salt" |
| 202 | link_modules |
| 203 | salt_run saltutil.clear_cache; salt_run saltutil.refresh_pillar; salt_run saltutil.sync_all; |
| 204 | for role in $(find $SCHEMARDIR/* -maxdepth 0 -type f -iname *.yaml); do |
| 205 | role_name=$(basename "${role%*.yaml}") |
| 206 | for pillar in $(ls pillar/${role_name}*.sls | grep -v ${IGNORE_MODELVALIDATE_MASK} ); do |
| 207 | pillar_name=$(basename "${pillar%*.sls}") |
| 208 | local _message="FORMULA:${FORMULA_NAME} ROLE:${role_name} against PILLAR:${pillar_name}" |
| 209 | log_info "model_validate ${_message}" |
| 210 | # Rendered Example: |
| 211 | # python $(which salt-call) --local -c /test1/maas/tests/build/salt --id=maas_cluster modelschema.model_validate maas cluster |
| 212 | salt_run -m ${DEPSDIR}/salt-formula-salt --id=${pillar_name} modelschema.model_validate ${FORMULA_NAME} ${role_name} || { log_err "Execution of model_validate ${_message} failed"; exit 1 ; } |
| 213 | done |
| 214 | done |
| 215 | for schema in $(find $SCHEMARDIR -mindepth 2 -type f -iname *.yaml); do |
| 216 | role_name=$(basename "${schema%*.yaml}") |
| 217 | os_release=$(echo $schema | rev | cut -d'/' -f2 | rev) |
| 218 | local _message="FORMULA:${FORMULA_NAME} ROLE:${role_name} against PILLAR:${role_name}" |
| 219 | log_info "model_validate ${_message}" |
| 220 | salt_run -m ${DEPSDIR}/salt-formula-salt --id=${os_release}_${role_name} modelschema.model_validate ${FORMULA_NAME} ${role_name} ${os_release} || { log_err "Execution of model_validate ${_message} failed"; exit 1 ; } |
| 221 | done |
| 222 | else |
| 223 | log_info "${SCHEMARDIR} not found!"; |
| 224 | fi |
| 225 | } |
| 226 | dependency_check() { |
| 227 | local DEPENDENCY_COMMANDS=$* |
| 228 | for DEPENDENCY_COMMAND in $DEPENDENCY_COMMANDS; do |
| 229 | which $DEPENDENCY_COMMAND > /dev/null || ( log_err "Command \"$DEPENDENCY_COMMAND\" can not be found in default path."; exit 1; ) |
| 230 | done |
| 231 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 232 | _atexit() { |
| 233 | RETVAL=$? |
| 234 | trap true INT TERM EXIT |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 235 | if [ $RETVAL -ne 0 ]; then |
| 236 | log_err "Execution failed" |
| 237 | else |
| 238 | log_info "Execution successful" |
| 239 | fi |
| 240 | return $RETVAL |
| 241 | } |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 242 | ## Main |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 243 | log_info "Running version: ${__ScriptVersion}" |
| 244 | log_info "Command line: '${__ScriptFullName} ${__ScriptArgs}'" |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 245 | trap _atexit INT TERM EXIT |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 246 | case $1 in |
| 247 | clean) |
| 248 | clean |
| 249 | ;; |
| 250 | prepare) |
| 251 | prepare |
| 252 | ;; |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 253 | lint) |
| 254 | lint |
| 255 | ;; |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 256 | run) |
| 257 | run |
| 258 | ;; |
| 259 | real-run) |
| 260 | real_run |
| 261 | ;; |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 262 | model-validate) |
| 263 | prepare |
| 264 | run_model_validate |
| 265 | ;; |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 266 | *) |
| 267 | prepare |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 268 | # lint |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 269 | run |
Jesse Pendergrass | 615d0d1 | 2021-03-08 15:51:57 -0600 | [diff] [blame^] | 270 | run_model_validate |
Filip Pytloun | d5d7cc4 | 2016-05-16 10:56:18 +0200 | [diff] [blame] | 271 | ;; |
| 272 | esac |