This commit is contained in:
MangoPig
2026-06-01 00:28:14 +01:00
parent 58531bf579
commit 52054493cc
8 changed files with 231 additions and 40 deletions

View File

@@ -18,11 +18,15 @@ echo -e "${BLUE} LOG:${YELLOW} Initializing Base System Layer...${NC}"
# Confirm Architecture
ARCH=$(uname -m)
if [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "aarch64" ]; then
if [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "aarch64" ] && [ "$ARCH" != "arm64" ]; then
echo -e "${RED} ERROR: Unsupported architecture: $ARCH${NC}"
exit 1
fi
is_wsl() {
[ -f /proc/version ] && grep -qEi "(Microsoft|WSL)" /proc/version
}
# Package Installation
PACKAGES=(
curl wget git sudo
@@ -51,6 +55,8 @@ for pkg in "${PACKAGES[@]}"; do
FINAL_PACKAGES+=(build-essential)
elif is_fedora_family; then
FINAL_PACKAGES+=(gcc gcc-c++ make patch)
elif is_macos; then
:
fi
continue
;;
@@ -61,6 +67,8 @@ for pkg in "${PACKAGES[@]}"; do
FINAL_PACKAGES+=(python3 python3-pip python3-venv)
elif is_fedora_family; then
FINAL_PACKAGES+=(python3 python3-pip)
elif is_macos; then
FINAL_PACKAGES+=(python)
fi
continue
;;
@@ -83,6 +91,8 @@ for pkg in "${PACKAGES[@]}"; do
FINAL_PACKAGES+=(libssl-dev)
elif is_fedora_family; then
FINAL_PACKAGES+=(openssl openssl-devel)
elif is_macos; then
FINAL_PACKAGES+=(openssl@3)
fi
continue
;;
@@ -93,6 +103,8 @@ for pkg in "${PACKAGES[@]}"; do
FINAL_PACKAGES+=(dnsutils)
elif is_fedora_family; then
FINAL_PACKAGES+=(bind-utils)
elif is_macos; then
FINAL_PACKAGES+=(bind)
fi
continue
;;
@@ -101,6 +113,8 @@ for pkg in "${PACKAGES[@]}"; do
FINAL_PACKAGES+=(ninja)
elif is_debian_family || is_fedora_family; then
FINAL_PACKAGES+=(ninja-build)
elif is_macos; then
FINAL_PACKAGES+=(ninja)
fi
continue
;;
@@ -111,12 +125,16 @@ for pkg in "${PACKAGES[@]}"; do
FINAL_PACKAGES+=(libcurl4-openssl-dev)
elif is_fedora_family; then
FINAL_PACKAGES+=(libcurl-devel)
elif is_macos; then
FINAL_PACKAGES+=(curl)
fi
continue
;;
"gnupg")
if is_fedora_family; then
FINAL_PACKAGES+=(gnupg2)
elif is_macos; then
FINAL_PACKAGES+=(gnupg)
else
FINAL_PACKAGES+=(gnupg)
fi
@@ -137,6 +155,18 @@ if is_fedora_family; then
FINAL_PACKAGES+=(R-core gcc-gfortran bzip2 bzip2-devel readline-devel sqlite sqlite-devel tk-devel libffi-devel xz xz-devel ncurses-devel zlib-devel findutils llvm)
fi
if is_macos; then
FINAL_PACKAGES=(
curl wget git zsh tmux unzip
python bison mercurial
ripgrep fd bat fzf jq
btop httpie gnupg
zoxide stow direnv
bind nmap socat
hexyl ninja just
)
fi
echo -e "${BLUE} LOG:${YELLOW} Installing: ${NC}${FINAL_PACKAGES[*]}"
install_status=0
@@ -160,48 +190,60 @@ bash "$REPO_ROOT/Scripts/bin/install.sh" --all
if ! command -v rclone &> /dev/null; then
echo -e "${BLUE} LOG:${YELLOW} Installing Rclone CLI...${NC}"
case "$ARCH" in
x86_64)
RCLONE_ARCH="amd64"
;;
aarch64)
RCLONE_ARCH="arm64"
;;
esac
if is_macos; then
brew install rclone
else
TEMP_DIR="$(mktemp -d)"
RCLONE_ZIP="$TEMP_DIR/rclone.zip"
case "$ARCH" in
x86_64)
RCLONE_ARCH="amd64"
;;
aarch64|arm64)
RCLONE_ARCH="arm64"
;;
esac
curl -fLsS "https://downloads.rclone.org/rclone-current-linux-${RCLONE_ARCH}.zip" -o "$RCLONE_ZIP"
unzip -q "$RCLONE_ZIP" -d "$TEMP_DIR"
install -m 755 "$TEMP_DIR"/rclone-*-linux-"${RCLONE_ARCH}"/rclone "$HOME/.local/bin/rclone"
rm -rf "$TEMP_DIR"
TEMP_DIR="$(mktemp -d)"
RCLONE_ZIP="$TEMP_DIR/rclone.zip"
curl -fLsS "https://downloads.rclone.org/rclone-current-linux-${RCLONE_ARCH}.zip" -o "$RCLONE_ZIP"
unzip -q "$RCLONE_ZIP" -d "$TEMP_DIR"
install -m 755 "$TEMP_DIR"/rclone-*-linux-"${RCLONE_ARCH}"/rclone "$HOME/.local/bin/rclone"
rm -rf "$TEMP_DIR"
fi
fi
if ! command -v earthly &> /dev/null; then
echo -e "${BLUE} LOG:${YELLOW} Installing Earthly CLI...${NC}"
case "$ARCH" in
x86_64)
EARTHLY_ARCH="amd64"
;;
aarch64)
EARTHLY_ARCH="arm64"
;;
esac
if is_macos; then
brew install earthly
else
curl -fLsS "https://github.com/earthly/earthly/releases/latest/download/earthly-linux-${EARTHLY_ARCH}" \
-o "$HOME/.local/bin/earthly"
chmod +x "$HOME/.local/bin/earthly"
case "$ARCH" in
x86_64)
EARTHLY_ARCH="amd64"
;;
aarch64|arm64)
EARTHLY_ARCH="arm64"
;;
esac
curl -fLsS "https://github.com/earthly/earthly/releases/latest/download/earthly-linux-${EARTHLY_ARCH}" \
-o "$HOME/.local/bin/earthly"
chmod +x "$HOME/.local/bin/earthly"
fi
fi
# Docker Installation
if command -v docker &> /dev/null; then
echo -e "${GREEN} LOG: Docker is already installed.${NC}"
else
if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null; then
if is_wsl; then
echo -e "${RED} LOG: WSL Detected! Skipping Native Docker.${NC}"
echo -e "${RED} >>> Please install Docker Desktop on Windows.${NC}"
elif is_macos; then
echo -e "${YELLOW} NOTE:${NC} Docker is not installed. Please install Docker Desktop for macOS manually."
else
echo -e "${BLUE} LOG:${YELLOW} Installing Native Docker...${NC}"
if is_arch_family; then
@@ -220,7 +262,7 @@ else
fi
# Add user to group
if getent group docker >/dev/null 2>&1; then
if command -v getent >/dev/null 2>&1 && getent group docker >/dev/null 2>&1; then
sudo usermod -aG docker $(whoami)
fi
fi
@@ -239,7 +281,7 @@ mkdir -p "$ZSH_CUSTOM/plugins"
[ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ] && git clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM/plugins/zsh-autosuggestions"
# 5. Git Credentials (WSL Bridge)
if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null; then
if is_wsl; then
GCM_WIN="/mnt/c/Program Files/Git/mingw64/bin/git-credential-manager.exe"
[ -f "$GCM_WIN" ] && git config --global credential.helper "! \"$GCM_WIN\""
else
@@ -253,10 +295,21 @@ touch "$REPO_ROOT/Zsh/.zsh_secrets"
# 7. Set Shell
TARGET_SHELL="$(command -v zsh)"
CURRENT_LOGIN_SHELL="$(getent passwd "$(whoami)" | cut -d: -f7)"
CURRENT_LOGIN_SHELL=""
if command -v getent >/dev/null 2>&1; then
CURRENT_LOGIN_SHELL="$(getent passwd "$(whoami)" | cut -d: -f7)"
elif is_macos && command -v dscl >/dev/null 2>&1; then
CURRENT_LOGIN_SHELL="$(dscl . -read "/Users/$(whoami)" UserShell 2>/dev/null | awk '{print $2}')"
fi
if [ "$CURRENT_LOGIN_SHELL" != "$TARGET_SHELL" ]; then
if command -v chsh >/dev/null 2>&1; then
if [ ! -t 0 ]; then
echo -e "${YELLOW} NOTE:${NC} Non-interactive session detected. Skipping login shell change to $TARGET_SHELL."
echo -e "${YELLOW} NOTE:${NC} Run 'chsh -s $TARGET_SHELL' manually later if you want zsh as your login shell."
elif is_macos && command -v chsh >/dev/null 2>&1; then
chsh -s "$TARGET_SHELL"
elif command -v chsh >/dev/null 2>&1; then
sudo chsh -s "$TARGET_SHELL" "$(whoami)"
elif command -v usermod >/dev/null 2>&1; then
sudo usermod -s "$TARGET_SHELL" "$(whoami)"