tidy up
This commit is contained in:
Executable
+35
@@ -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
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Git Restore Script for Latest Backup
|
||||
# Usage: ./restore_git_backup.sh [project_name] (optional - restore specific project)
|
||||
|
||||
# Configuration
|
||||
BACKUP_DIR="/mnt/nas/Jake/git_backups"
|
||||
REPO_SOURCE="$HOME/source/"
|
||||
|
||||
# Function to restore a single project from latest backup
|
||||
restore_project() {
|
||||
local project_name="$1"
|
||||
local latest_backup=$(find "$BACKUP_DIR" -maxdepth 1 -type d -name "*" | sort -r | head -n 1)
|
||||
|
||||
if [ -z "$latest_backup" ]; then
|
||||
echo "Error: No backups found in $BACKUP_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local project_backup_path="${latest_backup}/${project_name}"
|
||||
|
||||
if [ ! -d "$project_backup_path" ]; then
|
||||
echo "Error: Backup for project '$project_name' not found in latest backup"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local target_dir="$REPO_SOURCE/$project_name"
|
||||
|
||||
echo "Restoring $project_name from latest backup..."
|
||||
|
||||
# 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
|
||||
|
||||
# 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"
|
||||
}
|
||||
|
||||
# Main restore function
|
||||
main_restore() {
|
||||
local latest_backup=$(find "$BACKUP_DIR" -maxdepth 1 -type d -name "*" | sort -r | head -n 1)
|
||||
|
||||
if [ -z "$latest_backup" ]; then
|
||||
echo "Error: No backups found in $BACKUP_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Latest backup directory: $latest_backup"
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
# Restore all projects from latest backup
|
||||
echo "Restoring all projects from latest backup..."
|
||||
|
||||
# Get list of project directories in the backup
|
||||
local projects=($(ls "$latest_backup"))
|
||||
|
||||
for project in "${projects[@]}"; do
|
||||
restore_project "$project"
|
||||
done
|
||||
else
|
||||
# Restore specific project
|
||||
local target_project="$1"
|
||||
restore_project "$target_project"
|
||||
fi
|
||||
|
||||
echo "Restore completed successfully!"
|
||||
}
|
||||
|
||||
# Run main restore function
|
||||
main_restore "$@"
|
||||
Executable
+40
@@ -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!"
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Setup script for QNAP NAS mount
|
||||
# This script adds the NAS entry to /etc/fstab and creates credential file
|
||||
|
||||
set -e
|
||||
|
||||
NAS_SERVER="192.168.0.146"
|
||||
NAS_PATH="Jake"
|
||||
MOUNT_POINT="/mnt/nas"
|
||||
FILESYSTEM_TYPE="cifs"
|
||||
|
||||
echo "Setting up QNAP NAS mount..."
|
||||
echo "NAS: //$NAS_SERVER/$NAS_PATH"
|
||||
echo "Mount point: $MOUNT_POINT"
|
||||
|
||||
# Create mount point if it doesn't exist
|
||||
sudo mkdir -p "$MOUNT_POINT"
|
||||
|
||||
# Backup existing fstab
|
||||
sudo cp /etc/fstab /etc/fstab.backup.$(date +%Y%m%d%H%M%S)
|
||||
|
||||
# Read credentials from environment or prompt user
|
||||
CREDENTIALS_FILE="$HOME/.nas-credentials"
|
||||
|
||||
if [[ -n "$NAS_USERNAME" && -n "$NAS_PASSWORD" ]]; then
|
||||
username="$NAS_USERNAME"
|
||||
password="$NAS_PASSWORD"
|
||||
echo "username=$username" > "$CREDENTIALS_FILE"
|
||||
echo "password=$password" >> "$CREDENTIALS_FILE"
|
||||
chmod 600 "$CREDENTIALS_FILE"
|
||||
elif [[ -f "$CREDENTIALS_FILE" ]]; then
|
||||
echo "Using existing credentials file: $CREDENTIALS_FILE"
|
||||
source "$CREDENTIALS_FILE"
|
||||
username="$username"
|
||||
password="$password"
|
||||
else
|
||||
read -p "Enter NAS username: " username
|
||||
read -sp "Enter NAS password: " password
|
||||
echo
|
||||
echo "username=$username" > "$CREDENTIALS_FILE"
|
||||
echo "password=$password" >> "$CREDENTIALS_FILE"
|
||||
chmod 600 "$CREDENTIALS_FILE"
|
||||
fi
|
||||
|
||||
# Check if entry already exists in fstab
|
||||
MOUNT_ENTRY="//$NAS_SERVER/$NAS_PATH $MOUNT_POINT $FILESYSTEM_TYPE credentials=$CREDENTIALS_FILE,uid=1000,gid=1000,iocharset=utf8,cache=none,_netdev,x-systemd.device-timeout=10,x-systemd.requires-network.target 0 0"
|
||||
|
||||
if grep -q "$MOUNT_ENTRY" /etc/fstab; then
|
||||
echo "Mount entry already exists in /etc/fstab"
|
||||
else
|
||||
# Add the NAS mount entry to fstab
|
||||
echo "$MOUNT_ENTRY" | sudo tee -a /etc/fstab
|
||||
echo
|
||||
echo "Mount added to /etc/fstab"
|
||||
fi
|
||||
|
||||
# Try mounting to verify it works (ignoring failure if network not available)
|
||||
echo "Attempting to mount (will fail if network not available)..."
|
||||
systemctl daemon-reload
|
||||
sudo mount -a 2>/dev/null || echo "Network unavailable, will mount on next boot"
|
||||
Executable
+45
@@ -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
|
||||
+22
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user