This commit is contained in:
Flo 2024-12-21 03:19:46 +01:00
parent 9dde2c0aeb
commit 76819f7b95
8 changed files with 61 additions and 9 deletions

2
.gitignore vendored
View File

@ -7,5 +7,5 @@ systems/*
var/
.alias
.aliases
.systems

View File

@ -1,11 +1,25 @@
# GIT branch in bash START
# bin
. $DEV_ENV_PATH/bin/denv
. $DEV_ENV_PATH/bin/dcom
. $DEV_ENV_PATH/bin/drun
. $DEV_ENV_PATH/bin/git
# /bin
# alias
if [ -f "$DEV_ENV_PATH/.aliases" ]; then
. "$DEV_ENV_PATH/.aliases"
fi
# /alias
# GIT branch in bash
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
# GIT branch in bash END
# /GIT branch in bash
# SSH Setup START
# SSH
SSH_ENV="$HOME/.ssh/agent-environment"
function start_agent {
echo "Initialising new SSH agent..."
@ -26,4 +40,4 @@ if [ -f "$SSH_ENV" ]; then
else
start_agent
fi
# SSH Setup END
# /SSH

View File

@ -2,7 +2,7 @@
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../" &> /dev/null && pwd )
denv() {
if [ ! -z $1 ] then
if [ ! -z $1 ] ; then
$ENV_DIR/$1
else
cd $ENV_DIR

View File

@ -16,7 +16,11 @@ drun() {
return 1
fi
if [[ -t 0 && -t 1 ]]; then
docker exec -it "$CONTAINER_ID" $COMMAND
else
docker exec "$CONTAINER_ID" $COMMAND
fi
}
_drun_completion() {

4
init
View File

@ -9,6 +9,10 @@ then
denv_info_msg "[dev-env]: docker-compose.yml created"
fi
# Update .aliases
$ENV_DIR/script/write_aliases
echo ""
# Update .profile
$ENV_DIR/script/update_profile
echo ""

View File

@ -30,7 +30,8 @@ else
denv_echo_msg "[dev-env]: Section does not exists. Adding contents..."
fi
ENV_DIR_STRING="#DEV-ENV\nDEV_ENV_PATH=$ENV_DIR\n#DEV-ENV"
# Add contents
echo -e "\n$START_MARKER\n$TEMPLATE_CONTENT\n$END_MARKER" >> "$PROFILE_FILE"
echo -e "\n$START_MARKER\n$ENV_DIR_STRING\n$TEMPLATE_CONTENT\n$END_MARKER" >> "$PROFILE_FILE"
denv_success_msg "[dev-env]: Successfully updated $PROFILE_FILE"

24
script/write_aliases Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
CONFIG_FILE="$ENV_DIR/.systems"
source $ENV_DIR/bin/denv_msg
# Check if .systems configuration exists
if [ ! -f "$CONFIG_FILE" ]; then
denv_error_msg "$CONFIG_FILE not found."
exit 1
fi
echo "" > "$ENV_DIR/.aliases"
# Iterate through all lines in .systems configuration
while IFS=' ' read -r IDENTIFIER DIRECTORY GIT; do
# Skip comments and emtpy lines
if [[ "$IDENTIFIER" =~ ^#.* ]] || [ -z "$IDENTIFIER" ]; then
continue
fi
DIRECTORY="systems/$DIRECTORY"
echo "alias goto-$IDENTIFIER='cd \$DEV_ENV_PATH/$DIRECTORY'" >> "$ENV_DIR/.aliases"
done < "$CONFIG_FILE"

5
up
View File

@ -8,3 +8,8 @@ docker compose -f "$ENV_DIR/docker/docker-compose.yml" up -d
echo ""
$ENV_DIR/script/foreachSystem/dcom up -d
if [[ ! -f "$ENV_DIR/var/.firstRun" ]] ; then
$ENV_DIR/script/foreachSystem/runScript firstRun
touch "$ENV_DIR/var/.firstRun"
fi