diff options
author | Matteo Pasotti <matteo.pasotti@gmail.com> | 2014-09-13 18:37:19 +0200 |
---|---|---|
committer | Matteo Pasotti <matteo.pasotti@gmail.com> | 2014-09-13 18:37:19 +0200 |
commit | 9f5c70691a909045c35172584a7c71303ca9f8f5 (patch) | |
tree | f2cfacb630c25acaae2e391bcfd36115a7f6ec28 /scripts | |
parent | 8d309a849a49df7e16569d8f3390cb8d1971dda0 (diff) | |
parent | b2a65e49195d237aacd68905747953838baa8797 (diff) | |
download | manatools-9f5c70691a909045c35172584a7c71303ca9f8f5.tar manatools-9f5c70691a909045c35172584a7c71303ca9f8f5.tar.gz manatools-9f5c70691a909045c35172584a7c71303ca9f8f5.tar.bz2 manatools-9f5c70691a909045c35172584a7c71303ca9f8f5.tar.xz manatools-9f5c70691a909045c35172584a7c71303ca9f8f5.zip |
Merge branch 'master' of ssh://git.mageia.org/software/adminpanel
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/mana | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/mana b/scripts/mana new file mode 100755 index 00000000..ee3da644 --- /dev/null +++ b/scripts/mana @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +use AdminPanel::Privileges; + +use yui; + +# TODO from configuration file? +my %modules = ( + log => '/usr/bin/manalog', + user => '/usr/bin/manauser', + service => '/usr/bin/manaservice', + clock => '/usr/bin/manaclock', + host => '/usr/bin/manahost', + pan => '/usr/bin/mpan.pl', + proxy => '/usr/bin/manaproxy', + +); + +my $cmdline = new yui::YCommandLine; + +usage() if($cmdline->find("--help") > 0 || $cmdline->find("-h") > 0); +usage() if scalar(@ARGV) < 1; + +my $cmd = $ARGV[0]; + +die "Command ". $cmd . " not found!\n" if !defined($modules{$cmd}); + +my $mod = $modules{$cmd}; +shift(@ARGV); + +if(is_root_capability_required()) { + system("/usr/bin/pkexec", $mod, @ARGV); +} else { + system($mod, @ARGV); +} + +sub usage { + print "\n"; + print "Usage mana --help | -h print this help\n"; + print "Usage mana <command> [args...]\n\n"; + print "valid <commands>:\n\t"; +# TODO better presentation + while ( my ($key, $value) = each(%modules) ) { + print " " . $key; + } + print "\n"; + exit(0); +} |