This commit is contained in:
2024-03-25 17:44:36 -04:00
parent 91b6e8e13f
commit fc884e4629
187 changed files with 5039 additions and 130 deletions

View File

@@ -0,0 +1,34 @@
#! /bin/bash
mkdir -p /tmp/check4contribsupdates.$$
TMPFILE=`mktemp /tmp/check4contribsupdates.$$/XXXXXXXXXX` || exit 1
TMP1=`mktemp /tmp/check4contribsupdates.$$/XXXXXXXXXX` || exit 1
MAILADDR=admin-dnf
dnf -e 0 -d 0 check-update --disablerepo=* --enablerepo=smecontribs > $TMP1
if [ $? = 100 ]; then
echo -e "===\n=== dnf reports available updates for Contribs:\n===" >> $TMPFILE
cat $TMP1 >> $TMPFILE
echo -e "\n=== To apply *all* these updates, log on to your server command line and
=== enter the following command:
# dnf update --enablerepo=smecontribs" >> $TMPFILE
echo -e "\n=== Alternatively you can update packages one at a time using the command:
=== (replace packagename with contrib name eg smeserver-wbl)
# dnf update --enablerepo=smecontribs packagename
=== if needed, you might also be asked to run after dnf:
# signal-event post-upgrade
# signal-event reboot\n" >> $TMPFILE
fi
if [ -s $TMPFILE ]; then
if [ "$1" = "-m" ]; then
mail -s "SME Server Contribs Updates available for `hostname`" $MAILADDR < $TMPFILE
else
echo "SME Server Contribs Updates available for `hostname`"
cat $TMPFILE
fi
fi
rm -f $TMPFILE $TMP1
rm -fr /tmp/check4contribsupdates.*

View File

@@ -0,0 +1,45 @@
#! /bin/bash
mkdir -p /tmp/check4updates.$$
TMPFILE=`mktemp /tmp/check4updates.$$/XXXXXXXXXX` || exit 1
TMP1=`mktemp /tmp/check4updates.$$/XXXXXXXXXX` || exit 1
MAILADDR=admin-dnf
# SME 10 EOL message
DATE=$(date +%Y%m%d)
if [ $DATE -ge "20290531" ]; then
echo -e "===\n=== URGENT NOTICE:">> $TMPFILE
echo -e "=== As per June 30th 2024, SME Server 10 is obsolete, and potentially INSECURE.">> $TMPFILE
echo -e "=== Failure to upgrade may lead to the compromise of this server.">> $TMPFILE
echo -e "=== NO support will be offered for any issue found with this installed version.">> $TMPFILE
echo -e "=== Please migrate IMMEDIATELY to Koozali SME Server 11 or higher version." >> $TMPFILE
echo -e "=== Visit https://wiki.koozali.org/SME_Server:Download \n===" >> $TMPFILE
fi
dnf -e 0 -d 0 check-update > $TMP1
if [ $? = 100 ]; then
echo -e "===\n=== dnf reports available updates:\n===" >> $TMPFILE
DownloadOnly=$(/sbin/e-smith/config getprop dnf DownloadOnly|| echo "disabled")
AutoInstallUpdates=$(/sbin/e-smith/config getprop dnf AutoInstallUpdates|| echo "disabled")
if [ $DownloadOnly = "disabled" ] && [ $AutoInstallUpdates = "disabled" ]; then
ABRT_IGNORE_PYTHON=1 /usr/bin/dnf-automatic /etc/dnf/automatic.conf --timer --no-installupdates --no-downloadupdates >> $TMPFILE
else
ABRT_IGNORE_PYTHON=1 /usr/bin/dnf-automatic /etc/dnf/automatic.conf --timer >> $TMPFILE
fi
# we have updates, let's inform the server-manager
/usr/bin/systemctl restart dnf.service
fi
if [ -s $TMPFILE ]; then
if [ "$1" = "-m" ]; then
mail -s "Updates available for `hostname`" $MAILADDR < $TMPFILE
else
echo "Updates available for `hostname`"
cat $TMPFILE
fi
fi
rm -f $TMPFILE $TMP1
rm -fr /tmp/check4updates.*

View File

@@ -0,0 +1,114 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# Yum database updates
# Copyright (C) 2005 Gordon Rowell <gordonr@gormand.com.au>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License or more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#----------------------------------------------------------------------
use strict;
use esmith::ConfigDB;
my $db = esmith::ConfigDB->open_ro or die "Couldn't open ConfigDB\n";
my $pid = fork;
exit 1 unless defined $pid;
# now two processes are executing
if ($pid == 0) {
# XXX - WARNING - XXX
#
# For speed and to reduce log noise, we don't use
# the esmith::DB routines here
# We do not use -R xxx to sleep for a while, as we do this at cron level
# this allows faster results when needed or delayed when not
use constant DNF_CMD => "/usr/bin/dnf -d 0 -e 0 ";
# dnf check to have fresh metadata
system(DNF_CMD." check-update 1>/dev/null");
my $tmp_file;
END { $tmp_file and -f $tmp_file and unlink $tmp_file; }
for my $list_option ( qw(available installed updates) )
{
my $file = "/home/e-smith/db/dnf_${list_option}";
$tmp_file = "/home/e-smith/db/dnf_${list_option}.tmp";
open DB, ">$tmp_file" or die "Couldn't create $tmp_file\n";
print DB "# Generated by $0: " . scalar localtime() . "\n";
open YUM, "-|", DNF_CMD . "list $list_option" or
die "Couldn't call dnf list $list_option\n";
#strip header, preventing inclusion as package
my $header = <YUM>;
while ( <YUM> )
{
my ($package, $version, $repo) = split /\s+/;
next unless $package and $version and $repo;
if ($list_option eq 'available')
{
my $RestrictRpm = $db->get_prop('dnf', 'RestrictRpm') || '';
my $RestrictRepo = $db->get_prop('dnf', 'RestrictRepo') || '';
my @rpms = split(/,/, $RestrictRpm);
my @repos = split(/,/, $RestrictRepo);
if ( ($#rpms < 0 && $#repos < 0)
|| (grep { $package =~ /$_/ } @rpms)
|| (grep { $repo =~ /$_/ } @repos)
)
{
print DB "$package=package|Repo|$repo|Version|$version\n";
}
}
else
{
print DB "$package=package|Repo|$repo|Version|$version\n";
}
}
close YUM or warn "dnf list $list_option status $?\n";
open YUM, "-|", DNF_CMD . "grouplist $list_option" or
die "Couldn't call dnf grouplist $list_option\n";
while ( <YUM> )
{
next if /^\s*$/;
next unless /^\s+/;
s/\s+//g;
print DB "$_=group\n";
}
close YUM or warn "dnf grouplist $list_option status $?\n";
close DB;
rename $tmp_file, $file or die "Couldn't rename $tmp_file $file\n";
}
exit 0;
}
exit 0;