master: aua changes

This commit is contained in:
Flo 2025-05-25 22:21:05 +02:00
parent 1af381d3cd
commit 5852c79f10
21 changed files with 313 additions and 150 deletions

2
.gitignore vendored
View File

@ -10,3 +10,5 @@ var/
.firstRun
.aliases
.systems
.idea
.DS_Store

100
README.md
View File

@ -1,28 +1,90 @@
# Stack-Up dev-env
# AuA24 dev-env
## Introduction
This project is the development environment of all stack-up projects.
It simplifies handling different docker-enabled applications and their maintenance.
This project is the development environment of the **AuA24 Dashboard**.
It's purpose is to simplify the handling, maintenance and development of docker-enabled applications (systems).
## Installation
- Create a .systems file bases on .systems.example: `cp .systems.example .systems`
- Enter all systems in the created file `nano .systems`
- run `./init`. Init will:
- update `.aliases` file, which enables you to switch between your systems easily via `goto-<system-identifier>`
- updates `.profile` to use the updated aliases, enables the dev-env binaries (denv, drun, dcom, ...) and add some utility functions
- clones all systems defined in `.systems`
- calls the `bin/script/init` script for all cloned systems.
- Perform init actions on systems
- Run `./init`
- Perform initial actions on systems.
This might include...
- changing variables in your `.env` files, adjusting the `docker/docker-compose.yml` if necessary
- adding file(s) to the system (e.g. the `weblate.token`)
- `./up` to start your containers
- up will also run all the `bin/script/firstRun` scripts, if the `.firstRun` marker is missing
## Usage
After the installation was performed successfully and you've sourced your ~/.profile file, you'll have access to the following utilities:
- denv
- without a parameter, navigates to the development environment
- if a parameter is specified, denv will try to execute the passed script in the dev-env base folder
- drun
- executes a command on the app container of a system
- dcom
- executes a docker compose command.
- without a parameter, for the system of the current directory
- with a parameter, for the supplied system-id
After the installation was performed successfully and you've sourced your ~/.profile file, you'll have access to the following utilities
### Binaries
#### denv
> Syntax: `denv [script]`
> - Without a passed script, navigates to the development environment.
> - If `script` is passed, denv will try to execute the specified script in the dev-env base folder.
#### drun
> Syntax: `drun [system-identifier] <command>`
> - Executes a command on the 'app'-container of a system. (e.g. `backend-app` for `backend`)
> - If a system-identifier is passed, the specified command will be executed on the 'app'-container for the passed system-identifier.
> - If no system-identifier is passed, `drun` will try to identify the system by the folder you're currently in.
#### dcom
> Syntax: `dcom [system-identifier] <command>`
> - Executes a `docker compose` command for a specific system
> - If a `system-identifier` is passed, the `command` will be for the `docker/docker-compose.yml` file of the passed `system-identifier`.
> - If no `system-identifier` is passed, `dcom` will try to identify the system by the folder you're currently in.
### Scripts
All these scripts are available in the dev-env base directory.
They may be called by either just executing them in the command line when you're in the dev-env base directory `./script` or by using the `denv` binary from any place: `denv script`
#### build
> Builds the images, which are used to start up docker containers
> - Executes `docker compose build` for the dev-env
> - Then executes `dcom <system> build` for each system
#### down
> Stops all running containers and removes them afterwards.
> This may lead to loss of data.
> - Executes `docker compose down` for the dev-env
> - Then executes `dcom <system> down` for each system
#### info
> Displays information about the dev-env
> - Full path to the environment
> - An overview over all installed systems...
> - Identifier
> - Path relative to the dev-env
> - Currently checked out branch
> - An indicator whether there are uncommitted changes on the branch
#### init
> Initializes the development environment.
> It should skip unnecessary steps, in case the dev-env is already initialized.
> - Creates certificates used by traefik to enable TLS (HTTPS)
> - Creates access keys `~/.ssh/personal_bitbucket_access_key` and `~/.ssh/bitbucket_access_key` used for connecting a container with git
> - Updates `.aliases` file, which enables you to switch between your systems easily via `goto-<system-identifier>`
> - Updates `.profile` to use the updated aliases, enables the dev-env binaries (`denv`, `drun`, `dcom`, ...) and add some utility functions
> - Clones all systems defined in `.systems`
> - Calls the `./bin/script/init` script for each cloned system
#### prune
> Removes all containers and images from docker. This also includes all data saved on databases.
> After confirmation...
> - Stops all running docker containers
> - Remove all containers and images
#### stop
> Stops all running containers.
> - Executes `docker compose stop` for the dev-env
> - Then executes `dcom <system> stop` for each system
#### up
> Starts all running containers.
> - Executes `docker compose up -d` for the dev-env
> - Then executes `dcom <system> up -d` for each system
#### update
> Calls the `bin/script/update` script for each system

