initial commit of file from CVS for smeserver-yum on Thu 26 Oct 11:26:23 BST 2023
This commit is contained in:
34
root/sbin/e-smith/check4contribsupdates
Normal file
34
root/sbin/e-smith/check4contribsupdates
Normal 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-yum
|
||||
|
||||
yum -e 0 -d 0 check-update --disablerepo=* --enablerepo=smecontribs > $TMP1
|
||||
if [ $? = 100 ]; then
|
||||
echo -e "===\n=== yum 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:
|
||||
# yum 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)
|
||||
# yum update --enablerepo=smecontribs packagename
|
||||
=== if needed, you might also be asked to run after yum:
|
||||
# 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.*
|
40
root/sbin/e-smith/check4updates
Normal file
40
root/sbin/e-smith/check4updates
Normal file
@@ -0,0 +1,40 @@
|
||||
#! /bin/bash
|
||||
|
||||
mkdir -p /tmp/check4updates.$$
|
||||
TMPFILE=`mktemp /tmp/check4updates.$$/XXXXXXXXXX` || exit 1
|
||||
TMP1=`mktemp /tmp/check4updates.$$/XXXXXXXXXX` || exit 1
|
||||
|
||||
MAILADDR=admin-yum
|
||||
|
||||
# SME 10 EOL message
|
||||
DATE=$(date +%Y%m%d)
|
||||
if [ $DATE -ge "20240630" ]; 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
|
||||
|
||||
yum -e 0 -d 0 check-update > $TMP1
|
||||
if [ $? = 100 ]; then
|
||||
echo -e "===\n=== yum reports available updates:\n===" >> $TMPFILE
|
||||
/usr/sbin/yum-cron /etc/yum/yum-cron.conf >> $TMPFILE
|
||||
#cat $TMP1 >> $TMPFILE
|
||||
# we have updates, let's inform the server-manager
|
||||
/usr/bin/systemctl restart yum.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.*
|
132
root/sbin/e-smith/yum_update_dbs
Normal file
132
root/sbin/e-smith/yum_update_dbs
Normal file
@@ -0,0 +1,132 @@
|
||||
#!/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) {
|
||||
|
||||
use constant YUM_CRON_FLAG => '/var/lock/subsys/yum-cron';
|
||||
# we do not use yum-cron /etc/cron.daily file
|
||||
# so we keep away the subsys file
|
||||
#if ($db->get_prop('yum', 'AutoInstallUpdates') eq 'enabled')
|
||||
#{
|
||||
# (system('/bin/touch', YUM_CRON_FLAG) == 0) or
|
||||
# warn "Couldn't touch " . YUM_CRON_FLAG . "\n";
|
||||
#}
|
||||
#else
|
||||
#{
|
||||
# system("/usr/bin/systemctl -q stop yum-cron");
|
||||
# system("/usr/bin/systemctl -q mask yum-cron");
|
||||
unlink YUM_CRON_FLAG;
|
||||
#}
|
||||
|
||||
# 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 YUM_CMD => "/usr/bin/yum -d 0 -e 0 ";
|
||||
|
||||
# avoid error with no installed groups file.
|
||||
system(YUM_CMD." groups mark convert -d 0 -e 0 1>/dev/null") unless (-d "/var/lib/yum/groups/");
|
||||
|
||||
# yum check to have fresh metadata
|
||||
system(YUM_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/yum_${list_option}";
|
||||
$tmp_file = "/home/e-smith/db/yum_${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, "-|", YUM_CMD . "list $list_option" or
|
||||
die "Couldn't call yum 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('yum', 'RestrictRpm') || '';
|
||||
my $RestrictRepo = $db->get_prop('yum', '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 "yum list $list_option status $?\n";
|
||||
|
||||
open YUM, "-|", YUM_CMD . "grouplist $list_option" or
|
||||
die "Couldn't call yum grouplist $list_option\n";
|
||||
|
||||
while ( <YUM> )
|
||||
{
|
||||
next if /^\s*$/;
|
||||
|
||||
next unless /^\s+/;
|
||||
|
||||
s/\s+//g;
|
||||
|
||||
print DB "$_=group\n";
|
||||
}
|
||||
|
||||
close YUM or warn "yum grouplist $list_option status $?\n";
|
||||
|
||||
close DB;
|
||||
|
||||
rename $tmp_file, $file or die "Couldn't rename $tmp_file $file\n";
|
||||
}
|
||||
|
||||
exit 0;
|
||||
}
|
||||
exit 0;
|
Reference in New Issue
Block a user