summaryrefslogtreecommitdiff
path: root/move_containers.sh
blob: 7062177a4188c91aac67b3309954e67799309c0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash

# === Config ===
CONTAINERS=(
  archivecontrol
  archivelist
  ftp
  hostingtoot
  humptydumpty
  teamtalk
  akkoma
)

TARGET_POOL="infernode-pool"

# === Move loop ===
for container in "${CONTAINERS[@]}"; do
  echo "=== Processing container: $container ==="

  echo "Stopping $container..."
  lxc stop "$container" --timeout=30

  echo "Waiting for $container to fully shut down..."
  while true; do
    status=$(lxc info "$container" | grep "Status:" | awk '{print $2}')
    if [[ "$status" != "RUNNING" ]]; then
      echo "$container is fully stopped."
      break
    fi
    echo "$container still stopping... waiting 3 more seconds."
    sleep 3
  done

  echo "Moving $container to pool: $TARGET_POOL"
  lxc move "$container" "$container" --storage "$TARGET_POOL"

  echo "Starting $container..."
  lxc start "$container"

  echo "=== $container moved and restarted! ==="
  echo
done

echo "=== All containers have been successfully moved and restarted! ==="