-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdnf-smb-mon
47 lines (39 loc) · 1.72 KB
/
dnf-smb-mon
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
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
#Patch 1.0
# dnf_smb_mon
# Monitoring script that will compare the @System Repository with the Upstream Repository for Samba DC
# If a match between the files are resolved, there will be no update
# If a match is NOT resolved between files, a message will be sent to MOTD and upon next login
# the (root) User should run "samba-dnf-pkg-update"
# Update the DNF cache
dnf makecache
# Get the Samba versions from the provides output
VERSIONS=$(dnf provides samba | grep -oP 'samba = \K[0-9]+\.[0-9]+\.[0-9]+-[0-9]+')
# Convert the versions to an array
VERSION_ARRAY=($VERSIONS)
# Check if two versions were found
if [ ${#VERSION_ARRAY[@]} -lt 2 ]; then
echo "Not enough version information found. Please check your DNF configuration."
exit 1
fi
# Extract the first and second versions
VERSION1=${VERSION_ARRAY[0]}
VERSION2=${VERSION_ARRAY[1]}
# Compare the versions
if [ "$VERSION1" == "$VERSION2" ]; then
logger -s "dnf-smb-mon: The Samba versions match: $VERSION1. Repositories are in sync." 2>>/var/log/dnf-smb-mon.log
else
cat <<EOF >/etc/motd
*********************************************
ATTENTION!
*********************************************
dnf_smb_mon sees a difference between the @System dnf repository
for Samba and the dnf repository upstream. This probably means that
the upstream Samba packages are a new version and the --dc packages
are now out of date.
Found versions: $VERSION1 and $VERSION2
You should probably run the command samba-dnf-pkg-update from the cli
or samba service management --> samba update (from server-manager).
EOF
logger -s "dnf-smb-mon: Repositories are NOT in sync. Found versions: $VERSION1 and $VERSION2. Review and run samba-dnf-pkg-update." 2>>/var/log/dnf-smb-mon.log
fi