From 7cbaf3e4e333fb7db0a357e8943e31e00e0c33dd Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Sat, 13 Sep 2014 16:33:30 +0200 Subject: Added mana script to manage as script launcher --- scripts/mana | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 scripts/mana (limited to 'scripts') diff --git a/scripts/mana b/scripts/mana new file mode 100755 index 0000000..b4bc38b --- /dev/null +++ b/scripts/mana @@ -0,0 +1,47 @@ +#!/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', + 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 [args...]\n\n"; + print "valid :\n\t"; +# TODO better presentation + while ( my ($key, $value) = each(%modules) ) { + print " " . $key; + } + print "\n"; + exit(0); +} -- cgit v1.2.1