From: Thomas Glanzmann Date: Sat, 22 Feb 2020 21:30:27 +0000 (+0100) Subject: add $url to exceptions.sites if the file exists X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/commitdiff_plain/2747626560b46ae7c8d3bf167f20549e8202c2e3?hp=5e257ef3d52a0bbb3de3179f83e0c20d841a823c add $url to exceptions.sites if the file exists --- diff --git a/supermicro-kvm.pl b/supermicro-kvm.pl index 79e4f03..93e91a0 100755 --- a/supermicro-kvm.pl +++ b/supermicro-kvm.pl @@ -46,6 +46,22 @@ sub read_inifile { %Ini; } +sub add_url_to_java_exceptions { + my $url = shift || die; + my $file = "$ENV{HOME}/.java/deployment/security/exception.sites"; + return unless -f ${file}; + open my $fh, '+<', $file || die; + unless (grep{m#${url}#} <$fh>){ + close $fh; + if (open my $fh, '>>', $file) { + print $fh "${url}\n"; + close $fh; + } + } else { + close $fh; + } +} + my %Config = read_inifile("$ENV{HOME}/.rsbs2rc"); my $hostalias = $ARGV[0]; @@ -62,6 +78,7 @@ if (!defined($hostalias) || !defined($Config{$hostalias})) { my $url = "http://" . ${$Config{$hostalias}}{"host"}; login($url, ${$Config{$hostalias}}{"user"}, ${$Config{$hostalias}}{"pass"}); +add_url_to_java_exceptions($url); my $response = $ua->get("${url}/cgi/url_redirect.cgi?url_name=ikvm&url_type=jwsk"); die $response->status_line if (!($response->is_success));