changes from fue 1

This commit is contained in:
Flo 2024-09-14 13:48:22 +00:00
parent 907713850d
commit 8c25db6bb2
5 changed files with 10 additions and 34 deletions

View File

@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
denvexec() { denvexec() {
# Überprüfen, ob die richtige Anzahl Argumente übergeben wurden
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
echo "Verwendung: denvexec <docker command>" echo "Verwendung: denvexec <docker command>"
return 1 return 1
@ -10,9 +9,8 @@ denvexec() {
local DOCKER_COMMAND="$@" local DOCKER_COMMAND="$@"
local ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd ) local ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
echo "" echo ""
echo "$ENV_DIR: $DOCKER_COMMAND" echo "Directory: ${ENV_DIR}"
#MAC #MAC
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
@ -30,14 +28,11 @@ denvexec() {
} }
dexec() { dexec() {
# Überprüfen, ob die richtige Anzahl Argumente übergeben wurden
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
echo "Verwendung: dexec <system> <docker command>" echo "Verwendung: dexec <system> <docker command>"
return 1 return 1
fi fi
# convert first parameter to system-direcotry, concat the rest
# Teile den String in zwei Teile auf, getrennt durch "-"
local systemPart="${1%-*}" # before "-" e.g. auth / bee / etc local systemPart="${1%-*}" # before "-" e.g. auth / bee / etc
local typePart="${1##*-}" # after "-" e.g. backend / frontend local typePart="${1##*-}" # after "-" e.g. backend / frontend
local SYSTEM_DIR="$typePart/$systemPart" local SYSTEM_DIR="$typePart/$systemPart"
@ -45,10 +40,10 @@ dexec() {
local DOCKER_COMMAND="$@" local DOCKER_COMMAND="$@"
local ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd ) local ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
local DOT_ENV_PATH="${ENV_DIR}/systems/${SYSTEM_DIR}/.env"
echo "" echo ""
echo "$SYSTEM_DIR: $DOCKER_COMMAND" echo "Directory: ${ENV_DIR}/systems/${SYSTEM_DIR}"
local DOT_ENV_PATH="${ENV_DIR}/systems/${SYSTEM_DIR}/.env"
#SET ENV VARIABLES FROM .ENV #SET ENV VARIABLES FROM .ENV
if [ -e "$DOT_ENV_PATH" ]; then if [ -e "$DOT_ENV_PATH" ]; then

View File

@ -1,48 +1,31 @@
#!/bin/bash #!/bin/bash
drun() { drun() {
# Überprüfen, ob die richtige Anzahl Argumente übergeben wurden
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
echo "Verwendung: drun <system> <run in docker container>" echo "Verwendung: drun <system> <run in docker container>"
return 1 return 1
fi fi
# Container-Namen extrahieren
local CONTAINER_NAME="$1" local CONTAINER_NAME="$1"
shift # Das erste Argument entfernen shift # Das erste Argument entfernen
# Den Rest der Argumente als Befehlszeichenfolge zusammenfügen
local COMMAND="$@" local COMMAND="$@"
# Container-ID mithilfe des Container-Namens finden
local CONTAINER_ID=$(docker ps -qf "name=$CONTAINER_NAME-app") local CONTAINER_ID=$(docker ps -qf "name=$CONTAINER_NAME-app")
# Überprüfen, ob der Container gefunden wurde
if [ -z "$CONTAINER_ID" ]; then if [ -z "$CONTAINER_ID" ]; then
echo "Container '$CONTAINER_NAME' wurde nicht gefunden." echo "Container '$CONTAINER_NAME' wurde nicht gefunden."
return 1 return 1
fi fi
# Befehl im Container ausführen
docker exec -it "$CONTAINER_ID" $COMMAND docker exec -it "$CONTAINER_ID" $COMMAND
} }
_drun_completion() { _drun_completion() {
local cur prev opts local cur prev opts
COMPREPLY=() # Array, das die Vorschläge enthalten wird COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" # Das aktuelle Wort, das vervollständigt werden soll cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" # Das vorherige Wort prev="${COMP_WORDS[COMP_CWORD-1]}"
# Hier definierst du die Optionen oder Argumente, die `drun` akzeptiert
opts="start stop restart status" opts="start stop restart status"
# Wenn die Optionen abhängig vom vorherigen Wort sind, kannst du hier Bedingungen hinzufügen
# Beispiel:
# if [[ ${prev} == "start" ]]; then
# opts="service1 service2 service3"
# fi
# Die verfügbaren Optionen auf das aktuelle Eingabewort filtern
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0 return 0
} }

View File

@ -5,7 +5,6 @@ ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../.." &> /dev/null && pwd
source ${ENV_DIR}/bin/dexec source ${ENV_DIR}/bin/dexec
# Überprüfen, ob die richtige Anzahl Argumente übergeben wurden
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
echo "Verwendung: foreachSystem up -d" echo "Verwendung: foreachSystem up -d"
return 1 return 1
@ -13,10 +12,7 @@ fi
for SYSTEM in $ENV_DIR/systems/*/*/ ; do for SYSTEM in $ENV_DIR/systems/*/*/ ; do
# Extrahiere den Teil nach "systems/"
relative_path="${SYSTEM#*/systems/}" relative_path="${SYSTEM#*/systems/}"
# Entferne den abschließenden Schrägstrich
relative_path="${relative_path%/}" relative_path="${relative_path%/}"
typePart="${relative_path%/*}" # before "/" eg. backend / frontend typePart="${relative_path%/*}" # before "/" eg. backend / frontend

2
cron/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
setup
View File

@ -30,4 +30,4 @@ echo "source $ENV_DIR/bin/git" >> ~/.profile
echo "appending dev-env .profile to .profile" echo "appending dev-env .profile to .profile"
echo "" >> ~/.profile echo "" >> ~/.profile
cat .profile >> ~/.profile cat .profile >> ~/.profile