kickstart file generate tool use cgi

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/perl -w
use CGI;
my $ks_cgi=new CGI;
my $ks_ip="10.10.99.103";
# auto mount centos isos in /mnt
# use autofs mount iso images dynamically
# ln -s /mnt /var/www/html
my $ks_dir="mnt";
my $ks_distro=$ks_cgi->param("distro");
my @ks_client=split(/\./,$ENV{'REMOTE_ADDR'});
my $ks_hostname="$ks_distro-$ks_client[-2]-$ks_client[-1]";
my $ks_size=$ks_cgi->param("size");

my $ks_addr_http="url --url http://$ks_ip/$ks_dir/$ks_distro";
my $ks_addr_nfs="nfs nfs:$ks_ip:/$ks_dir/$ks_distro";
my $ks_addr_ftp="ftp://$ks_ip/$ks_dir/$ks_distro";
my %ks_src_type=(
	http=>$ks_addr_http,
	nfs=>$ks_addr_nfs,
	ftp=>$ks_addr_ftp
	);
my @ks_inst_type=('text','install');
my %ks_lang=(
	lang=>'lang en_US.UTF-8',
	support=>'langsupport --default=en_US.UTF-8 zh_CN.UTF-8 en_US.UTF-8',
	kbd=>'keyboard us'
	);
my %ks_network=(
	dev=>'network --device eth0',
	boot=>'--bootproto dhcp',
	hostname=>"--hostname $ks_hostname"
	);
my %ks_sec=(
	rootpwd=>'rootpw 111111',
	fw=>'firewall --disabled',
	slx=>'selinux --disabled'
	);
my $ks_auth="authconfig --enableshadow --enablemd5";
my $ks_timezone="timezone Asia/Shanghai";
my $ks_driverdisk="#driverdisk --source=http://$ks_ip/driver/linux/$ks_distro/scsi/product/xx.ko";
my %ks_bootloader=(
	mbr=>'zerombr',
	location=>'bootloader --location=mbr',
	order=>'--driveorder=sda',
	append=>' --append="rhgb console=ttyS0,38400 console=tty0"',
	ignore=>'#ignoredisk --drives=sdb,sdc,sdd,sde,sdf,sdg,sdh,sdi,sdj,sdk,sdl,sdm,sdn',
	use=>'#ignoredisk --only-use=sda'
	);
my %ks_part=(
	type=>'clearpart --all --initlabel',
	root=>"part / --fstype ext3 --size=$ks_size --ondisk=sda",
	swap=>'part swap --size=2048 --ondisk=sda'
	);
##part /boot --fstype ext3 --size=100 --ondisk=sda                                       |        );
#part pv.2 --size=0 --grow --ondisk=sda                                                 |my %ks_part=(
#volgroup VolGroup00 --pesize=32768 pv.2                                                |        type=>'clearpart --all --initlabel',
#logvol / --fstype ext4 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow          |        root=>"part / --fstype ext3 --size=$ks_size --ondisk=sda",
#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1000 --grow --maxs|        swap=>'part swap --size=2048 --ondisk=sda' ize=1984
my $ks_reboot="reboot";
my $ks_include="#%include ";
## @Everything (Server)
## -@Conflicts
my %ks_pkgs=(
cmd=>'%packages --ignoremissing',
grp=>'
@additional-devel
@admin-tools
@base
@base-x
@basic-desktop
@chinese-support
@cifs-file-server
@core
@debugging
@desktop-debugging
@desktop-platform
@desktop-platform-devel
@development
@development-libs
@development-tools
@dialup
@directory-client
@eclipse
@editors
@emacs
@fonts
@ftp-server
@general-desktop
@gnome-desktop
@gnome-software-development
@graphical-admin-tools
@graphical-internet
@graphics
@input-methods
@internet-browser
@java-development
@java-platform
@legacy-network-server
@legacy-software-development
@legacy-software-support
@legacy-x
@mysql
@network-file-system-client
@network-server
@nfs-file-server
@office
@performance
@perl-runtime
@printing
@remote-desktop-clients
@server-cfg
@server-platform
@server-platform-devel
@server-policy
@smb-server
@sound-and-video
@sql-server
@storage-client-iscsi
@storage-server
@system-admin-tools
@system-tools
@text-internet
@web-server
@x11
@x-software-development',
pkg=>'
abrt-gui
ant
certmonger
crypto-utils
desktop-file-utils
device-mapper-multipath
dhcp
e2fsprogs
genisoimage
gnutls-devel
grub
imake
iscsi-initiator-utils
jpackage-utils
junit
kernel
kernel-devel
kexec-tools
krb5-workstation
libbonobo-devel
libdrm-devel
libgcrypt-devel
libglade2-devel
libgnomeui-devel
libtool-ltdl
libXau-devel
libXinerama-devel
libXmu
libXrandr-devel
libxslt-devel
lsscsi
minicom
mtools
netpbm-progs
nscd
nss-pam-ldapd
oddjob
OpenIPMI-tools
pam_krb5
pam_ldap
pax
perl-DBD-SQLite
popt-devel
PyXML
rpmdevtools
rpmlint
sg3_utils
sgpio
startup-notification-devel
sysstat
wodim
xorg-x11-proto-devel
'
);
# $ ks_vnc
#repo --name=<repoid> [--baseurl=<url>| --mirrorlist=<url>]                             |my $ks_pre="\%pre";
#vnc [--host=<hostname>] [--port=<port>] [--password=<password>]
# services --disabled avahi-daemon,avahi-dnsconfd,bluetooth,conman,cpuspeed,cups,cups-config-daemon,firstboot,isdn,kudzu,sendmail,pcmcia,rhnsd,hidd,ip6tables,iptables,yum-updates grub --enabled ssh
my $ks_pre="\%pre";
my $ks_post="\%post
#!/bin/sh
wget http://$ks_ip/sysconfig/pre_run.sh
sh ./pre_run.sh";
############################
##### print  kickstart #####
############################
print "Content-Type:text/plain\n\n";

print "#$ks_pre\n";
print "#$ks_include\n";

print "$ks_inst_type[0]\n";
print "$ks_inst_type[1]\n";
print "$ks_src_type{'http'}\n";

print "$ks_lang{'lang'}\n";
#print "$ks_lang{'support'}\n";
print "$ks_lang{'kbd'}\n";

print "$ks_network{'dev'} $ks_network{'boot'} $ks_network{'hostname'}\n";
print "$ks_driverdisk\n";

print "$ks_sec{'rootpwd'}\n";
print "$ks_sec{'fw'}\n";
print "$ks_sec{'slx'}\n";
print "$ks_auth\n";
print "$ks_timezone\n";

print "$ks_bootloader{'mbr'}\n";
print "$ks_bootloader{'ignore'}\n";
print "$ks_bootloader{'use'}\n";
print "$ks_bootloader{'location'} $ks_bootloader{'order'} $ks_bootloader{'append'}\n";

print "$ks_part{'type'}\n";
print "$ks_part{'root'}\n";
print "$ks_part{'swap'}\n";

print "$ks_reboot\n";
print "$ks_pkgs{'cmd'}\n";
print "$ks_pkgs{'grp'}\n";
print "$ks_pkgs{'pkg'}\n";
print "$ks_post\n";