always pull pool name
This commit is contained in:
parent
b31818d074
commit
dc2d476937
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
|
|
||||||
mount(){
|
mount(){
|
||||||
|
pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r")
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
clear -x
|
clear -x
|
||||||
@ -48,12 +49,7 @@ do
|
|||||||
data_name=$(echo "$pvc" | awk '{print $3}')
|
data_name=$(echo "$pvc" | awk '{print $3}')
|
||||||
mount=$(echo "$pvc" | awk '{print $4}')
|
mount=$(echo "$pvc" | awk '{print $4}')
|
||||||
volume_name=$(echo "$pvc" | awk '{print $4}')
|
volume_name=$(echo "$pvc" | awk '{print $4}')
|
||||||
mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}')
|
full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}')
|
||||||
if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup.
|
|
||||||
echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool"
|
|
||||||
pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r")
|
|
||||||
full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}')
|
|
||||||
fi
|
|
||||||
echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name"
|
echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name"
|
||||||
zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app"
|
zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app"
|
||||||
echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n"
|
echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n"
|
||||||
@ -87,17 +83,9 @@ do
|
|||||||
main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}')
|
main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}')
|
||||||
app=$(echo "$main" | awk '{print $1}' | cut -c 4-)
|
app=$(echo "$main" | awk '{print $1}' | cut -c 4-)
|
||||||
pvc=$(echo "$main" | awk '{print $3}')
|
pvc=$(echo "$main" | awk '{print $3}')
|
||||||
mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-)
|
full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-)
|
||||||
if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup.
|
zfs set mountpoint=legacy "$full_path""$pvc"
|
||||||
echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool"
|
echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i"
|
||||||
pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | tr -d " \t\n\r")
|
|
||||||
full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-)
|
|
||||||
zfs set mountpoint=legacy "$full_path""$pvc"
|
|
||||||
echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i"
|
|
||||||
else
|
|
||||||
zfs set mountpoint=legacy "$path""$pvc"
|
|
||||||
echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
rmdir /mnt/heavyscript
|
rmdir /mnt/heavyscript
|
||||||
sleep 3
|
sleep 3
|
||||||
|
Loading…
Reference in New Issue
Block a user