From c34089f0bc42f3575fdd76813dc51cdda9d3e98d Mon Sep 17 00:00:00 2001 From: anorien90 Date: Tue, 9 Dec 2025 16:20:00 +0100 Subject: [PATCH] fixed ENV for .bashrc and .zshrc --- dist/{.shellrc => .baserc} | 0 dist/init_rc.sh | 23 +++++++++++++++++++++++ dist/pacman.sh | 4 +--- 3 files changed, 24 insertions(+), 3 deletions(-) rename dist/{.shellrc => .baserc} (100%) create mode 100644 dist/init_rc.sh diff --git a/dist/.shellrc b/dist/.baserc similarity index 100% rename from dist/.shellrc rename to dist/.baserc diff --git a/dist/init_rc.sh b/dist/init_rc.sh new file mode 100644 index 0000000..b1fe4ad --- /dev/null +++ b/dist/init_rc.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# detect if either .bashrc or .zshrc is present + +if [ -f "$HOME/.bashrc" ]; then + SHELL_RC="$HOME/.bashrc" +elif [ -f "$HOME/.zshrc" ]; then + SHELL_RC="$HOME/.zshrc" +else + echo "No .bashrc or .zshrc file found in home directory." + exit 1 +fi + +echo "Using shell rc file: $SHELL_RC" + +# Check if content already exists in the shell rc file and if not, append it + +if ! grep -q "export PATH=\$PATH:\$HOME/.local/bin" "$SHELL_RC"; then + echo "Adding .local/bin to PATH in $SHELL_RC" + echo 'export PATH=$PATH:$HOME/.local/bin' >> "$SHELL_RC" +else + echo ".local/bin is already in PATH in $SHELL_RC" +fi diff --git a/dist/pacman.sh b/dist/pacman.sh index cf4c3c7..95ca188 100755 --- a/dist/pacman.sh +++ b/dist/pacman.sh @@ -73,10 +73,8 @@ else yes | su - "$BUILD_USER" -c "paru -S --noconfirm ${paru_packages[*]}" yes | su - "$BUILD_USER" -c "yes | sdkmanager --licenses" yes | su - "$BUILD_USER" -c "yes | sudo pacman -Syu --noconfirm gradle" + yes | su - "$BUILD_USER" -c "dist/init_rc.sh" # check if bashrc or zshrc contains sdkman initialization, if not add it - SHELL_RC_CONTENT="$(echo dist/.shellrc)" - echo "Checking shell rc for sdkman initialization..." - yes | su - "$BUILD_USER" -c "if [[ -f ~/.bashrc ]]; then echo ${SHELL_RC_CONTENT} >> ~/.bashrc; fi else if [[ -f ~/.zshrc ]]; then echo ${SHELL_RC_CONTENT} >> ~/.zshrc; fi" fi