#!/h/COE/Comp/PERL5/bin/perl -T -I/h/COE/lib -w
#-
# Copyright (C) 2002, Federal Linux Systems
# License: GNU Lesser General Public License, v2.1
#-
use strict;
use Coe;
my $PRGM="COE_assign_app_to_profile";
my $VERSION="1.1.4.1";
if (@ARGV == 0) {
&useage;
exit 202;
}
sub useage {
print "Useage: $PRGM [options] \"\" ";
print "\"\"\n";
}
my $applabel="a";
my $profile="a";
my $coedatstr="a";
my $pscope="a";
my $arg1;
my $flag="false";
while (@ARGV > 0 ){
$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 {
$profile=$arg1;
$pscope=cleanString(shift,1);
$applabel=cleanString(shift,1);
}
}
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# do some simple sanity checks
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# check global scope
if ("$pscope" eq "l" || "$pscope" eq "local" ) {
$pscope="local";
} elsif ("$pscope" eq "g" || "$pscope" eq "global" ) {
$pscope="global";
} else {
&useage;
exit 202;
}
# check to see if profile exists and get its acct group
# check to see if application exists for this acct group
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# define some stuff
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# path for the AppData data COEDAT
my $coedat=coeFileConv "COE_USER/$pscope/Profiles/.ProfileApp.dat";
# ProfileApp.dat == profile:applabel
$coedatstr="$profile:$applabel\n";
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# if the profile name and application label are unique, append it to the COEDAT
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
my $COEDAT = readFile "$coedat";
while (<$COEDAT>) { chomp(); if (/^$profile:$applabel$/) { $flag="true"; }}
close $COEDAT;
if ("$flag" eq "false") {
open COEDAT, (">>$coedat") || die "Cannot open COEDAT $coedat: $!\n";
print COEDAT "$coedatstr";
close COEDAT;
exit 0;
} else {
exit 218;
}
exit 0;