summaryrefslogtreecommitdiff
path: root/reorderips.sh
diff options
context:
space:
mode:
Diffstat (limited to 'reorderips.sh')
-rwxr-xr-xreorderips.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/reorderips.sh b/reorderips.sh
new file mode 100755
index 0000000..6567d95
--- /dev/null
+++ b/reorderips.sh
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+
+echo "Reassigning container IPs in increments of 10..."
+
+# Container name to IP mapping
+declare -A CONTAINERS=(
+ [archivecontrol]="10.196.1.10"
+ [archivelist]="10.196.1.20"
+ [ftp]="10.196.1.30"
+ [hostingtoot]="10.196.1.40"
+ [humptydumpty]="10.196.1.50"
+ [teamtalk]="10.196.1.60"
+ [akkoma]="10.196.1.70"
+)
+
+# Ordered list to process in sequence
+ORDER=(archivecontrol archivelist ftp hostingtoot humptydumpty teamtalk akkoma)
+
+for container in "${ORDER[@]}"; do
+ new_ip="${CONTAINERS[$container]}"
+
+ # Check current IP assignment
+ current_ip=$(lxc config device get "$container" eth0 ipv4.address 2>/dev/null)
+
+ if [[ "$current_ip" == "$new_ip" ]]; then
+ # No change needed
+ continue
+ fi
+
+ echo "Updating $container: assigning IP $new_ip (was: ${current_ip:-unset})"
+
+ # Override NIC to allow per-container IP (silently if already done)
+ lxc config device override "$container" eth0 >/dev/null 2>&1
+
+ # Clear any existing IP config
+ lxc config device unset "$container" eth0 ipv4.address >/dev/null 2>&1
+
+ # Set the new IP
+ lxc config device set "$container" eth0 ipv4.address "$new_ip"
+done
+
+echo "Restarting updated containers..."
+for container in "${ORDER[@]}"; do
+ new_ip="${CONTAINERS[$container]}"
+ current_ip=$(lxc config device get "$container" eth0 ipv4.address 2>/dev/null)
+ if [[ "$current_ip" == "$new_ip" ]]; then
+ echo "Restarting $container (new IP: $new_ip)"
+ lxc restart "$container" >/dev/null
+ fi
+done
+
+echo "IP assignment complete! Here’s the final layout:"
+lxc list