View previous topic :: View next topic |
Author |
Message |
Bouncelot n00b
Joined: 09 Sep 2003 Posts: 56
|
Posted: Wed Oct 08, 2003 5:35 pm Post subject: My little contribution. |
|
|
Here is the script I have been using. I prefer to update manualy especialy on my servers
I set it up as a weekly cron to notify me of updates.
Code: | #!/usr/bin/perl
use Net::SMTP;
my $mailserver = "mail";
my $sysadmin = "root\@bouncelot.com";
my $message = "";
$bUpdates = 0;
#Update the package tree.
`emerge sync > /dev/null`;
$message = "System Updates: \n";
$_ = `emerge -up system`;
$message .= checkForUpdates($_);
$message .= "\nWorld Updates: \n";
$_ = `emerge -up world`;
$message .= checkForUpdates($_);
$message .= "\nKernel Updates: \n";
$_ = `emerge -p gentoo-sources`;
$message .= checkForUpdates($_);
if($bUpdates == 1) {
sendStatus($mailserver, $sysadmin, $message);
}
exit 0;
sub checkForUpdates
{
my $message = "";
/^\n+(.*):\n+(.*)!\n+(.*)\n+$/;
if($3 ne "") {
$message = "$3\n";
$bUpdates = 1;
}
else {
$message = "None.\n";
}
return $message;
}
sub sendStatus
{
my $hostname = `hostname -f`;
my $smtp = Net::SMTP->new($_[0]);
$smtp->mail($ENV{USER});
$smtp->to($_[1]);
$smtp->data();
$smtp->datasend("To: $_[1]\n");
$smtp->datasend("From: $ENV{USER}\n");
$smtp->datasend("Subject: $hostname System Update\n");
$smtp->datasend("\n");
$smtp->datasend($_[2]);
$smtp->dataend();
$smtp->quit;
} |
|
|
Back to top |
|
|
s0m3body n00b
Joined: 16 Nov 2003 Posts: 11
|
Posted: Thu Dec 11, 2003 12:27 pm Post subject: syncing multiple machines |
|
|
i'm sorry if there is an answer somewhere in the documetnation - i haven't found it
i have several servers running gentoo, doing emerge sync every couple of days
my question is - is it possible to change all of them but one to sync with my 'master' ?
then i need to sync master against rsync.gentoo.org and the rest of my servers against the master
not only that it reduces load on gentoo servers, it also reduces my internet traffic and saves me money
or shall i just run rsync command to sync /usr/portage instead of emerge sync (on 'slaves') ?
thanks,
martin |
|
Back to top |
|
|
Anior Guru
Joined: 17 Apr 2003 Posts: 317 Location: European Union (Stockholm / Sweden)
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|