#!/usr/bin/perl # vim: set et ts=4 sw=4: #***************************************************************************** # # Copyright (c) 2014 Angelo naselli # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # #***************************************************************************** use AdminPanel::Privileges; use yui; # TODO from configuration file? # TODO localization for descriptions my %modules = ( log => { exec => '/usr/bin/manalog', descr => "manalog: journalct log reader", }, user => { exec => '/usr/bin/manauser', descr => "manauser: user manager", }, service => { exec => '/usr/bin/manaservice', descr => "manaservice: service manager", }, clock => { exec => '/usr/bin/manaclock', descr => "manaclock: date/time manager", }, host => { exec => '/usr/bin/manahost', descr => "manahost: hosts manager", }, pan => { esxec => '/usr/bin/mpan.pl', descr => "mpan: admin panel", }, proxy => { exec => '/usr/bin/manaproxy', descr => "manaproxy: proxy manager", }, ); 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}->{exec}; shift(@ARGV); if(is_root_capability_required()) { system("/usr/bin/pkexec", $mod, @ARGV); } else { system($mod, @ARGV); } #============================================================= =head2 usage =head3 DESCRIPTION usage print the mana usage help =cut #============================================================= sub usage { print "\n"; print "Usage mana --help | -h print this help\n"; print "Usage mana [args...]\n\n"; print "valid :\n"; # TODO better presentation while ( my ($key, $value) = each(%modules) ) { print "<" . $key . ">\t\t". $value->{descr} . "\n"; } print "\n"; exit(0); }