Changeset 29683

Show
Ignore:
Timestamp:
09.01.2015 15:53:33 (4 years ago)
Author:
jts21
Message:

Added option to delete sites/interfaces

Location:
main/trunk/package-kits/scripts
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/package-kits/scripts/gs-mkinterface.pl

    r29682 r29683  
    88use Greenstone::Interface; 
    99 
     10my $delete = 0; 
     11 
     12for (@ARGV) { 
     13    if (/^-/) { 
     14        if (/^-delete$/) { 
     15            $delete = 1; 
     16        } else { 
     17            die "Unknown flag '$_'\n"; 
     18        } 
     19    } 
     20} 
     21 
    1022my $interface = Greenstone::Interface->new (shift); 
    11 $interface->exists and die "Interface already exists\n"; 
    12 $interface->create and print "Interface created\n"; 
     23if ($delete) { 
     24    $interface->delete and print "Interface deleted\n"; 
     25} else { 
     26    $interface->create and print "Interface created\n"; 
     27} 
  • main/trunk/package-kits/scripts/gs-mksite.pl

    r29675 r29683  
    88use Greenstone::Site; 
    99 
     10my $delete = 0; 
     11 
     12for (@ARGV) { 
     13    if (/^-/) { 
     14        if (/^-delete$/) { 
     15            $delete = 1; 
     16        } else { 
     17            die "Unknown flag '$_'\n"; 
     18        } 
     19    } 
     20} 
     21 
    1022my $site = Greenstone::Site->new (shift); 
    11 $site->exists and die "Site already exists\n"; 
    12 $site->create and print "Site created\n"; 
     23if ($delete) { 
     24    $site->delete and print "Site deleted\n"; 
     25} else { 
     26    $site->create and print "Site created\n"; 
     27} 
  • main/trunk/package-kits/scripts/perllib/Greenstone/Directory.pm

    r29678 r29683  
    66use base 'Exporter'; 
    77 
     8use File::Path 'remove_tree'; 
    89use Greenstone::Config; 
    910 
     
    6162sub create { 
    6263    my $self = shift; 
    63     $self->exists and return 0; 
     64    if ($self->exists) { 
     65        print STDERR "Site already exists\n"; 
     66        return 0; 
     67    } 
    6468    mkdir $self->dir or die "Failed to create directory: $!\n"; 
    6569    return 1; 
    6670} 
    6771 
     72sub delete { 
     73    my $self = shift; 
     74    unless ($self->exists) { 
     75        print STDERR "Site doesn't exist\n"; 
     76        return 0; 
     77    } 
     78    remove_tree $self->dir or die "Failed to remove directory: $!\n"; 
     79    return 1; 
     80} 
     81 
    68821;