#!/usr/bin/perl
use strict; use warnings;
=pod

=head1 NAME

vox-tomcat-context - list, add or remove Tomcat's vote-server contexts

=head1 SYNOPSIS

vox-tomcat-context [+|- VOTE_SERVER_NAME]

vox-tomcat-context --help

=head1 EXAMPLES

vox-tomcat-context + v

vox-tomcat-context - voff

=cut

use Pod::Usage qw( pod2usage );


    my $contextDir = '/etc/tomcat-6/Catalina/public.reluk.ca';



##########################################################################################


{
    my $action = shift;  defined $action or $action = '';
    if( $action eq '+' )
    {
        my $voteServer = shift; defined $voteServer or pod2usage( -verbose => 1 ); # and exits
        system( "ln -sf ../../../../home/$voteServer/votorola/web/$voteServer.xml $contextDir/" );
    }
    elsif( $action eq '-' )
    {
        my $voteServer = shift; defined $voteServer or pod2usage( -verbose => 1 ); # and exits
        system( "rm $contextDir/$voteServer.xml" );
    }
    elsif( $action eq '--help' )
    {
        pod2usage( -verbose => 1 ); # and exits
    }
    system( "ls $contextDir/" );
}