#!/bin/bash

## Copyright (C) 2016 - 2023 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

set -x
set -e

counter=0

while true ; do
   for icon in success busy error ; do
      msg="$(cat /proc/sys/kernel/random/uuid)"

      sudo -u sdwdate python3 -u -c "
import json
status = {'icon': '', 'message': ''}
status['icon'] = '$icon'
status['message'] = '$msg $msg $msg'
with open(\"/run/sdwdate/status\", 'w') as f:
    json.dump(status, f)
      "

      counter=$(( counter + 1 ))
      if [ "$counter" -ge 10000 ]; then
         do_break=true
      fi

      #sleep 1
   done
   if [ "$do_break" = "true" ]; then
      break
   fi
done
