dev-env/bin/script/foreachSystem
2024-08-24 19:44:42 +00:00

33 lines
841 B
Bash
Executable File

#!/bin/bash
COMMAND="$@"
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../.." &> /dev/null && pwd )
source ${ENV_DIR}/bin/dexec
# Überprüfen, ob die richtige Anzahl Argumente übergeben wurden
if [ $# -lt 1 ]; then
echo "Verwendung: foreachSystem up -d"
return 1
fi
for SYSTEM in $ENV_DIR/systems/*/*/ ; do
# Extrahiere den Teil nach "systems/"
relative_path="${SYSTEM#*/systems/}"
# Entferne den abschließenden Schrägstrich
relative_path="${relative_path%/}"
typePart="${relative_path%/*}" # before "/" eg. backend / frontend
systemPart="${relative_path##*/}" # after "/" eg. bee / auth / etc
SYSTEM_CODE="$systemPart-$typePart"
DENV_COMMAND="dexec"
if [[ "$COMMAND" == "init" ]]; then
$ENV_DIR/systems/$typePart/$systemPart/bin/script/init
else
$DENV_COMMAND $SYSTEM_CODE $COMMAND
fi
done