#!/bin/sh

# External files synchronization and system/configuration updates for
# local installations and fat clients.
# Executed by puavo-update.service

set -eu

# XXX get rid of hosttype handling
puavo_hosttype=$(puavo-conf puavo.hosttype)

case "$puavo_hosttype" in
  bootserver|laptop|wirelessaccesspoint)
    # Do not do updates when booting from network.
    test -e /run/puavo/nbd-server && exit 0

    # Wait 90 seconds before proceeding (seems like a nice number, at least
    # the administrative tunnel should be up by then).
    sleep 90

    # The real work is done elsewhere. Trigger puavo-update-client and wait
    # for an hour before triggering it again.
    while true; do
      puavo-update-client --auto || true
      sleep 3600
    done
    ;;
esac

exit 0
