sub createLicenseWindow { my $mins = int(8); #waittime in minutes my $waittime = int($mins * 60); #wait in seconds my @serailset; my $mainwindow = MainWindow->new(); $mainwindow->title("License Units"); $mainwindow->configure(-background=> 'wheat'); my $center = $mainwindow->Frame->grid(); $center->configure(-background=> 'wheat'); $center->Label(-text=>"Select license option to set on unit. New feature.\n\nWill automatticly continue after $mins minutes.", -background=>'tan', -foreground=>'green', -font=>['courier', '14', 'bold'])->grid(-row=>0, -column=>0, -columnspan=>2, -sticky=>'ew'); my $lic_frame = $center->Scrolled('Frame', -scrollbars=>'e', -height=>'300')->grid(-row=>1, -column=>0, -columnspan=>2); my $lic_grid = $lic_frame->grid(); $lic_grid->configure(-background=> 'wheat'); my @serailEnt; for (my $count = 0; $count < @{$SYSTEMJOB->{systemlist}->[0]->{system}}; $count++) { my $system = $SYSTEMJOB->{systemlist}->[0]->{system}->[$count]; my $serail = \$serialEnt[$count]; my $bgcolor; if ($count % 2 == 0) { $bgcolor="LemonChiffon"; } else { $bgcolor="cornsilk"; } $lic_grid->Label(-text=>"IP: ".$system->{ip}->[0], -background=>$bgcolor."1")->grid(-row=>$count, -column=>0); $serail = $lic_grid->LabEntry(-label=>"Serial: ", -background=>$bgcolor."2", -textvariable=>\$system->{serial}->[0], -labelPack=>[-side=>'left', -anchor=>'w'])->grid(-row=>$count, -column=>1); $lic_grid->BrowseEntry(-label=>"Set License: ", -background=>$bgcolor."3", -variable=>\$system->{license}->[0], -choices=>\@lic_options)->grid(-row=>$count, -column=>2); my $blink = $lic_grid->Button(-text=>"Blink Unit", -background=>$bgcolor."4", -command=>sub { if ($system->{raidtype}->[0] =~ m/software/i or $system->{raidtype}->[0] =~ m/unknown/i) { qx"wincuri 2 $system->{ip}->[0] \"/usr/AmiNas/cli blink -t ld -l /dev/md255 raid\""; } if ($system->{raidtype}->[0] =~ m/hardware/i or $system->{raidtype}->[0] =~ m/unknown/i) { qx"wincuri 2 $system->{ip}->[0] \"/usr/AmiNas/cli blink -t ld -l /dev/sda raid\""; } $serail->focus; })->grid(-row=>$count, -column=>3); if ($system->{raidtype}->[0] =~ m/none/i) { $blink->enabled = 0; } } for (my $count = 0; $count < @serailEnt; $count++) { my $serail = \$serialEnt[$count]; $serail->bind('' => sub{ print "Key pressed for serial $count\n"; my $system = $SYSTEMJOB->{systemlist}->[0]->{system}->[$count]; my $nextserail = \$serialEnt[$count+1]; $system->{serial}->[0] =~ s/\n//g; if (length($system->{serial}->[0]) >= 15) { $nextserail->focus; } }); } $center->Button(-text=>"Continue", -background=>'tan', -command=>sub { my $allset = 2; my $message = ""; for (my $count = 0; $count < @{$SYSTEMJOB->{systemlist}->[0]->{system}}; $count++) { my $system = $SYSTEMJOB->{systemlist}->[0]->{system}->[$count]; if ($system->{serial}->[0] eq "") { $allset = 0; } elsif (length($system->{serial}->[0]) ne 15) { $message .= "Serial number ".$system->{serial}->[0]." is ".length($system->{serial}->[0])." charaters\n"; $allset = 1; } elsif (length($system->{serial}->[0]) eq 15) { my $set = 1; foreach my $alreadydone (@serailset) { if ($system->{ip}->[0] eq $alreadydone) { $set = 0; } } if ($set == 1) { qx"wincuri 2 ".$system->{ip}->[0]." \"echo '".$system->{serial}->[0]."' > /etc/itxserial\""; push(@serialset, $system->{ip}->[0]); } } } if ($allset == 1) { $mainwindow->messageBox(-message=>"Serial numbers must be 15 charaters long\n\n$message", -title=>"Invalid Input"); } elsif ($allset == 2) { $waittime = -1; $mainwindow->destroy; } })->grid(-row=>2, -column=>0, -columnspan=>2, -sticky=>'ew'); $center->LabEntry(-label=>"Auto Continue in: ", -background=>'tan', -textvariable=>\$waittime, -labelPack=>[-side=>'left', -anchor=>'w'])->grid(-row=>3, -column=>0); $center->Button(-text=>"Stop Timer", -background=>'tan', -command=>sub {$waittime = -1;})->grid(-row=>3, -column=>1); my $timer = $mainwindow->repeat(1000, sub{ if ($waittime == 0) { my $allset = 1; for (my $count = 0; $count < @{$SYSTEMJOB->{systemlist}->[0]->{system}}; $count++) { my $system = $SYSTEMJOB->{systemlist}->[0]->{system}->[$count]; if ($system->{serial}->[0] eq "" or length($system->{serial}->[0]) ne 15) { $allset = 0; } elsif (length($system->{serial}->[0]) eq 15) { my $set = 1; foreach my $alreadydone (@serailset) { if ($system->{ip}->[0] eq $alreadydone) { $set = 0; } } if ($set == 1) { qx"wincuri 2 ".$system->{ip}->[0]." \"echo '".$system->{serial}->[0]."' > /etc/itxserial\""; push(@serialset, $system->{ip}->[0]); } } } if ($allset == 1) { $waittime = -1; $mainwindow->destroy; } else { $waittime = -1; licenseEmail(); } } elsif ($waittime > 0) { $waittime--; } }); }