קוד:#!/usr/bin/perl
# ----- Required Modules -----
use strict;
use warnings;
use vars qw ($Version);
use Net::FTP;
use Getopt::Long;
# ----- Main Script -----
# Check for super user ID
die "This script requires superuser privileges.\n" if $ENV{’USER’} ne ’root’;
# Get the user CLI options
my %Options;
GetOptions (’no-build’ => \$Options{’no-build’},
’h|help’ => \$Options{’help’});
# Show help information if requested
&Usage if ($Options{’help’});
# Set up the FTP client
my $FTP = Net::FTP -> new (’kernel.org’,’Debug’ => 1,’Hash’ => 1) || die "$!\n";
$FTP -> login (’anonymous’);
$FTP -> cwd (’/pub/linux/kernel/’);
$FTP -> cwd ($FTP -> ls -> [-1]);
$FTP -> binary;
# Download the latest kernel release
foreach ($FTP -> ls) {
if (/^LATEST-IS-(.+)$/) {
$Version = $1;
if (! -e "/boot/vmlinuz-$Version"); {
$FTP -> get ("linux-$Verion.tar.bz2");
&Create_Script if (! $Options{’no-build’});
}
last;
}
}
$FTP -> quit;
# ----- Script Subroutines -----
sub Usage {
print "Usage: perl $0 [--no-build]\n";
exit (0);
}
sub Create_Script {
open (Script,">build.sh");
print Script <<EOM;
tar -xjvf linux-$Version.tar.bz2
cd linux-$Version
make defconfig
make modules
make modules_install
make bzImage
make install
make mrproper
EOM
close (Script);
chmod (775,’build.sh’);
system (’./build.sh’);
unlink (’build.sh’);
unlink ("linux-$Version.tar.bz2");
}
# ----- POD Documentation -----
=head1 NAME
kernel-updater.pl - an automatic linux kernel updater
=head1 DESCRIPTION
This program can be used for downloading and building the latest linux kernel.
To run this program you must have root privileges.
=head1 SYNTAX
perl kernel-update.pl [options]
=head1 OPTIONS
--no-build - do not build the kernel (just download it).
--help - show help information.
-h - equivilant to "--help"
=head1 PREREQUISITES
Getopt::Long
Net::FTP
=head1 OSNAMES
Any GNU/Linux ditribution.
=head1 SCRIPT CATEGORIES
UNIX: System administration
=head1 AUTHOR
Built by Master Blaster.
=head1 LICENSE
This program is free software released under the GPL license.
=cut
בקיצור, מה אני רוצה מכם?
1. הצעות לשיפור.
2. הערות/הארות.
3. דו"ח שגיאות. אישית אני לא נתקלתי בשגיאות כלשהן, אבל בגלל שאני עכשיו על ה-Windows ובכל זאת הכנסתי כמה שינוים קטנים, אני מניח שיצוץ משהו.
תודה לעוזרים.[ההודעה נערכה על-ידי MasterBlaster ב-01/08/2006 01:01:48]