diff --git a/.bashrc b/.bashrc index 43049e4..e3e40d5 100644 --- a/.bashrc +++ b/.bashrc @@ -18,3 +18,8 @@ alias la='ls -la' fastfetch + +# Added by LM Studio CLI (lms) +export PATH="$PATH:/home/jake/.lmstudio/bin" +# End of LM Studio CLI section + diff --git a/omarchy_package_install.sh b/omarchy_package_install.sh deleted file mode 100644 index 2a94fac..0000000 --- a/omarchy_package_install.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# -pacman_to_add=( - "tree" - "ttf-fira-code" - "cronie" -) - -aur_to_add=( - "bazecor" - "lmstudio-bin" -) - -package_str=(IFS=' ' ; echo "${pacman_to_add[@]}") -aur_str=(IFS=' ' ; echo "${aur_to_add[@]}") - - -omarchy-pkg-add $package_str -omarchy-pkg-aur-add $aur_str diff --git a/restore_cron_jobs.sh b/restore_cron_jobs.sh deleted file mode 100644 index 188f03c..0000000 --- a/restore_cron_jobs.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -# - -# Copy cron tasks to /usr/local/bin -cp /mnt/nas/Jake/cron_tasks/*.sh /usr/local/bin/ - -# Restore from your saved file -crontab < /mnt/nas/Jake/cron_tasks/cron_backup diff --git a/restore_ssh_gpg.sh b/restore_ssh_gpg.sh deleted file mode 100755 index 2a5f748..0000000 --- a/restore_ssh_gpg.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# FIRST, MOUNT NAS AT /mnt/nas/ - -REMOTE="/mnt/nas/Jake - -echo "📥 Pulling SSH keys..." -rsync "$REMOTE/ssh/id_rsa" ~/.ssh/ && chmod 600 ~/.ssh/id_rsa -rsync "$REMOTE/ssh/id_rsa.pub" ~/.ssh/ && chmod 644 ~/.ssh/id_rsa.pub -rsync "$REMOTE/ssh/config" ~/.ssh/ && chmod 644 ~/.ssh/config - -echo "📥 Pulling GPG key..." -rsync "$REMOTE/ssh/my-gpg-key.asc" ~/ - -echo "🔑 Importing GPG key..." -gpg --import ~/my-gpg-key.asc -rm ~/my-gpg-key.asc # Clean up after import - -echo "✅ SSH and GPG setup complete!" diff --git a/scripts/generic/restore_cron_jobs.sh b/scripts/generic/restore_cron_jobs.sh new file mode 100755 index 0000000..6c6830a --- /dev/null +++ b/scripts/generic/restore_cron_jobs.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# + +# Copy cron tasks to /usr/local/bin only if source is newer +for script in /mnt/nas/Jake/cron_tasks/*.sh; do + if [ -f "$script" ]; then + basename=$(basename "$script") + dest="/usr/local/bin/$basename" + if [ ! -f "$dest" ] || [ "$(stat -c %Y "$script")" -gt "$(stat -c %Y "$dest" 2>/dev/null || echo 0)" ]; then + sudo cp "$script" "$dest" + echo " Updated $basename" + else + echo " Skipped $basename (up to date)" + fi + fi +done + +# Restore crontab only if backup is newer than current crontab +CRON_BACKUP="/mnt/nas/Jake/cron_tasks/cron_backup" +if [ -f "$CRON_BACKUP" ]; then + CURRENT_CRON=$(mktemp) + crontab -l >"$CURRENT_CRON" 2>/dev/null || true + + if ! diff -q "$CURRENT_CRON" "$CRON_BACKUP" >/dev/null 2>&1; then + crontab < "$CRON_BACKUP" + echo " Cron jobs updated" + else + echo " Cron jobs up to date" + fi + + rm -f "$CURRENT_CRON" +else + echo "Error: Cron backup file not found at $CRON_BACKUP" >&2 + exit 1 +fi diff --git a/restore_git_backup.sh b/scripts/generic/restore_git_backup.sh similarity index 73% rename from restore_git_backup.sh rename to scripts/generic/restore_git_backup.sh index 0427b60..3639a2f 100755 --- a/restore_git_backup.sh +++ b/scripts/generic/restore_git_backup.sh @@ -24,13 +24,26 @@ restore_project() { exit 1 fi + local target_dir="$REPO_SOURCE/$project_name" + echo "Restoring $project_name from latest backup..." - # Create the project directory if it doesn't exist - mkdir -p "$REPO_SOURCE/$project_name" + # Check if project already exists and is up to date + if [ -d "$target_dir" ]; then + local backup_mtime=$(stat -c %Y "${project_backup_path}/backup.tar" 2>/dev/null || echo 0) + local repo_mtime=$(stat -c %Y "$target_dir" 2>/dev/null || echo 0) + + if [ "$repo_mtime" -ge "$backup_mtime" ]; then + echo " Skipped $project_name (already up to date)" + return 0 + fi + fi - # Extract the backup to the source directory - tar -xf "${project_backup_path}/backup.tar" -C "$REPO_SOURCE/$project_name" + # Create the project directory if it doesn't exist + mkdir -p "$target_dir" + + # Extract the backup to the source directory (overwrite existing files) + tar -xf "${project_backup_path}/backup.tar" -C "$target_dir" echo "Successfully restored $project_name from backup" } diff --git a/scripts/generic/restore_ssh_gpg.sh b/scripts/generic/restore_ssh_gpg.sh new file mode 100755 index 0000000..20a163e --- /dev/null +++ b/scripts/generic/restore_ssh_gpg.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# FIRST, MOUNT NAS AT /mnt/nas/ + +REMOTE="/mnt/nas/Jake" + +echo "📥 Pulling SSH keys..." +if [ ! -f ~/.ssh/id_rsa ] || [ "$(stat -c %Y "$REMOTE/ssh/id_rsa")" -gt "$(stat -c %Y ~/.ssh/id_rsa 2>/dev/null || echo 0)" ]; then + rsync "$REMOTE/ssh/id_rsa" ~/.ssh/ && chmod 600 ~/.ssh/id_rsa +fi + +if [ ! -f ~/.ssh/id_rsa.pub ] || [ "$(stat -c %Y "$REMOTE/ssh/id_rsa.pub")" -gt "$(stat -c %Y ~/.ssh/id_rsa.pub 2>/dev/null || echo 0)" ]; then + rsync "$REMOTE/ssh/id_rsa.pub" ~/.ssh/ && chmod 644 ~/.ssh/id_rsa.pub +fi + +if [ ! -f ~/.ssh/config ] || [ "$(stat -c %Y "$REMOTE/ssh/config")" -gt "$(stat -c %Y ~/.ssh/config 2>/dev/null || echo 0)" ]; then + rsync "$REMOTE/ssh/config" ~/.ssh/ && chmod 644 ~/.ssh/config +fi + +echo "📥 Pulling GPG key..." +if [ ! -f ~/my-gpg-key.asc ]; then + rsync "$REMOTE/ssh/my-gpg-key.asc" ~/ +else + echo " GPG key already exists locally, skipping download" +fi + +if [ ! -f ~/my-gpg-key.asc ]; then + echo "✅ SSH and GPG setup complete!" + exit 0 +fi + +echo "🔑 Importing GPG key..." +if ! gpg --list-secret-keys --with-colons "my-gpg-key.asc" 2>/dev/null | grep -q "^sec:"; then + gpg --import ~/my-gpg-key.asc +else + echo " GPG key already imported, skipping import" +fi +rm -f ~/my-gpg-key.asc + +echo "✅ SSH and GPG setup complete!" diff --git a/set_up_nas_mount.sh b/scripts/generic/set_up_nas_mount.sh similarity index 100% rename from set_up_nas_mount.sh rename to scripts/generic/set_up_nas_mount.sh diff --git a/scripts/generic/set_up_sym_links.sh b/scripts/generic/set_up_sym_links.sh new file mode 100755 index 0000000..7660cb0 --- /dev/null +++ b/scripts/generic/set_up_sym_links.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# +# Folders to link into the host .config directory +link_to_config=( + "git" + "starship.toml" + "fastfetch" +) +link_to_home=( + ".bashrc" + ".gitconfig" +) +directories=( + "~/source" +) + +for dir in "${directories[@]}"; do + if [ -e "$dir" ] || [ -L "$dir" ]; then + echo " Skipping $dir (already exists)" + else + mkdir -p "$dir" + echo " Created $dir" + fi +done + + +for link in "${link_to_config[@]}"; do + config_path="$HOME/dotfiles/$link" + target_path="$HOME/.config/$link" + if [ -e "$target_path" ] || [ -L "$target_path" ]; then + echo " Skipping $target_path (already exists)" + else + ln -sf "$config_path" "$target_path" + fi +done + +for link in "${link_to_home[@]}"; do + config_path="$HOME/dotfiles/$link" + target_path="$HOME/$link" + if [ -e "$target_path" ] || [ -L "$target_path" ]; then + echo " Skipping $target_path (already exists)" + else + ln -sf "$config_path" "$target_path" + fi +done diff --git a/scripts/omarchy-specific/omarchy_package_install.sh b/scripts/omarchy-specific/omarchy_package_install.sh new file mode 100755 index 0000000..49ac40f --- /dev/null +++ b/scripts/omarchy-specific/omarchy_package_install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +source ~/.local/share/omarchy/bin/omarchy-pkg-add +source ~/.local/share/omarchy/bin/omarchy-pkg-aur-add + +pacman_to_add=( + "tree" + "ttf-fira-code" + "cronie" +) + +aur_to_add=( + "bazecor" + "lmstudio-bin" +) + +package_str=$(IFS=' ' ; echo "${pacman_to_add[@]}") +aur_str=$(IFS=' ' ; echo "${aur_to_add[@]}") + + +omarchy-pkg-add $package_str +omarchy-pkg-aur-add $aur_str diff --git a/scripts/omarchy-specific/remove_bloat.sh b/scripts/omarchy-specific/remove_bloat.sh new file mode 100644 index 0000000..87339df --- /dev/null +++ b/scripts/omarchy-specific/remove_bloat.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Redirect the output to /dev/null to suppress any output if all is good! +omarchy-webapp-remove "HEY" 2>/dev/null || true +omarchy-webapp-remove "Basecamp" 2>/dev/null || true +omarchy-webapp-remove "Google Photos" 2>/dev/null || true +omarchy-webapp-remove "Google Messages" 2>/dev/null || true +omarchy-webapp-remove "Figma" 2>/dev/null || true +omarchy-webapp-remove "Zoom" 2>/dev/null || true +omarchy-webapp-remove "Fizzy" 2>/dev/null || true + +omarchy-pkg-drop signal-desktop 2>/dev/null || true + +rm -rf ~/Work/tries 2>/dev/null || true diff --git a/set_up_sym_links.sh b/set_up_sym_links.sh deleted file mode 100755 index 60512e7..0000000 --- a/set_up_sym_links.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -# -# Folders to link into the host .config directory -link_to_config=( - "git" - "starship.toml" -) -link_to_home=( - ".bashrc" - ".gitconfig" -) - -for link in "${link_to_config[@]}"; do - config_path="$HOME/dotfiles/$link" - target_path="$HOME/.config/$link" - ln -s "$config_path" "$target_path" -done - -for link in "${link_to_home[@]}"; do - config_path="$HOME/dotfiles/$link" - target_path="$HOME/$link" - ln -s "$config_path" "$target_path" -done diff --git a/setup_omarchy.sh b/setup_omarchy.sh index 15f5920..6f284be 100755 --- a/setup_omarchy.sh +++ b/setup_omarchy.sh @@ -10,36 +10,38 @@ echo " Omarchy Fresh Install - Starting..." echo "========================================" # 1. Add packages (must be first) -echo "[1/4] Installing packages..." -./omarchy_package_install.sh - +echo "Installing packages..." +./scripts/omarchy-specific/omarchy_package_install.sh # 2. Set up symbolic links echo "" -echo "[2/4] Setting up symbolic links..." -./set_up_sym_links.sh +echo "Setting up symbolic links..." +./scripts/generic/set_up_sym_links.sh # 3. Mount NAS (required for restore scripts) echo "" -echo "[3/4] Setting up NAS mount..." -./set_up_nas_mount.sh +echo "Setting up NAS mount..." +./scripts/generic/set_up_nas_mount.sh # 4. Restore backups (requires NAS mount) echo "" -echo "[4/4] Restoring SSH/GPG keys and Git data..." +echo "Restoring SSH/GPG keys and Git data..." echo " - Restoring SSH and GPG keys..." -./restore_ssh_gpg.sh +./scripts/generic/restore_ssh_gpg.sh echo " - Restoring Git backups..." -./restore_git_backup.sh +./scripts/generic/restore_git_backup.sh >/dev/null 2>&1 || echo " (Git restore skipped)" echo " - Restoring cron jobs..." -./restore_cron_jobs.sh +./scripts/generic/restore_cron_jobs.sh echo " - Enabling services..." sudo systemctl enable --now cronie.service +echo " - Removing unwanted stuf..." +./scripts/omarchy-specific/remove_bloat.sh + echo "" echo "========================================" echo " Omarchy Setup Complete!"