From 10909bc66f2e2c824f420425b51a3e9a1ad737cf Mon Sep 17 00:00:00 2001 From: Hector van der Aa Date: Tue, 21 Apr 2026 15:25:14 +0000 Subject: [PATCH] Updated --- part1.sh | 176 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 140 insertions(+), 36 deletions(-) diff --git a/part1.sh b/part1.sh index b2f0a41..15bb801 100755 --- a/part1.sh +++ b/part1.sh @@ -1,50 +1,154 @@ #!/bin/bash +set -euo pipefail -cd ~ -# Update system -sudo pacman -Syu +# ------------------------------- +# Helpers +# ------------------------------- +info() { + printf '\n==> %s\n' "$1" +} -# Install base utils -sudo pacman -S --needed git which base-devel +append_if_missing() { + local line="$1" + local file="$2" + touch "$file" + grep -qxF "$line" "$file" || echo "$line" >>"$file" +} -# Install yay -git clone https://aur.archlinux.org/yay.git -cd yay -makepkg -si -cd ~ -rm -rf yay +# ------------------------------- +# Paths and config +# ------------------------------- +HOME_DIR="$HOME" +BASHRC="$HOME_DIR/.bashrc" +SSH_KEY_PATH="$HOME_DIR/.ssh/id_ed25519" +SSH_KEY_EMAIL="hector@h3cx.dev" +DOTFILES_REPO="gitea@git.h3cx.dev:h3cx/HectorsDotFiles.git" +WALLPAPERS_REPO="gitea@git.h3cx.dev:h3cx/HectorsWallpapers.git" +CONFIG_BACKUP="$HOME_DIR/.config.backup.$(date +%Y%m%d-%H%M%S)" +WALLPAPER_TARGET="$HOME_DIR/.local/share/wallpapers" +TMP_DIR="$(mktemp -d)" -# Install zen-browser -yay -S zen-browser-bin +cleanup() { + rm -rf "$TMP_DIR" +} +trap cleanup EXIT -# Install font -sudo pacman -S ttf-jetbrains-mono-nerd +cd "$HOME_DIR" -# Install clipboard -sudo pacman -S cliphist wl-clipboard +# ------------------------------- +# System update and packages +# ------------------------------- +info "Updating system" +sudo pacman -Syu --noconfirm -# Install nvim -sudo pacman -S nvim +info "Installing base packages" +sudo pacman -S --needed --noconfirm \ + git \ + which \ + base-devel \ + ttf-jetbrains-mono-nerd \ + cliphist \ + wl-clipboard \ + neovim \ + starship \ + lazygit \ + openssh -# Install ble.sh -git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git -make -C ble.sh install PREFIX=~/.local -echo 'source -- ~/.local/share/blesh/ble.sh' >>~/.bashrc -cd ~ -rm -rf ble.sh +# ------------------------------- +# yay +# ------------------------------- +if ! command -v yay >/dev/null 2>&1; then + info "Installing yay" + git clone https://aur.archlinux.org/yay.git "$TMP_DIR/yay" + ( + cd "$TMP_DIR/yay" + makepkg -si --noconfirm + ) +else + info "yay already installed" +fi -# Install starship -sudo pacman -S starship -grep -qxF 'eval "$(starship init bash)"' ~/.bashrc || echo 'eval "$(starship init bash)"' >>~/.bashrc -source ~/.bashrc -stty sane +# ------------------------------- +# AUR packages +# ------------------------------- +info "Installing AUR packages" +yay -S --needed --noconfirm zen-browser-bin -# Install lazygit -sudo pacman -S lazygit +# ------------------------------- +# ble.sh +# ------------------------------- +if [ ! -f "$HOME_DIR/.local/share/blesh/ble.sh" ]; then + info "Installing ble.sh" + git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git "$TMP_DIR/ble.sh" + make -C "$TMP_DIR/ble.sh" install PREFIX="$HOME_DIR/.local" +else + info "ble.sh already installed" +fi +append_if_missing 'source -- ~/.local/share/blesh/ble.sh' "$BASHRC" -# Setup git -git config --global user.email "hector@h3cx.dev" +# ------------------------------- +# Shell setup +# ------------------------------- +info "Configuring shell" +append_if_missing 'eval "$(starship init bash)"' "$BASHRC" +stty sane || true + +# ------------------------------- +# Git setup +# ------------------------------- +info "Configuring git" +git config --global user.email "$SSH_KEY_EMAIL" git config --global user.name "Hector van der Aa" -# Generate ssh-keys -ssh-keygen +# ------------------------------- +# SSH key setup for Gitea +# ------------------------------- +info "Preparing SSH key for git access" +mkdir -p "$HOME_DIR/.ssh" +chmod 700 "$HOME_DIR/.ssh" + +if [ ! -f "$SSH_KEY_PATH" ]; then + ssh-keygen -t ed25519 -C "$SSH_KEY_EMAIL" -f "$SSH_KEY_PATH" -N "" +else + info "SSH key already exists at $SSH_KEY_PATH, reusing it" +fi + +chmod 600 "$SSH_KEY_PATH" +chmod 644 "$SSH_KEY_PATH.pub" + +if command -v ssh-keyscan >/dev/null 2>&1; then + touch "$HOME_DIR/.ssh/known_hosts" + ssh-keyscan -H git.h3cx.dev >>"$HOME_DIR/.ssh/known_hosts" 2>/dev/null || true +fi + +if command -v wl-copy >/dev/null 2>&1; then + wl-copy <"$SSH_KEY_PATH.pub" + info "Your public SSH key has been copied to the clipboard" +else + info "wl-copy not found, public key is below" + cat "$SSH_KEY_PATH.pub" +fi + +echo +echo "Add this SSH public key as an authorized key in your Gitea account:" +echo " $SSH_KEY_PATH.pub" +echo +read -rp "Press Enter once the key has been added to git.h3cx.dev... " + +# ------------------------------- +# Clone private repositories +# ------------------------------- +info "Replacing ~/.config with HectorsDotFiles" +if [ -d "$HOME_DIR/.config" ]; then + mv "$HOME_DIR/.config" "$CONFIG_BACKUP" + info "Existing ~/.config moved to $CONFIG_BACKUP" +fi +git clone "$DOTFILES_REPO" "$HOME_DIR/.config" + +info "Installing wallpapers repository" +mkdir -p "$HOME_DIR/.local/share" +rm -rf "$WALLPAPER_TARGET" +git clone "$WALLPAPERS_REPO" "$WALLPAPER_TARGET" + +info "Post-install section completed" +echo "You may want to restart your shell or run: source ~/.bashrc"