diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index dc03e15..565a5fa 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,7 +18,15 @@ ], // Configure tool-specific properties. - // "customizations": {}, + "customizations": { + "vscode":{ + "extensions": [ + "timonwong.shellcheck", + "GitHub.vscode-pull-request-github", + "charliermarsh.ruff" + ] + } + }, // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" diff --git a/bin/lib.sh b/bin/lib.sh index 930fff8..4478c7b 100644 --- a/bin/lib.sh +++ b/bin/lib.sh @@ -1,26 +1,28 @@ -DIRNAME=$(dirname `realpath $0`) +#!/bin/bash +DIRNAME=$(dirname $(realpath $0)) PARENT_DIR=$DIRNAME/.. -PROJECT_DIR=`realpath $PARENT_DIR` +PROJECT_DIR=$(realpath $PARENT_DIR) ENV_FILE=$PROJECT_DIR/.env if [ -f "$ENV_FILE" ]; then - . $ENV_FILE + # shellcheck source=lib.sh + . "$ENV_FILE" else echo "WARNING: File $ENV_FILE does not exist, relying on environment variables" fi check_environment_variables_defined () { - variable_not_set=0 - for VARIABLE in "$@"; do - if [ -z "${!VARIABLE}" ]; then - echo "Environment variable $VARIABLE is not set" - variable_not_set=1 + variable_not_set=0 + for VARIABLE in "$@"; do + if [ -z "${!VARIABLE}" ]; then + echo "Environment variable $VARIABLE is not set" + variable_not_set=1 + fi + done + + if [ $variable_not_set -eq 1 ]; then + exit 1 fi - done - - if [ $variable_not_set -eq 1 ]; then - exit 1 - fi } export PGOPTIONS="--search_path=$LOUIS_SCHEMA,public" @@ -33,16 +35,17 @@ export PGHOST export PGPASSFILE export PGPASSWORD -VERSION15=`psql --version | grep 15.` +VERSION15=$(psql --version | grep 15.) if [ -z "$VERSION15" ]; then echo "postgresql-client-15 required" exit 1 fi -PSQL_ADMIN="psql -v ON_ERROR_STOP=1 --single-transaction -d $PGBASE" -TODAY=`date +%Y-%m-%d` +TODAY=$(date +%Y-%m-%d) if [ -z "$PGDUMP_FILENAME" ]; then PGDUMP_FILENAME=$PROJECT_DIR/dumps/$TODAY.$PGBASE.pg_dump fi + +export PSQL_ADMIN="psql -v ON_ERROR_STOP=1 --single-transaction -d $PGBASE"