#!/bin/bash

# detect if either .bashrc or .zshrc is present


# check if user is root and change user to builder 
TEMP_USER="builder"

if [ "$EUID" -eq 0 ]; then
    BUILD_USER="$TEMP_USER"
else
    BUILD_USER="$USER"
fi


if [ -f "/home/$BUILD_USER/.bashrc" ]; then
    SHELL_RC="/home/$BUILD_USER/.bashrc"
elif [ -f "/home/$BUILD_USER/.zshrc" ]; then
    SHELL_RC="/home/$BUILD_USER/.zshrc"
else
    touch "/home/$BUILD_USER/.bashrc"
    SHELL_RC="/home/$BUILD_USER/.bashrc"
fi

echo "Using shell rc file: $SHELL_RC"

cat dist/.baserc >> "$SHELL_RC"

source "$SHELL_RC"
