'c|config=s' => \my $config_file,
's|storage=s' => \my $storage_dir,
'H|host=s' => \my $hostname,
+ 'U|user=s' => \my $username,
'allow-empty' => \my $allow_empty,
'a|all' => \my $update_all,
'g|group=s' => \my @update_groups,
die "Requires --all or --group option\n"
unless $update_all or @update_groups;
+die "The --user option also requires a --host to be set\n"
+ if defined($username) and not defined($hostname);
+
my $config = System::Introspector::Config->new(
config_file => (defined($config_file)
? $config_file
@update_groups = $config->groups
if $update_all;
+
+my $sudo_user = $config->sudo_user;
for my $group (@update_groups) {
my $group_dir = "$storage_dir/$group";
$storage->create
unless $storage->exists;
my $state = System::Introspector::State->new(
- defined($hostname) ? (host => $hostname) : (),
+ defined($hostname) ? (host => $hostname) : (),
+ defined($username) ? (user => $username) : (),
+ defined($sudo_user) ? (sudo_user => $sudo_user) : (),
storage => $storage,
config => $config->config_for_group($group),
);
eval { $state->fetch_and_store };
if (my $error = $@) {
+ warn "Error: $error\n";
$storage->reset;
}
else {