initial commit of file from CVS for smeserver-check4updates on Sat Sep 7 20:13:39 AEST 2024
This commit is contained in:
@@ -0,0 +1 @@
|
||||
admin-yum
|
@@ -0,0 +1 @@
|
||||
daily
|
@@ -0,0 +1 @@
|
||||
|
@@ -0,0 +1 @@
|
||||
configuration
|
@@ -0,0 +1,28 @@
|
||||
{
|
||||
#used for smeserver-check4updates-0.0.3-1
|
||||
#only needed because I made a mistake on the db name
|
||||
#(check4update instead of check4updates)
|
||||
use esmith::ConfigDB;
|
||||
|
||||
my $DB = esmith::ConfigDB->open or die ("can not open db configuration : $!");
|
||||
|
||||
my $check4update = $DB->get(check4update) or return;
|
||||
|
||||
my $repositories = $DB->get_prop_and_delete('check4update','repositories') || '';
|
||||
my $excludes = $DB->get_prop_and_delete('check4update','excludes') || '';
|
||||
my $emailaddress = $DB->get_prop_and_delete('check4update','emailaddress') || '';
|
||||
my $frequence = $DB->get_prop_and_delete('check4update','frequence') || '';
|
||||
|
||||
$check4update->delete;
|
||||
|
||||
my %defaults = ('type' => 'configuration');
|
||||
|
||||
my $check4updates = $DB->get("check4updates") ||
|
||||
$DB->new_record('check4updates' , \%defaults)
|
||||
or die ("can not create check4updates key");
|
||||
|
||||
$check4updates->set_prop('repositories',"$repositories");
|
||||
$check4updates->set_prop('excludes',"$excludes");
|
||||
$check4updates->set_prop('emailaddress',"$emailaddress");
|
||||
$check4updates->set_prop('frequence',"$frequence");
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
{
|
||||
return "\n# yum check for $check4updates{repositories} updates is disabled\n" unless $yum{status} eq 'enabled';
|
||||
|
||||
my $freq = $check4updates{frequence} || 'daily';
|
||||
|
||||
my $min;
|
||||
my $dom;
|
||||
my $dow;
|
||||
|
||||
if ($freq eq 'weekly') {
|
||||
$min = 22;
|
||||
$dom = '*';
|
||||
$dow = 0;
|
||||
} elsif ($freq eq 'monthly') {
|
||||
$min = 42;
|
||||
$dom = 1;
|
||||
$dow = '*';
|
||||
} else {
|
||||
$min = 2;
|
||||
$dom = '*';
|
||||
$dow = '*';
|
||||
}
|
||||
return "$min 4 $dom * $dow root "
|
||||
. q{sleep $[ $RANDOM \\% 3600 ]; /sbin/e-smith/check4repositoriesupdates -m };
|
||||
}
|
||||
|
29
root/sbin/e-smith/check4repositoriesupdates
Normal file
29
root/sbin/e-smith/check4repositoriesupdates
Normal file
@@ -0,0 +1,29 @@
|
||||
#! /bin/bash
|
||||
|
||||
mkdir -p /tmp/check4repositoriessupdates.$$
|
||||
TMPFILE=`mktemp /tmp/check4repositoriessupdates.$$/XXXXXXXXXX` || exit 1
|
||||
TMP1=`mktemp /tmp/check4repositoriessupdates.$$/XXXXXXXXXX` || exit 1
|
||||
repositories=$(/sbin/e-smith/db configuration getprop check4updates repositories) || exit 1
|
||||
excludes=$(/sbin/e-smith/db configuration getprop check4updates excludes) || exit 1
|
||||
MAILADDR=$(/sbin/e-smith/db configuration getprop check4updates emailaddress)|| exit 1
|
||||
|
||||
yum -e 0 -d 0 check-update --disablerepo=* --enablerepo=$repositories --exclude=$excludes > $TMP1
|
||||
if [ $? = 100 ]; then
|
||||
echo -e "===\n=== yum reports available updates for $repositories :\n===" >> $TMPFILE
|
||||
cat $TMP1 >> $TMPFILE
|
||||
echo -e "\n To apply all these updates, you can log on your server and run the following command :\n
|
||||
yum update --enablerepo=$repositories --exclude=$excludes\n" >> $TMPFILE
|
||||
fi
|
||||
|
||||
if [ -s $TMPFILE ]; then
|
||||
if [ "$1" = "-m" ]; then
|
||||
mail -s "Repositories($repositories) Updates available for `hostname`" $MAILADDR < $TMPFILE
|
||||
else
|
||||
echo "Repositories($repositories) Updates available for `hostname`"
|
||||
cat $TMPFILE
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f $TMPFILE $TMP1
|
||||
rm -fr /tmp/check4repositoriessupdates.*
|
||||
|
Reference in New Issue
Block a user