Move bash config to shell subdir

This commit is contained in:
2025-11-13 13:52:25 -05:00
parent 60d5d88e96
commit 7ef57ef155
16 changed files with 9 additions and 9 deletions

55
shell/scripts.d/50-dev.sh Normal file
View File

@@ -0,0 +1,55 @@
DEVENV_IMAGE='localhost/toolbox-dev-env:latest'
function dev() {
if [ ${#} -lt 1 ]; then
echo "WARNING: Missing project name";
project=""
else
project="${1}"
fi
if [ -f '/run/.toolboxenv' ]; then
cd "${PROJECTS_PATH}/${project}";
if [ -f "${PWD}/ansible.cfg" ]; then
export ANSIBLE_CONFIG="${PWD}/ansible.cfg";
export ANSIBLE_COLLECTIONS_PATH="${PWD}/.ansible"
fi
if [ -f "${PWD}/pyproject.toml" ]; then
poetry_venv=$(poetry env info --path)
if [ ! -z "${poetry_venv}" ] && [ -f "${poetry_venv}/bin/activate" ]; then
source "${poetry_venv}/bin/activate";
fi
fi
else
if [ ! -d "${PROJECTS_PATH}/${project}" ]; then
echo "ERROR: Project path ${PROJECTS_PATH}/${project} does not exist";
return 1
fi
local slug=$(random 8)
local container_name="toolbox-${project:-generic}-${slug}"
toolbox create --image="${DEVENV_IMAGE}" "${container_name}" &>/dev/null || return 1
local current=$(pwd)
cd "${PROJECTS_PATH}/${project}"
echo ">>> Loading project: ${project}"
echo ">>> ${PWD}"
toolbox enter "${container_name}"
echo ">>> Exited: ${container_name}"
cd "${current}"
podman container stop "${container_name}" &>/dev/null
podman container rm --force "${container_name}" &>/dev/null
fi
}
if [ -f '/run/.toolboxenv' ]; then
if [[ "${PWD}" == $PROJECTS_PATH/* ]]; then
dev $(basename "${PWD}")
fi
fi