Thanks.
I would recommend taking the sudo out the script, write your script assuming is being run as root, and using sudo to call the script instead.
For instance:
Code:
#!/bin/bash
ufw status | grep inactive &> /dev/null
if [ $? = 0 ]; then
notify-send "WARNING: ufw is not enabled." -t 2100
fi
and the script would be called like this:
Code:
sudo /path/to/myscript.sh
If you'd like to monitor the status all the time, you can also run this in a loop:
Code:
#!/bin/bash
while true; do
ufw status | grep inactive &> /dev/null
if [ $? = 0 ]; then
notify-send "WARNING: ufw is not enabled." -t 2100
fi
sleep 60s
done
Then you could left the program run on the background:
Code:
sudo /path/to/myscript.sh &
Hope it helps. Let us know how it goes.
Regards.
Bookmarks