#!/bin/bash -eu

for host in `kubectl get ing -l app.kubernetes.io/name=nextcloud -A --no-headers -o custom-columns=":spec.rules[0].host"`;do
  export folder=`echo $host| cut -d'.' -f2- | rev | sed 's/\./-/' | rev`
  echo $folder
  export sub=`echo $host| cut -d'.' -f1`
  echo $sub
  cd /root/domains/$folder/$sub
  libre update --batch
done
