diff options
author | Trent Piepho <xyzzy@speakeasy.org> | 2006-08-02 22:49:51 -0300 |
---|---|---|
committer | Trent Piepho <xyzzy@speakeasy.org> | 2006-08-02 22:49:51 -0300 |
commit | 5d240a7d7f05be93610bae704a8bb4415907d247 (patch) | |
tree | 766a87c3d8361015b6c5316398d8624161afe3a5 /v4l | |
parent | c76882c71e223b1a6bb2f1f0043227d5cf9e3e82 (diff) | |
download | mediapointer-dvb-s2-5d240a7d7f05be93610bae704a8bb4415907d247.tar.gz mediapointer-dvb-s2-5d240a7d7f05be93610bae704a8bb4415907d247.tar.bz2 |
Look for module utilities in /sbin directories
From: Trent Piepho <xyzzy@speakeasy.org>
Normally programs like modinfo are in /sbin, and non-root users often
don't have this in their path. Make the rmmod.pl script look in some
extra directories like /sbin, /usr/sbin, etc. if it can't find the
utilities in the path.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Diffstat (limited to 'v4l')
-rwxr-xr-x | v4l/scripts/rmmod.pl | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/v4l/scripts/rmmod.pl b/v4l/scripts/rmmod.pl index ade231707..d190a9edf 100755 --- a/v4l/scripts/rmmod.pl +++ b/v4l/scripts/rmmod.pl @@ -28,8 +28,17 @@ my %debug = ( "tuner" => "tuner_debug=1", ); +sub findprog($) +{ + foreach(split(/:/, $ENV{PATH}),qw(/sbin /usr/sbin /usr/local/sbin)) { + return "$_/$_[0]" if(-x "$_/$_[0]"); + } + die "Can't find needed utility '$_[0]'"; +} + sub parse_dir { my $file = $File::Find::name; + my $modinfo = findprog('modinfo'); if (!($file =~ /[.]ko$/)) { return; @@ -38,7 +47,7 @@ sub parse_dir { my $module = $file; $module =~ s|^[./]*(.*)[.]ko|\1|; - open IN, "modinfo $file|grep depends|cut -b 17-|"; + open IN, "$modinfo $file|grep depends|cut -b 17-|"; while (<IN>) { my $deps = $_; $deps =~ s/\n//; @@ -123,33 +132,36 @@ sub orderdep () sub insmod ($) { my $debug=shift; + my $modprobe = findprog('modprobe'); + my $insmod = findprog('insmod'); while ( my ($key, $value) = each(%reqmodules) ) { - printf ("modprobe $key\n"); - system ("modprobe $key"); + print ("$modprobe $key\n"); + system ("$modprobe $key"); } foreach my $key (@modlist) { if ($debug) { my $dbg=$debug{$key}; - printf "insmod ./$key.ko $dbg\n"; - system "insmod ./$key.ko $dbg\n"; + print "$insmod ./$key.ko $dbg\n"; + system "$insmod ./$key.ko $dbg\n"; } else { - printf "insmod ./$key.ko\n"; - system "insmod ./$key.ko\n"; + print "$insmod ./$key.ko\n"; + system "$insmod ./$key.ko\n"; } } } sub rmmod () { + my $rmmod = findprog('rmmod'); while (my $key=pop @modlist) { my $dep=$key; $dep=~s/[\-]/_/g; if (exists ($loaded{$dep})) { - printf "rmmod $dep\n"; - system "rmmod $dep\n"; + print "$rmmod $dep\n"; + system "$rmmod $dep\n"; } } } |