summaryrefslogtreecommitdiff
path: root/squeakyclean.sh
blob: bb1e7543e62eaecfcb80862806e23c2695e0cb17 (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
#!/usr/bin/env bash

echo "=== LXD Storage Pool Check and Cleanup Helper ==="

# List all containers with their active storage pool
echo
echo "Container -> Storage Pool:"
for container in $(lxc list --format csv -c n); do
  pool=$(lxc config device get "$container" root pool 2>/dev/null)
  echo "$container -> ${pool:-default}"
done

echo
echo "=== Checking for leftover partial volumes in /mnt/infernode_lxd (NFS) ==="
if mountpoint -q /mnt/infernode_lxd; then
  leftovers=$(find /mnt/infernode_lxd -mindepth 1 -maxdepth 1)
  if [[ -z "$leftovers" ]]; then
    echo "No leftover volumes found. Clean as a whistle!"
  else
    echo "Found leftover items:"
    echo "$leftovers"
    echo
    read -p "Do you want to remove these? (y/n) " confirm
    if [[ "$confirm" == "y" ]]; then
      sudo rm -rf /mnt/infernode_lxd/*
      echo "Leftovers removed!"
    else
      echo "Leaving leftovers untouched for now."
    fi
  fi
else
  echo "NFS mount not found at /mnt/infernode_lxd. Skipping leftover check."
fi

echo
echo "=== Done! ==="