View File

@ -1,10 +1,10 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
dcom() {
function dcom() {
if [ $# -lt 1 ]; then
denv_error_msg "Verwendung: dcom [system] <docker-compose command>"
errormsg "Usage: dcom [system] <docker-compose command>"
return 1
fi
@ -23,13 +23,13 @@ dcom() {
SYSTEM_PATH=$(grep "$ASSUMED_SYSTEM_PATH" "$SYSTEMS_CONFIG" | cut -d' ' -f2)
if [ -z "$SYSTEM_PATH" ]; then # You are NOT in a configured system directory (though in a subdirectory of dev-env/systems).
denv_error_msg "$CURRENT_DIRECTORY is not a configured dev-env system path.\nPlease register the system in $ENV_DIR/.systems, navigate to a registered system, or provide a system identifer as the first parameter of dcom."
errormsg "$CURRENT_DIRECTORY is not a configured dev-env system path.\nPlease register the system in $ENV_DIR/.systems, navigate to a registered system, or provide a system identifer as the first parameter of dcom."
return 1
else # You are in a configured system directory
SYSTEM_IDENTIFIER=$(grep "$ASSUMED_SYSTEM_PATH" "$SYSTEMS_CONFIG" | cut -d' ' -f1)
fi
else
denv_error_msg "$CURRENT_DIRECTORY is not a subdirectory of $ENV_DIR/systems.\nPlease navigate to a configured system, or provide a system identifer as the first parameter of dcom."
errormsg "$CURRENT_DIRECTORY is not a subdirectory of $ENV_DIR/systems.\nPlease navigate to a configured system, or provide a system identifer as the first parameter of dcom."
return 1
fi
@ -44,11 +44,11 @@ dcom() {
# Set .env variables if a file exist
if [[ ! -f "$DOCKER_COMPOSE_FILE" ]]; then
denv_error_msg "$DOCKER_COMPOSE_FILE was not found. Have you run init yet?"
errormsg "$DOCKER_COMPOSE_FILE was not found. Have you run init yet?"
return 1
fi
denv_info_msg "[$SYSTEM_IDENTIFIER]: $DOCKER_COMPOSE_COMMAND"
infomsg "[$SYSTEM_IDENTIFIER]: $DOCKER_COMPOSE_COMMAND"
if [[ -f "$SYSTEM_ENV_FILE" ]] ; then
export $(grep -v '^#' "$SYSTEM_ENV_FILE" | xargs)
@ -62,7 +62,7 @@ dcom() {
fi
}
_dcom_completion() {
function _dcom_completion() {
local SYSTEMS_CONFIG="$ENV_DIR/.systems"
local cur prev opts
COMPREPLY=()

View File

@ -1,10 +1,24 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../" &> /dev/null && pwd )
denv() {
function denv() {
if [ ! -z $1 ] ; then
$ENV_DIR/$1
else
cd $ENV_DIR
fi
}
_denv_completion() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(find "$ENV_DIR" -maxdepth 1 -type f -executable -printf "%f\n")
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _denv_completion denv

View File

@ -1,27 +0,0 @@
#!/bin/bash
RESET='\033[0m'
Black='\033[0;30m'
Red='\033[0;31m'
Green='\033[0;32m'
Yellow='\033[0;33m'
Blue='\033[0;34m'
Purple='\033[0;35m'
Cyan='\033[0;36m'
White='\033[0;37m'
denv_error_msg () {
echo -e "${Red}$@${RESET}"
}
denv_success_msg () {
echo -e "${Green}$@${RESET}"
echo -e ""
}
denv_info_msg () {
echo -e "${Cyan}$@${RESET}"
}
denv_echo_msg () {
echo -e "${White}$@${RESET}"
}

View File

@ -1,10 +1,10 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
drun() {
function drun() {
if [ $# -lt 1 ]; then
denv_error_msg "Verwendung: drun [system] <docker-compose command>"
errormsg "Usage: drun [system] <docker-compose command>"
return;
fi
@ -23,13 +23,13 @@ drun() {
SYSTEM_PATH=$(grep "$ASSUMED_SYSTEM_PATH" "$SYSTEMS_CONFIG" | cut -d' ' -f2)
if [ -z "$SYSTEM_PATH" ]; then # You are NOT in a configured system directory (though in a subdirectory of dev-env/systems).
denv_error_msg "$CURRENT_DIRECTORY is not a configured dev-env system path.\nPlease register the system in $ENV_DIR/.systems, navigate to a registered system, or provide a system identifer as the first parameter of drun."
errormsg "$CURRENT_DIRECTORY is not a configured dev-env system path.\nPlease register the system in $ENV_DIR/.systems, navigate to a registered system, or provide a system identifer as the first parameter of drun."
return;
else # You are in a configured system directory
SYSTEM_IDENTIFIER=$(grep "$ASSUMED_SYSTEM_PATH" "$SYSTEMS_CONFIG" | cut -d' ' -f1)
fi
else
denv_error_msg "$CURRENT_DIRECTORY is not a subdirectory of $ENV_DIR/systems.\nPlease navigate to a configured system, or provide a system identifer as the first parameter of drun."
errormsg "$CURRENT_DIRECTORY is not a subdirectory of $ENV_DIR/systems.\nPlease navigate to a configured system, or provide a system identifer as the first parameter of drun."
return;
fi
@ -44,7 +44,7 @@ drun() {
# Set .env variables if a file exist
if [[ ! -f "$DOCKER_COMPOSE_FILE" ]]; then
denv_error_msg "$DOCKER_COMPOSE_FILE was not found. Have you run init yet?"
errormsg "$DOCKER_COMPOSE_FILE was not found. Have you run init yet?"
return;
fi
@ -54,22 +54,23 @@ drun() {
fi
APP_CONTAINER=$(docker compose -f "$DOCKER_COMPOSE_FILE" config --services | grep 'app')
if [[ ! -z "$APP_CONTAINER" ]] ; then
denv_info_msg "[$SYSTEM_IDENTIFIER]($APP_CONTAINER): $DOCKER_EXEC_COMMAND"
CONTAINER_ID=$(docker ps -qf "name=$APP_CONTAINER")
infomsg "[$SYSTEM_IDENTIFIER]($APP_CONTAINER): $DOCKER_EXEC_COMMAND"
CONTAINER_ID=$(docker ps -qf "name=docker-$APP_CONTAINER")
if [ -z "$CONTAINER_ID" ]; then
denv_error_msg "No active container found for '$APP_CONTAINER'"
errormsg "No active container found for '$APP_CONTAINER'"
return;
fi
if [[ -t 0 && -t 1 ]]; then
docker exec -it "$CONTAINER_ID" $DOCKER_EXEC_COMMAND
docker exec -it "$CONTAINER_ID" bash -ci "$DOCKER_EXEC_COMMAND"
else
docker exec "$CONTAINER_ID" $DOCKER_EXEC_COMMAND
docker exec -t "$CONTAINER_ID" bash -ci "$DOCKER_EXEC_COMMAND"
fi
else
denv_error_msg "No 'app' container found in $DOCKER_COMPOSE_FILE"
errormsg "No 'app' container found in $DOCKER_COMPOSE_FILE"
return;
fi
@ -79,7 +80,7 @@ drun() {
fi
}
_drun_completion() {
function _drun_completion() {
local SYSTEMS_CONFIG="$ENV_DIR/.systems"
local cur prev opts
COMPREPLY=()

24
bin/git
View File

@ -1,8 +1,26 @@
#!/bin/bash
acp() {
git add .
git commit -m "$@"
function acp() {
git add -A
NAME=$(git branch | grep '*' | sed 's/* //')
git commit -a -m "$NAME: $1"
git push
}
function pd() {
git pull origin develop:develop
}
function pdm() {
git pull origin develop:develop
git merge develop
}
function pm() {
git pull origin master:master
}
function pmm() {
git pull origin master:master
git merge master
}

38
bin/messages Normal file
View File

@ -0,0 +1,38 @@
ANSI_OPEN="\033["
function resetcolors {
echo -n -e "${ANSI_OPEN}0m"
}
function importantmsg {
echo -e "${ANSI_OPEN}96m$1"
resetcolors
}
function errormsg {
echo -e "${ANSI_OPEN}91m$1"
resetcolors
}
function infomsg {
echo -e "${ANSI_OPEN}0m$1"
resetcolors
}
function successmsg {
echo -e "${ANSI_OPEN}92m$1"
resetcolors
}
function warnmsg {
echo -e "${ANSI_OPEN}93m$1"
resetcolors
}
function hasNewLine {
test "$(tail -c 1 "$1" | wc -l)" -eq 0 && echo "NO" || echo "YES"
}
function indent {
sed 's/^/ /';
}

27
bin/ssh
View File

@ -2,26 +2,21 @@
SSH_ENV="$HOME/.ssh/agent-environment"
function dssh {
ADD_AGENT=0
if [ -f "$SSH_ENV" ]; then
. "$SSH_ENV" >/dev/null
ps -ef | grep $SSH_AGENT_PID | grep ssh-agent$ >/dev/null || {
ADD_AGENT=1
}
else
ADD_AGENT=1
fi
if [ $ADD_AGENT -eq 1 ]; then
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' >"$SSH_ENV"
echo succeeded
chmod 600 "$SSH_ENV"
. "$SSH_ENV" >/dev/null
else
echo "No agent necessary"
fi
/usr/bin/ssh-add;
/usr/bin/ssh-add ~/.ssh/gitea_ssh
ssh-add ~/.ssh/gitea_ssh
}
if [ -f "$SSH_ENV" ]; then
. "$SSH_ENV" >/dev/null
ps -ef | grep $SSH_AGENT_PID | grep ssh-agent$ >/dev/null || {
dssh
}
else
dssh
fi

5
build
View File

@ -1,9 +1,8 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
denv_info_msg "[dev-env]: build"
infomsg "[dev-env]: Executing docker-compose build for dev-env"
docker compose -f "$ENV_DIR/docker/docker-compose.yml" build
echo ""

24
down
View File

@ -1,13 +1,27 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
$ENV_DIR/script/foreachSystem/dcom down
warnmsg "This script will down docker containers (= stop & remove)"
warnmsg "This also deletes all data on the databases"
warnmsg "Do you want to continue? (y/n)"
read -p "Answer: " ANSWER
echo ""
denv_info_msg "[dev-env]: down"
if [[ "$ANSWER" == "y" || "$ANSWER" == "Y" ]]; then
$ENV_DIR/script/foreachSystem/dcom down
infomsg "[dev-env]: Executing docker-compose down for dev-env"
docker compose -f "$ENV_DIR/docker/docker-compose.yml" down
echo ""
if [ -f "$ENV_DIR/.firstRun" ]; then
infomsg "[dev-env]: Removing firstRun marker"
rm "$ENV_DIR/.firstRun"
echo ""
fi
docker ps
else
infomsg "[dev-env]: down cancelled"
fi

19
info
View File

@ -2,9 +2,9 @@
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CONFIG_FILE="$ENV_DIR/.systems"
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
denv_info_msg "[dev-env]: $ENV_DIR"
importantmsg "[dev-env]: $ENV_DIR"
# Iterate through all lines in .systems configuration
while IFS=' ' read -r IDENTIFIER DIRECTORY GIT; do
@ -12,5 +12,18 @@ while IFS=' ' read -r IDENTIFIER DIRECTORY GIT; do
if [[ "$IDENTIFIER" =~ ^#.* ]] || [ -z "$IDENTIFIER" ]; then
continue
fi
denv_echo_msg "[$IDENTIFIER]: systems/$DIRECTORY"
SYSTEM_PATH=$(realpath "$ENV_DIR/systems/$DIRECTORY")
BRANCH=$(git -C "$SYSTEM_PATH" rev-parse --abbrev-ref HEAD)
if [ -n "$(git -C "$SYSTEM_PATH" status --porcelain)" ]; then
CHANGES="(X)"
else
CHANGES=""
fi
infomsg "[$IDENTIFIER]: ./systems/$DIRECTORY ${ANSI_OPEN}91m($BRANCH)${ANSI_OPEN}93m $CHANGES${ANSI_OPEN}0m"
done < "$CONFIG_FILE"
echo ""
docker ps

26
init
View File

@ -1,28 +1,38 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
# Check docker-compose.yml file
if [ ! -f "$ENV_DIR/docker/docker-compose.yml" ]
then
cp "$ENV_DIR/docker/docker-compose.yml.dist" "$ENV_DIR/docker/docker-compose.yml"
denv_info_msg "[dev-env]: docker-compose.yml created"
infomsg "[dev-env]: docker-compose.yml created"
fi
# Check .systems file
if [ ! -f "$ENV_DIR/.systems" ]
then
cp "$ENV_DIR/.systems.example" "$ENV_DIR/.systems"
infomsg "[dev-env]: .systems created"
fi
# Update .aliases
denv_info_msg "[dev-env]: Update dev-env/.aliases"
importantmsg "[dev-env]: Update dev-env/.aliases"
$ENV_DIR/script/write_aliases
denv_success_msg "[dev-env]: Successfully updated dev-env/.aliases"
successmsg "[dev-env]: Update dev-env/.aliases done"
echo ""
# Update .profile
denv_info_msg "[dev-env]: Update ~/.profile"
importantmsg "[dev-env]: Update ~/.profile"
$ENV_DIR/script/update_profile
denv_success_msg "[dev-env]: Successfully updated ~/.profile"
successmsg "[dev-env]: Update ~/.profile done"
echo ""
# Clone all systems.
denv_info_msg "[dev-env]: Clone systems"
importantmsg "[dev-env]: Clone systems"
$ENV_DIR/script/clone
denv_success_msg "[dev-env]: Cloned systems"
successmsg "[dev-env]: Clone systems done"
echo ""
# Run init for all systems
$ENV_DIR/script/foreachSystem/runScript init

21
prune Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $ENV_DIR/bin/messages
warnmsg "This script will remove all docker containers and images"
warnmsg "All your data will be lost, and you will have a \"clean\" dev-env again"
warnmsg "Do you want to continue? (y/n)"
read -p "Answer: " ANSWER
echo ""
if [[ "$ANSWER" == "y" || "$ANSWER" == "Y" ]]; then
infomsg "[dev-env]: Clearing docker"
docker rm -vf $(docker ps -aq)
docker rmi -f $(docker images -aq)
docker network prune -f
echo ""
docker ps
else
infomsg "[dev-env]: prune cancelled"
fi

View File

@ -1,11 +1,11 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
CONFIG_FILE="$ENV_DIR/.systems"
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
# Check if .systems configuration exists
if [ ! -f "$CONFIG_FILE" ]; then
denv_error_msg "$CONFIG_FILE not found."
errormsg "$CONFIG_FILE not found."
exit 1
fi
@ -16,17 +16,15 @@ while IFS=' ' read -r IDENTIFIER DIRECTORY GIT; do
continue
fi
denv_info_msg "[$IDENTIFIER]"
DIRECTORY="systems/$DIRECTORY"
SYSTEM_PATH="$ENV_DIR/systems/$DIRECTORY"
DIRECTORY="./systems/$DIRECTORY"
# Check if system directory already exists
if [ ! -d "$DIRECTORY" ]; then
denv_info_msg "Clone into directory '$DIRECTORY'..."
git clone "$GIT" "$DIRECTORY"
denv_success_msg "Successfully cloned $IDENTIFIER"
if [ ! -d "$SYSTEM_PATH" ]; then
infomsg "[$IDENTIFIER] Clone into directory '$DIRECTORY'..."
git clone -b develop "$GIT" "$SYSTEM_PATH"
successmsg "Successfully cloned $IDENTIFIER"
else
denv_echo_msg "Directory '$DIRECTORY' already exists. Skipping..."
echo ""
warnmsg "[$IDENTIFIER] Directory '$DIRECTORY' already exists. Skipping..."
fi
done < "$CONFIG_FILE"

View File

@ -1,6 +1,6 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../.." &> /dev/null && pwd )
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
source $ENV_DIR/bin/dcom
COMMAND="$@"
@ -8,11 +8,11 @@ CONFIG_FILE="$ENV_DIR/.systems"
# Check if .systems configuration exists
if [ ! -f "$CONFIG_FILE" ]; then
denv_error_msg "$CONFIG_FILE not found."
errormsg "$CONFIG_FILE not found."
exit 1
fi
denv_info_msg "[dev-env]: Executing $COMMAND for all systems"
importantmsg "[dev-env]: Executing docker-compose $COMMAND for all systems"
while IFS=' ' read -r IDENTIFIER DIRECTORY GIT; do # Iterate through all lines in .systems configuration
if [[ "$IDENTIFIER" =~ ^#.* ]] || [ -z "$IDENTIFIER" ]; then # Skip comments and emtpy lines

View File

@ -3,15 +3,15 @@ ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../.." &> /dev/null && pwd
CONFIG_FILE="$ENV_DIR/.systems"
COMMAND="$@"
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
# Check if .systems configuration exists
if [ ! -f "$CONFIG_FILE" ]; then
denv_error_msg "$CONFIG_FILE not found."
errormsg "$CONFIG_FILE not found."
exit 1
fi
denv_info_msg "[dev-env]: Execute $COMMAND for all systems"
importantmsg "[dev-env]: Execute $COMMAND for all systems"
# Iterate through all lines in .systems configuration
while IFS=' ' read -r IDENTIFIER DIRECTORY GIT; do
@ -25,12 +25,15 @@ while IFS=' ' read -r IDENTIFIER DIRECTORY GIT; do
# Check if system directory already exists
if [ ! -f "$COMMAND_PATH" ]; then
denv_error_msg "$COMMAND_PATH not found."
errormsg "$COMMAND_PATH not found."
continue
fi
denv_info_msg "[$IDENTIFIER]: $COMMAND"
importantmsg "[$IDENTIFIER]: $COMMAND"
$COMMAND_PATH
denv_success_msg "[$IDENTIFIER]: $COMMAND completed successfully"
successmsg "[$IDENTIFIER]: $COMMAND completed successfully"
echo ""
done < "$CONFIG_FILE"
successmsg "[dev-env]: Executed $COMMAND for all systems"

View File

@ -1,7 +1,6 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
PROFILE_FILE="$HOME/.profile"
TEMPLATE_FILE="$ENV_DIR/.profile.template"
@ -12,7 +11,7 @@ END_MARKER="#DEV ENV SETUP END"
# Check if template file exists
if [ ! -f "$TEMPLATE_FILE" ]; then
denv_error_msg "[dev-env]: Template file '$TEMPLATE_FILE' does not exist. Skip updating .profile."
errormsg "[dev-env]: Template file '$TEMPLATE_FILE' does not exist. Skip updating .profile."
exit 1
fi
@ -20,12 +19,12 @@ TEMPLATE_CONTENT=$(<"$TEMPLATE_FILE")
# Check if start marker already exists in profile file
if grep -q "$START_MARKER" "$PROFILE_FILE"; then
denv_echo_msg "[dev-env]: Section already exists. Update contents..."
warnmsg "[dev-env]: Section already exists. Update contents..."
# Remove contents between start and end marker
sed -i "/$START_MARKER/,/$END_MARKER/d" "$PROFILE_FILE"
else
denv_echo_msg "[dev-env]: Section does not exists. Adding contents..."
infomsg "[dev-env]: Section does not exists. Adding contents..."
fi
ENV_DIR_STRING="# path\nDEV_ENV_PATH=$ENV_DIR\n"

View File

@ -1,11 +1,11 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
CONFIG_FILE="$ENV_DIR/.systems"
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
# Check if .systems configuration exists
if [ ! -f "$CONFIG_FILE" ]; then
denv_error_msg "$CONFIG_FILE not found."
errormsg "$CONFIG_FILE not found."
exit 1
fi

9
stop
View File

@ -1,12 +1,11 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
$ENV_DIR/script/foreachSystem/dcom stop
infomsg "[dev-env]: Executing docker-compose stop for dev-env"
docker compose -f "$ENV_DIR/docker/docker-compose.yml" stop
echo ""
denv_info_msg "[dev-env] stop"
docker compose -f "$ENV_DIR/docker/docker-compose.yml" stop
docker ps

10
up
View File

@ -1,15 +1,19 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $ENV_DIR/bin/denv_msg
source $ENV_DIR/bin/messages
denv_info_msg "[dev-env]: up -d"
infomsg "[dev-env]: Executing docker-compose up -d for dev-env"
docker compose -f "$ENV_DIR/docker/docker-compose.yml" up -d
echo ""
$ENV_DIR/script/foreachSystem/dcom up -d
if [[ ! -f "$ENV_DIR/.firstRun" ]] ; then
# Setup databases for all systems
importantmsg "[dev-env]: Setup databases"
$ENV_DIR/script/create_databases
successmsg "[dev-env]: Setup databases done"
$ENV_DIR/script/foreachSystem/runScript firstRun
touch "$ENV_DIR/.firstRun"
fi