From 35359e4f0abdf7bccb915866cd464cc5a0ea5474 Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Wed, 10 Dec 2014 18:22:14 +0100 Subject: moved mpan.pl to mpan, easier to run by command line --- MANIFEST | 2 +- Makefile.PL | 2 +- extras/polkit/org.mageia.mpan.policy | 2 +- scripts/mana | 2 +- scripts/mpan | 102 +++++++++++++++++++++++++++++++++++ scripts/mpan.pl | 102 ----------------------------------- 6 files changed, 106 insertions(+), 106 deletions(-) create mode 100755 scripts/mpan delete mode 100755 scripts/mpan.pl diff --git a/MANIFEST b/MANIFEST index 38d3fb9..b8d53ad 100644 --- a/MANIFEST +++ b/MANIFEST @@ -78,7 +78,7 @@ scripts/manalog scripts/manaproxy scripts/manaservice scripts/manauser -scripts/mpan.pl +scripts/mpan share/images/Blank16x16.png share/images/Check.png share/images/Check_16x16.png diff --git a/Makefile.PL b/Makefile.PL index e380a1e..834e6e0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -62,7 +62,7 @@ WriteMakefile( "Modern::Perl" => 1.03, "autodie" => 2.20, }, - EXE_FILES => [ qw( scripts/mpan.pl + EXE_FILES => [ qw( scripts/mpan scripts/mana scripts/manaadduser scripts/manaclock diff --git a/extras/polkit/org.mageia.mpan.policy b/extras/polkit/org.mageia.mpan.policy index 5d793cf..1597cc8 100644 --- a/extras/polkit/org.mageia.mpan.policy +++ b/extras/polkit/org.mageia.mpan.policy @@ -15,7 +15,7 @@ auth_admin auth_admin - /usr/bin/mpan.pl + /usr/bin/mpan true diff --git a/scripts/mana b/scripts/mana index 329f3b2..45acbfd 100755 --- a/scripts/mana +++ b/scripts/mana @@ -51,7 +51,7 @@ my %modules = ( descr => "manahost: hosts manager", }, pan => { - exec => '/usr/bin/mpan.pl', + exec => '/usr/bin/mpan', descr => "mpan: admin panel", }, proxy => { diff --git a/scripts/mpan b/scripts/mpan new file mode 100755 index 0000000..589a72e --- /dev/null +++ b/scripts/mpan @@ -0,0 +1,102 @@ +#!/usr/bin/perl +# vim: set et ts=4 sw=4: +# Copyright 2012 Steven Tucker +# Copyright 2013 Matteo Pasotti +# Copyright 2014 Angelo Naselli +# +# This file is part of AdminPanel +# +# AdminPanel is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# AdminPanel 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 AdminPanel. If not, see . + +use strict; +use warnings; +use diagnostics; +use AdminPanel::Privileges; +use AdminPanel::SettingsReader; +use AdminPanel::MainDisplay; +use yui; + +my $cmdline = new yui::YCommandLine; + +usage() if $cmdline->find("--help") > 0 || $cmdline->find("-h") > 0; + +my $settings = getSettings(); + +if ($cmdline->find("--dev") > 0) { + print "== Development mode ON\n"; +} +else { + ask_for_authentication($settings->{priv_method}) if is_root_capability_required(); +} +my $mainWin = new AdminPanel::MainDisplay(); +while (1) { + my $launch = $mainWin->start(); + + if ($launch) { + $mainWin->destroy(); + $launch->start(); + } + else { + $mainWin->destroy(); + last; + } + $mainWin->setupGui(); +} + + +sub usage { + print "\n"; + print "Usage mpan [options...]\n\n"; + print "Options:\n"; + print "\t--help | -h print this help\n"; +## anaselli: --name now is used only to add a path to /etc (e.g. --name mcc2 means /etc/mcc2) + # and it is overriden by --conf_dir, so it should be discussed better to understand + # if it is really needed any more. + # Window title is got from settings.conf (key title) + print "\t--name string specify the window title of the administration panel\n"; + print "\t--conf_dir path specify the settings.conf file directory\n"; + print "\n"; + exit(0); +} + +# adpanel settings +sub getSettings { + my ($self) = @_; + + my $confDir = "/etc/mpan"; + # yui commandline parser + my $pos = $cmdline->find("--conf_dir"); + if ($pos > 0) { + $confDir = $cmdline->arg($pos + 1); + } + else { + $pos = $cmdline->find("--name"); + if ($pos > 0) { + $confDir = "/etc/" . $cmdline->arg($pos+1); + } + } + # configuration file name + my $fileName = "$confDir/settings.conf"; + return new AdminPanel::SettingsReader($fileName); +} + +=pod + +=head1 main + + main launcher + +=cut + +1; diff --git a/scripts/mpan.pl b/scripts/mpan.pl deleted file mode 100755 index 29b6d8e..0000000 --- a/scripts/mpan.pl +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/perl -# vim: set et ts=4 sw=4: -# Copyright 2012 Steven Tucker -# Copyright 2013 Matteo Pasotti -# Copyright 2014 Angelo Naselli -# -# This file is part of AdminPanel -# -# AdminPanel is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# AdminPanel 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 AdminPanel. If not, see . - -use strict; -use warnings; -use diagnostics; -use AdminPanel::Privileges; -use AdminPanel::SettingsReader; -use AdminPanel::MainDisplay; -use yui; - -my $cmdline = new yui::YCommandLine; - -usage() if $cmdline->find("--help") > 0 || $cmdline->find("-h") > 0; - -my $settings = getSettings(); - -if ($cmdline->find("--dev") > 0) { - print "== Development mode ON\n"; -} -else { - ask_for_authentication($settings->{priv_method}) if is_root_capability_required(); -} -my $mainWin = new AdminPanel::MainDisplay(); -while (1) { - my $launch = $mainWin->start(); - - if ($launch) { - $mainWin->destroy(); - $launch->start(); - } - else { - $mainWin->destroy(); - last; - } - $mainWin->setupGui(); -} - - -sub usage { - print "\n"; - print "Usage mpan.pl [options...]\n\n"; - print "Options:\n"; - print "\t--help | -h print this help\n"; -## anaselli: --name now is used only to add a path to /etc (e.g. --name mcc2 means /etc/mcc2) - # and it is overriden by --conf_dir, so it should be discussed better to understand - # if it is really needed any more. - # Window title is got from settings.conf (key title) - print "\t--name string specify the window title of the administration panel\n"; - print "\t--conf_dir path specify the settings.conf file directory\n"; - print "\n"; - exit(0); -} - -# adpanel settings -sub getSettings { - my ($self) = @_; - - my $confDir = "/etc/mpan"; - # yui commandline parser - my $pos = $cmdline->find("--conf_dir"); - if ($pos > 0) { - $confDir = $cmdline->arg($pos + 1); - } - else { - $pos = $cmdline->find("--name"); - if ($pos > 0) { - $confDir = "/etc/" . $cmdline->arg($pos+1); - } - } - # configuration file name - my $fileName = "$confDir/settings.conf"; - return new AdminPanel::SettingsReader($fileName); -} - -=pod - -=head1 main - - main launcher - -=cut - -1; -- cgit v1.2.1