diff --git a/env/.config/hpa/config.toml b/env/.config/hpa/config.toml index f8080ae..6f635c8 100644 --- a/env/.config/hpa/config.toml +++ b/env/.config/hpa/config.toml @@ -44,8 +44,8 @@ useVaultArgs = true # instead of the provided / default playbook. [playbook] -directory = '~/.local/share/hpa/playbook' -inventory = '~/.local/share/hpa/playbook/inventory.ini' +directory = '/root/.local/share/hpa/playbook' +inventory = '/root/.local/share/hpa/playbook/inventory.ini' version = 'main' # NOTE: @@ -53,7 +53,8 @@ version = 'main' # a remote git repository. [template] # The directory path on your local system to the template files. -directory = '~/.local/share/hpa/template' +directory = '/root/.local/share/hpa/template' +vars = 'repo_vars' # The url to a git repository that contains your template files. # url = 'https://git.example.com/consult-template.git' diff --git a/env/.local/scripts/hpa b/env/.local/scripts/hpa index 055e654..ebe84ad 100755 --- a/env/.local/scripts/hpa +++ b/env/.local/scripts/hpa @@ -10,16 +10,12 @@ set -o pipefail # Make sure to run 'hpa-init' first on this machine to setup # dependencies, if you have not done so already. # -# This will mount my home directory inside the container, so -# it should somewhat mirror like commands are run on the host os. -# # To attach to a shell inside the container run: # `hpa bash` # # To run ansible vault commands inside the container run: # `hpa ansible-vault ...` # -# SCRIPTS=${SCRIPTS:-$HOME/.local/scripts} . "$SCRIPTS/utils/hpa/hpa.env" @@ -28,16 +24,19 @@ SCRIPTS=${SCRIPTS:-$HOME/.local/scripts} last_pull="0" if [[ -f "$HPA_CONFIG_DIR/.lastpull" ]]; then - last_pull=$(cat "$HPA_CONFIG_DIR/.lastpull") + last_pull=$(cat "$HPA_CONFIG_DIR/.lastpull") fi curr=$(date +%s) diff=$((curr - last_pull)) if [[ $HPA_AUTO_PULL == "1" ]] && [[ $diff -gt "$HPA_AUTO_PULL_INTERVAL" ]]; then - . "$SCRIPTS/hpa-pull" "$HPA_AUTO_PULL_OPTS" + . "$SCRIPTS/hpa-pull" "$HPA_AUTO_PULL_OPTS" fi podman run --rm --interactive --tty \ - --volume "$HOME":/root \ - --secret "$HPA_VAULT_SECRET_KEY" \ - "$HPA_DOCKER_IMAGE:$HPA_DOCKER_TAG" "$@" + --volume "$HPA_CONFIG_DIR":/root/.config/hpa:ro \ + --volume "$HPA_DATA_DIR":/root/.local/share/hpa:ro \ + --volume "$HPA_CONSULTS_DIR":/consults \ + --volume "$PWD":/root/project \ + --secret "$HPA_VAULT_SECRET_KEY" \ + "$HPA_DOCKER_IMAGE:$HPA_DOCKER_TAG" "$@" diff --git a/env/.local/scripts/utils/hpa/hpa-create b/env/.local/scripts/utils/hpa/hpa-create index f0818aa..b5e6c1f 100755 --- a/env/.local/scripts/utils/hpa/hpa-create +++ b/env/.local/scripts/utils/hpa/hpa-create @@ -23,7 +23,7 @@ no_push_flag="0" date_opt=$(date '+%Y.%m.%d') usage() { - cat </dev/null || exit 1 - ( - git init - git add . - git commit --all --message="Initial commit" - git remote add origin "$HPA_CONSULT_ORIGIN_BASE_URL/$(basename "$dir")" - if [[ $no_push_flag == "0" ]]; then - git push --set-upstream origin main - fi - ) &>/dev/null - popd &>/dev/null - else - log "Skipping git initialization" - fi + pushd "$dir" &>/dev/null || exit 1 + ( + git init + git lfs install + git lfs track '*.png' + git lfs track '*.pdf' + git add . + git commit --all --message="Initial commit" + git remote add origin "$HPA_CONSULT_ORIGIN_BASE_URL/$(basename "$dir")" + if [[ $no_push_flag == "0" ]]; then + git push --set-upstream origin main + fi + ) &>/dev/null + popd &>/dev/null + else + log "Skipping git initialization" + fi - echo "$dir" + echo "$dir" } ################################################################################ @@ -124,19 +127,19 @@ setup-logging "$LOG_FILE" "$LOG_LABEL" declare customer output while [[ $# -gt 0 ]]; do - if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then - usage && exit 0 - elif [[ $1 == "-d" ]] || [[ $1 == "--date" ]]; then - shift - date_opt="$1" - elif [[ $1 == "-g" ]] || [[ $1 == "--no-git" ]]; then - no_git_flag="1" - elif [[ $1 == "-p" ]] || [[ $1 == "--no-push" ]]; then - no_push_flag="1" - else - customer=$1 - fi - shift + if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then + usage && exit 0 + elif [[ $1 == "-d" ]] || [[ $1 == "--date" ]]; then + shift + date_opt="$1" + elif [[ $1 == "-g" ]] || [[ $1 == "--no-git" ]]; then + no_git_flag="1" + elif [[ $1 == "-p" ]] || [[ $1 == "--no-push" ]]; then + no_push_flag="1" + else + customer=$1 + fi + shift done output=$(create "$customer" | initialize-git)