#!/h/COE/Comp/PERL5/bin/perl -T -I/h/COE/lib  -U
#-
 # Copyright (C) 2002, Federal Linux Systems
 # License: GNU Lesser General Public License, v2.1
#- 
 # need -U to allow rmtree
 # drop -w for insecure dependency warning

use strict;
use Coe;
use File::Path;

my $PRGM="COE_delete_all_profile_locks";
my $VERSION="1.1.4.1";

if (@ARGV == 0) {
	&useage;
	exit 202;
} 

sub useage {
	print "Useage: $PRGM [options] \n";
} 

my $arg1;
my $pscope="all";
my $coedat;
my $perm="0777";

$arg1=cleanString(shift,1);
if ("$arg1" eq "-h") {
	useage;
	exit 0;
} elsif ("$arg1" eq "-H") {
	coeMan("COE_COMP/UserMgmt/docs/man/$PRGM");
	exit 0;
} elsif ("$arg1" eq "-V") {
	print "VERSION: $VERSION\n";
   	exit 0;
} else {
	$pscope=$arg1;
}

if ("$pscope" eq "l" || "$pscope" eq "local" ) {
	$pscope="local";
} elsif ("$pscope" eq "g" || "$pscope" eq "global" ) {
	$pscope="global";
} else {
	$pscope="all";
}

if ("$pscope" ne "global") {
	# set the path to the locked profile directory
	$coedat=coeFileConv "COE_USER/local/Profiles/.LockedProfiles";
	rmtree $coedat;
	mkdir $coedat;
	chmod oct($perm), $coedat;
}

if ("$pscope" ne "local") {
	# set the path to the locked profile directory
	$coedat=coeFileConv "COE_USER/global/Profiles/.LockedProfiles";
	rmtree $coedat;
	mkdir $coedat;
	chmod oct($perm), $coedat;
}

exit 0;