#!/usr/bin/perl my $KSDIR = "/home/KickStart/cfg"; my $KSCONFIG = "$KSDIR/ks.config"; my $CONFIGD = "$KSDIR/config.d"; my $ACTIVED = "$KSDIR/ks.d"; my @HDTYPES = ( "prompt", "sd", "hd", "hdc" ); my @FWTYPES = ( "disable", "medium", "high" ); my @SELINUX = ( "disabled", "permissive", "enforcing" ); my @SETYPES = ( "targeted", "strict" ); my @TZONES = ( "US/Arizona", "US/Eastern", "US/Hawaii", "US/Pacific", "US/Central", "US/East-Indiana", "US/Indiana-Starke", "US/Mountain" ); my $DISCOLS = 3; my $STAGES; $STAGES->{1}->{suffix} = "P"; $STAGES->{1}->{desc} = "Pre"; $STAGES->{2}->{suffix} = "S"; $STAGES->{2}->{desc} = "Post (chroot)"; $STAGES->{3}->{suffix} = "N"; $STAGES->{3}->{desc} = "Post (No chroot)"; my $ks; my $cnt; my $run; print "Content-type: text/html\n\n"; print "\n"; print "
\n"; print "\n" if $DEBUG;
foreach my $line ( @stdin ) {
foreach my $pair ( split(/\&/,$line) ) {
$pair = URLDecode($pair);
if ( $pair =~ /^CF\+(\S+)=(.+)$/ ) {
print "file $1 = $2\n" if $DEBUG;
$rlst->{$1} = $2;
} elsif ( $pair =~ /^(\S+)=(.+)$/ ) {
print "config $1=$2\n" if $DEBUG;
$clst->{$1} = $2;
}
}
}
if ( open(RC, "$KSCONFIG") ) {
my @configs = ;
close RC;
system("cp", "-a", "$KSCONFIG.2", "$KSCONFIG.3");
system("cp", "-a", "$KSCONFIG.1", "$KSCONFIG.2");
system("cp", "-a", "$KSCONFIG", "$KSCONFIG.1");
if ( open(WC, ">$KSCONFIG") ) {
foreach ( @configs ) {
if ( /^(\w+)\=(.+)$/ ) {
if ( exists $clst->{$1} ) {
print WC "$1=$clst->{$1}\n";
delete $clst->{$1};
} else {
print WC "$1=$2\n";
}
} else {
print WC "$_";
}
}
foreach $new ( keys %{$clst} ) {
print WC "$new=$clst->{$new}\n";
}
} else {
print "Erorr: Could not open $KSCONFIG for read\n";
}
close WC;
} else {
print "Erorr: Could not open $KSCONFIG for write\n";
}
if ( opendir(CD, "$CONFIGD") ) {
my @fileList = grep(!/^\./, readdir(CD));
close CD;
foreach my $file ( @fileList ) {
if ( $file =~ /^(\w)(\d+.+)$/ ) {
print "$file: " if $DEBUG;
if ( -e "$ACTIVED/$file" ) {
if ( exists $rlst->{$file} ) {
print " Is turned on and should be turned on\n" if $DEBUG;
} else {
print " Is turned on and should be turned off\n" if $DEBUG;
unlink("$ACTIVED/$file");
}
} else {
if ( exists $rlst->{$file} ) {
print " Is turned off and should be turned on\n" if $DEBUG;
symlink("$CONFIGD/$file", "$ACTIVED/$file");
} else {
print " Is turned off and should be turned off\n" if $DEBUG;
}
}
} elsif ( $file =! /^HEADER/ ) {
} else {
print "Warning: What is this file $CONFIGD/$file
\n";
}
}
} else {
print "Erorr: Could not open directory $CONFIGD
\n";
}
print " \n" if $DEBUG;
}
# Get current setup
if ( open(C, "$KSCONFIG") ) {
print "\n" if $DEBUG; while (\n" if $DEBUG; close C; } else { print "Erorr: Could not open $KSCONFIG\n"; } if ( opendir(CD, "$CONFIGD") ) { foreach my $file ( grep(!/^\./, readdir(CD)) ) { if ( $file =~ /^([PSN])(\d+)(.+)$/ ) { my $act = $1; $run->{$act}->{$file}->{num} = $2; $run->{$act}->{$file}->{name} = $3; $run->{$act}->{$file}->{run} = ''; if (exists $cnt->{$act}) { ++$cnt->{$act}; } else { $cnt->{$act} = 1; } if ( open(F, "$CONFIGD/$file") ) { while () { if ( (/^\s*$/) || (/^\s*#/) ) { next; } elsif ( /^(\w+)\=(.+)$/ ) { $ks->{$1} = $2; print "$1 == $ks->{$1}\n" if $DEBUG; } } print "