Update MAC address at bootup on identifying interface link is up

Requirement is to change the MAC address on identifying that eth0 is up. I have a crude solution now, ie. a snap (daemon : oneshot) which executes below shell script to update MAC at bootup.

        command: usr/bin/chmac
        daemon: oneshot    

#! /bin/sh
sudo ip link set dev eth0 down
sleep 1
sudo ip link set dev eth0 address "XX:XX:XX:XX:XX:XX"
sleep 1
sudo ip link set dev eth0 up

However, I am looking for event driven approach, i.e. the snap should execute the script on identifying eth0 link up. Please help…!!

write a daemon script that reads from ip monitor output … (see ip monitor help)

also note that you do not need sudo for snapped daemons, they run as root already