{
    use esmith::NetworksDB;
    use esmith::ConfigDB;

    my $ndb = esmith::NetworksDB->open_ro();

    $localAccess = $ndb->local_access_spec();
    $localAccess =~ s#/255\.255\.255\.255##g;

        my $dbh = esmith::ConfigDB->open() || die "Unable to open configuration dbase.";
        my %sa_conf = $dbh->get('unjunkmgr')->props;

        while (my ($parameter,$value) = each(%sa_conf)) {
          if ($parameter eq 'LocalOnly') {
           $local = $value;
          }
          if ($parameter eq 'enabled') {
           $enabled = $value;
          }

        }

        $OUT = "";
        if (not (uc($enabled) eq 'YES')) {
         return;
        }
        $OUT .= "# This is the location of the UnJunk web interface\n";

        $OUT .= "AddHandler cgi-script .pl\n";
        $OUT .= "Alias /unjunkmgr /usr/local/unjunkmgr\n";
        $OUT .= "<Directory /usr/local/unjunkmgr>\n";
        $OUT .= "    Options +FollowSymLinks +ExecCGI\n";
        $OUT .= "    AllowOverride All\n";
        $OUT .= "    <FilesMatch \.php\$\>\n";
        $OUT .= "        SetHandler \"proxy:unix:/var/run/php-fpm/php$version.sock|fcgi://localhost\"\n";
        $OUT .= "    </FilesMatch>\n";

        if (uc($local) eq 'YES') {
          $OUT .= "    Require ip $localAccess\n";
        } else {
          $OUT .= "    Require all granted\n";
        }

        $OUT .= "</Directory>\n";
}

