#!/usr/bin/perl ## 09/09/2014, Olivier Salaün ## Command-line script to remove expired test accounts ## The script also updates the simpleSamlPhp config file use strict; use utf8; use lib "/opt/testidp/IdPAccountManager/lib"; use lib "/opt/testidp/IdPAccountManager/conf"; use Getopt::Long; use POSIX; use IdPAccountManager::TestAccount; my %options; unless (&GetOptions(\%options, 'help', 'list_only')) { die "Unknown options."; } if ($options{'help'}) { printf "$0 --list_only\n"; } if ($options {'list_only'}) { my $all = IdPAccountManager::TestAccount::list_test_accounts('query' => ['expiration_date' => {lt => time}]); foreach my $test_account (@$all) { $test_account->print(); } }else { ## Remove expired test accounts my $all = IdPAccountManager::TestAccount::list_test_accounts('query' => ['expiration_date' => {lt => time}]); printf "Removing expired test accounts...\n"; foreach my $test_account (@$all) { $test_account->print(); $test_account->delete || die; } printf "%d accounts removed\n", $#{$all}+1; #&IdPAccountManager::Tools::dump_var(\%Conf::global, 0, \*STDOUT); ## Update simpleSamlPhp configuration file printf "Update simpleSamlPhp configuration file...\n"; IdPAccountManager::Tools::update_ssp_authsources(); }