-
Guillaume ROUSSE authoredGuillaume ROUSSE authored
account-manager.pl.in 11.73 KiB
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use lib qw(@modulesdir@);
use feature "switch";
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
use Config::Tiny;
use Data::Dumper;
use DateTime;
use English qw(-no_match_vars);
use Getopt::Long qw(:config auto_help);
use Log::Any::Adapter;
use Pod::Usage;
use AccountManager::Account;
use AccountManager::Account::Manager;
use AccountManager::Metadata;
use AccountManager::Service;
use AccountManager::Service::Manager;
use AccountManager::Token;
use AccountManager::Token::Manager;
use AccountManager::Tools;
my %options;
GetOptions(
\%options,
'profile=s',
'configuration=s',
'contacts=s',
'delete',
'displayname=s',
'email_address=s',
'expired',
'sp_entityid=s',
'token=s',
) or pod2usage(
-message => "unknown option, aborting\n",
-verbose => 0
);
my $action = $ARGV[0];
pod2usage(
-message => "no action given, aborting\n",
-verbose => 0
) unless $action;
my $configuration_file =
$options{configuration} || '@sysconfdir@/manager.conf';
my $configuration = Config::Tiny->read($configuration_file);
AccountManager::DB->register_db(
driver => $configuration->{database}->{type},
database => $configuration->{database}->{name},
host => $configuration->{database}->{host},
password => $configuration->{database}->{password},
username => $configuration->{database}->{user}
);
my $db = AccountManager::DB->new();
for ($action) {
when ('add_account') { add_account() }
when ('list_accounts') { list_accounts() }
when ('add_service') { add_service() }
when ('list_services') { list_services() }
when ('add_token') { add_token() }