diff --git a/images/fcos-bastion-image/root/usr/bin/clean-registries.sh b/images/fcos-bastion-image/root/usr/bin/clean-registries.sh index e78c636..a6754e9 100755 --- a/images/fcos-bastion-image/root/usr/bin/clean-registries.sh +++ b/images/fcos-bastion-image/root/usr/bin/clean-registries.sh @@ -21,15 +21,13 @@ wait_for_container_running() { mapfile -t ports < <(systemctl list-units 'registry@*' --no-pager --quiet | awk -F'[@.]' '{print $2}') for port in "${ports[@]}"; do disk_use=$(df /opt/registry-"${port}" --output='pcent' | grep -o '[0-9]*') - if [ "$disk_use" -gt 85 ]; then + if [ "$disk_use" -gt 60 ]; then rm -rf /opt/registry-"${port}"/data/docker/registry/v2/repositories/* - sed -i -e '/readonly/{n;s/enabled:.*/enabled: true/;}' /opt/registry-"${port}"/config.yaml - systemctl restart registry@"${port}".service - wait_for_container_running registry-"${port}" + fi + if [ "$disk_use" -gt 50 ]; then podman exec registry-"${port}" /bin/registry garbage-collect /etc/docker/registry/config.yml - sed -i -e '/readonly/{n;s/enabled:.*/enabled: false/;}' /opt/registry-"${port}"/config.yaml - systemctl restart registry@"${port}".service fi + wait_for_container_running registry-"${port}" done exit 0