#!/bin/bash # R-1302 staged on the throwaway box (VM 9383, agent 0.172.0). The appliance path pre-positions the grant, so a plain first start never reaches the repair (read in the install log). # A: a true first grant: no seen file, the grant taken away, the agent started. B: a loss: the seen file there, the grant taken away, the agent started. del() { for k in "--users felhom-agent@pve" "--tokens felhom-agent@pve!agent"; do pveum acl delete /storage/felhom-pbs $k --roles FelhomAgentStore; done; } show() { journalctl -u felhom-agent --since "$1" --no-pager | grep -E 'store-grant|capabilities self-check' | sed -E 's/^.*felhom-agent\[[0-9]+\]: //' | cut -c1-230; } echo "version: $(/usr/local/bin/felhom-agent --version)" echo "seen before: $(cat /var/lib/felhom-agent/store-grant-seen.json)" echo "== A: first grant"; systemctl stop felhom-agent; rm -f /var/lib/felhom-agent/store-grant-seen.json; del; T=$(date '+%F %T'); systemctl start felhom-agent; sleep 25; show "$T" echo "ERROR R-190 lines: $(journalctl -u felhom-agent --since "$T" --no-pager | grep -c 'R-190')"; echo "seen after: $(cat /var/lib/felhom-agent/store-grant-seen.json)" echo "== B: a loss"; systemctl stop felhom-agent; del; T=$(date '+%F %T'); systemctl start felhom-agent; sleep 25; show "$T" echo "INFO granted lines: $(journalctl -u felhom-agent --since "$T" --no-pager | grep -c 'store-grant: granted')" pveum acl list --output-format json | python3 -c "import json,sys;print('grant back:',sum(1 for a in json.load(sys.stdin) if a['path']=='/storage/felhom-pbs'))"