#copy watchdog-install.sh to /home/ubuntu/

#check idVendor & idPoductId (may differ)
echo 'ACTION=="add", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="a26d", SYMLINK+="watchdog"' | sudo tee /etc/udev/rules.d/10-local.rules

#restart udev service
sudo udevadm trigger

#create watchdog pause script 
echo '#!/bin/bash
PORT=/dev/watchdog
while true
do
 echo -n "~P1" > $PORT
 sleep 1
done' | sudo tee /home/ubuntu/watchdog-pause.sh

sudo chmod u+x /home/ubuntu/watchdog-pause.sh

#create watchdog-pause.sh autostart service
echo '[Unit]
Description=Pause Watchdog module

[Service]
WorkingDirectory=/home/ubuntu/
Type=simple
ExecStart=/bin/sh watchdog-pause.sh

[Install]
WantedBy=multi-user.target' | sudo tee /lib/systemd/system/watchdog-pause.service

#enable & start service
sudo systemctl enable watchdog-pause.service
sudo systemctl start watchdog-pause.service

#enable user COM-port listener
sudo usermod -a -G dialout ubuntu

#reboot
sudo reboot