#!/usr/bin/perl
# 
# ***** BEGIN LICENSE BLOCK *****
# Zimbra Collaboration Suite Server
# Copyright (C) 2005, 2006, 2007, 2009, 2010, 2013, 2014, 2015, 2016 Synacor, Inc.
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software Foundation,
# version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.
# ***** END LICENSE BLOCK *****
# 

use strict;

use lib "/opt/zimbra/common/lib/perl5";
use Zimbra::Util::Common;

use LWP::UserAgent;

my $baseDir = "/opt/zimbra";

my $version = $ARGV[0];
my $email = $ARGV[1];

my $URL = "http://www.zimbra.com/cgi-bin/notify.cgi?VER=$version&MAIL=$email";

print "Notifying Zimbra of installation via $URL\n\n";

# Create a user agent object
my $ua = LWP::UserAgent->new;
$ua->agent("ZimbraInstaller/0.1 ");

# Create a request
my $req = HTTP::Request->new(GET => "$URL");

# Pass request to the user agent and get a response back
my $res = $ua->request($req);

# Check the outcome of the response
if ($res->is_success) {
	print "Notification complete\n\n";
} else {
	print "ERROR: Notification failed ";
	print $res->{status_line};
	print "\n";
}

exit (0);
