-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_check.sh
More file actions
34 lines (28 loc) · 766 Bytes
/
update_check.sh
File metadata and controls
34 lines (28 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# Checks for updates in FreeNAS and sends an email.
# Designed to be run by a cron job
### Variables ###
mailfile="/tmp/update_report.tmp"
email="admin@lamarranet.local"
subject="Updates Check for FreeNAS"
cmd="/usr/local/bin/freenas-update check"
### Set email headers ###
(
echo "To: ${email}"
echo "Subject: ${subject}"
echo "Content-Type: text/html"
echo "MIME-Version: 1.0"
echo -e "\r\n"
) > "$mailfile"
### Set email body ###
echo "<pre style=\"font-size:14px\">" >> "$mailfile"
###### summary ######
if "$cmd" >/dev/null 2>&1; then
echo "Updates available!" >> "$mailfile"
else
echo "No updates" >> "$mailfile"
fi
echo "</pre>" >> "$mailfile"
### Send report ###
sendmail -t < "$mailfile"
rm "$mailfile"