commit 407c327fa6c5495e8ccf7b2ae0eff70cfb614442 Author: Maddox Date: Sun Jan 25 20:36:12 2026 +0000 Initial commit: scripts directory with sync-dyno.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..73564fa --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# Temporary files +*.tmp +*.swp +*~ + +# Sensitive files (add patterns as needed) +# *.env +# secrets/ diff --git a/add-host.sh b/add-host.sh new file mode 100755 index 0000000..2f1f98b --- /dev/null +++ b/add-host.sh @@ -0,0 +1,44 @@ +#!/bin/bash +CONFIG_FILE="$HOME/.ssh/tmux-hosts.conf" +SSH_CONFIG="$HOME/.ssh/config" +INVENTORY="$HOME/clustered-fucks/inventory/hosts.yml" + +echo "=== Add New Host ===" +echo "" +read -p "Hostname (e.g., new-server): " hostname +read -p "IP Address (e.g., 192.168.1.130): " ip +read -p "SSH User [root]: " user +user=${user:-root} +read -p "SSH Port [22]: " port +port=${port:-22} +read -p "Description: " description + +echo "" +echo "Testing SSH connectivity..." +if ssh -o BatchMode=yes -o ConnectTimeout=5 -p $port ${user}@${ip} "echo OK" 2>/dev/null; then + echo "✓ Key already works" +else + echo "Copying SSH key..." + ssh-copy-id -p $port ${user}@${ip} +fi + +echo "" +echo "Adding to tmux-hosts.conf..." +echo "${hostname}:${user}@${ip}:${port}:${description}" >> "$CONFIG_FILE" + +echo "Adding to SSH config..." +cat >> "$SSH_CONFIG" << SSHENTRY + +Host ${hostname} + HostName ${ip} + User ${user} + Port ${port} +SSHENTRY + +echo "" +echo "✓ Host added!" +echo "" +echo "NOTE: Manually add to inventory if needed:" +echo " ~/clustered-fucks/inventory/hosts.yml" +echo "" +echo "Test with: ssh ${hostname}" diff --git a/control-menu.sh b/control-menu.sh new file mode 100755 index 0000000..bb17272 --- /dev/null +++ b/control-menu.sh @@ -0,0 +1,47 @@ +#!/bin/bash +CLUSTER_OPS="$HOME/clustered-fucks" + +show_menu() { + clear + echo "╔═══════════════════════════════════════════════════════════════╗" + echo "║ CLUSTER CONTROL - Ansible Menu ║" + echo "╠═══════════════════════════════════════════════════════════════╣" + echo "║ [1] Ping All - Test connectivity ║" + echo "║ [2] Check Status - Disk/memory/containers ║" + echo "║ [3] Update All - apt upgrade docker hosts ║" + echo "║ [4] Docker Prune - Clean unused resources ║" + echo "║ [5] Restart Utils - Restart utils stack everywhere ║" + echo "║ ║" + echo "║ [A] Ad-hoc Command - Run custom command ║" + echo "║ [I] Inventory - Show host list ║" + echo "║ [S] SSH Manager - Launch tmux session ║" + echo "║ ║" + echo "║ [Q] Quit ║" + echo "╚═══════════════════════════════════════════════════════════════╝" + echo "" +} + +cd "$CLUSTER_OPS" + +while true; do + show_menu + read -p "Choice: " choice + + case ${choice^^} in + 1) ansible all -m ping; read -p "Press Enter..." ;; + 2) ansible-playbook playbooks/check-status.yml; read -p "Press Enter..." ;; + 3) ansible-playbook playbooks/update-all.yml; read -p "Press Enter..." ;; + 4) ansible-playbook playbooks/docker-prune.yml; read -p "Press Enter..." ;; + 5) ansible-playbook playbooks/restart-utils.yml; read -p "Press Enter..." ;; + A) + read -p "Target [all]: " target + target=${target:-all} + read -p "Command: " cmd + [ -n "$cmd" ] && ansible $target -m shell -a "$cmd" + read -p "Press Enter..." + ;; + I) ansible-inventory --graph; read -p "Press Enter..." ;; + S) ~/scripts/ssh-manager.sh; exit 0 ;; + Q) exit 0 ;; + esac +done diff --git a/ssh-manager.sh b/ssh-manager.sh new file mode 100755 index 0000000..76cfcfb --- /dev/null +++ b/ssh-manager.sh @@ -0,0 +1,73 @@ +#!/bin/bash +SESSION="cluster" +CONFIG_FILE="$HOME/.ssh/tmux-hosts.conf" + +if [ ! -f "$CONFIG_FILE" ]; then + echo "Config file not found: $CONFIG_FILE" + exit 1 +fi + +# Kill existing session +tmux kill-session -t $SESSION 2>/dev/null + +# Create new session +tmux new-session -d -s $SESSION -n "Control" +tmux set -t $SESSION -g mouse on +tmux set -t $SESSION -g pane-border-status top + +# Count hosts +host_count=0 +while IFS=: read -r name connection port description; do + [[ -z "$name" || "$name" =~ ^# ]] && continue + ((host_count++)) +done < "$CONFIG_FILE" + +multiview_window=$((host_count + 1)) + +# Create individual host windows +window_num=1 +hosts=() +while IFS=: read -r name connection port description; do + [[ -z "$name" || "$name" =~ ^# ]] && continue + port=${port:-22} + hosts+=("$name:$connection:$port:$description") + + tmux new-window -t $SESSION:$window_num -n "$name" + tmux select-pane -t $SESSION:$window_num.0 -T "$description" + + if [ "$port" != "22" ]; then + tmux send-keys -t $SESSION:$window_num "ssh -p $port $connection" C-m + else + tmux send-keys -t $SESSION:$window_num "ssh $connection" C-m + fi + ((window_num++)) +done < "$CONFIG_FILE" + +# Create multi-view window +if [ ${#hosts[@]} -gt 0 ]; then + tmux new-window -t $SESSION:$multiview_window -n "Multi-View" + num_hosts=${#hosts[@]} + + for ((i=1; i/dev/null; then + echo "Changes detected:" + git diff configs/dyno.yml + echo "" + echo "To commit: cd ~/scripts && git add -A && git commit -m 'Update dyno.yml'" + else + echo "No changes from last sync." + fi +fi