diff --git a/provision.sh b/provision.sh index e02b329..b48b988 100755 --- a/provision.sh +++ b/provision.sh @@ -21,7 +21,16 @@ if [ -f /etc/os-release ]; then fi # IP Address Retrieval -IP=$(hostname -I | awk '{print $1}') +echo -e "${YELLOW}LOG: Determining primary IPv4 address...${NC}" +if command -v hostname >/dev/null 2>&1 && hostname -I >/dev/null 2>&1; then + IP=$(hostname -I | awk '{print $1}') +elif command -v ip >/dev/null 2>&1; then + IP=$(ip route get 1.1.1.1 2>/dev/null | awk '/src/ {print $NF; exit}') +elif command -v ifconfig >/dev/null 2>&1; then + IP=$(ifconfig | awk '/inet /{print $2}' | grep -v '^127' | head -n1) +else + IP="127.0.0.1" +fi # Install Prerequisites (Git, Make, Zsh, Sudo) echo -e "${YELLOW}LOG: Updating system and installing base tools...${NC}" diff --git a/setup.sh b/setup.sh index fe6a586..2303c87 100755 --- a/setup.sh +++ b/setup.sh @@ -15,11 +15,16 @@ NC='\033[0m' # OS Detection echo -e "${BLUE} LOG:${YELLOW} Checking System...${NC}" +OS="unknown" if [ -f /etc/os-release ]; then . /etc/os-release OS=$ID fi +if [ "$OS" = "unknown" ] || [ -z "$OS" ]; then + echo -e "${RED} ERROR:${NC} Could not detect operating system. /etc/os-release not found or ID not set." + exit 1 +fi # Package Installation PACKAGES=( curl wget git sudo @@ -76,10 +81,10 @@ fi if [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then FINAL_LIST="$FINAL_LIST ca-certificates bsdmainutils pkg-config cmake" -fi - -echo -e "${BLUE} LOG:${YELLOW} Installing: ${NC}$FINAL_LIST" - + sudo pacman -S --noconfirm --needed "$FINAL_LIST" +elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then + sudo DEBIAN_FRONTEND=noninteractive apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "$FINAL_LIST" if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then sudo pacman -S --noconfirm --needed $FINAL_LIST elif [ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ]; then @@ -165,13 +170,13 @@ fi echo -e "${BLUE} LOG:${YELLOW} Configuring Git Credentials...${NC}" if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null; then - GCM_WIN="/mnt/c/Program Files/Git/mingw64/bin/git-credential-manager.exe" + # Linux Server: Cache credentials for 12 hours if [ -f "$GCM_WIN" ]; then git config --global credential.helper "! \"$GCM_WIN\"" fi else # Linux Server: Cache credentials for 12 hour - git config --global credential.helper 'cache --timeout=43200' + git config --global credential.helper 'cache --timeout=43200 --replace-all' fi # Docker Group