The last article just completed the automatic installation of Nagios, this article continues, think of the previous days manually configured kickstart server process is more cumbersome, the idea is not clear, or the installation configuration process to write into the script is very convenient, feeling is once and for all, reduce the follow-up work of the Labor, And the whole idea process is clearer.
Experimental environment: centos6.3 x86_64
Firewall closed, SELinux set to Disabled
Note: The virtual machine needs to first load the centos6.3 x86_64 installation image ISO
The MAC address in the script needs to be changed to the MAC address of your current machine
Ks.cfg configuration file about setting the client password needs to be set yourself
You can start the installation configuration kickstart by executing the script directly.
This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/zs/
#!/bin/bash #auto Install Kickstart server lang=c mkdir/tftpboot mkdir/tftpboot/pxelinux.cfg mkdir/mnt/iso Mount-o Loop/dev/dvd/mnt/iso function Init_pack () {yum-y Install DHCP httpd xinetd tftp tftp-server s Yslinux chkconfig httpd on Chkconfig dhcpd on chkconfig xinetd on service httpd start Servic E dhcpd start service xinetd start} function set_tftp () {cp/etc/xinetd.d/tftp/etc/xin Etd.d/tftp.bak Echo ' service tftp {disable = no Socket_type = DG RAM protocol = UDP Wait = Yes user =
Root server =/usr/sbin/in.tftpd Server_args =-U nobody-s/tftpboot Per_source = one CPS = 2 flags = IP V4} ' >/etc/xinetd. d/tftp #need to format the text} function Set_eth () {echo ' device= ' eth0 ' Bootpro to= "Static" Ipaddr= "192.168.10.1" netmask= "255.255.255.0" gateway= "192.168.10.1" hwaddr= f:46 "nm_controlled=" yes "onboot=" yes ">/etc/sysconfig/network-scripts/ifcfg-eth0 #need to format
The text sed-i ' s/^ *//g '/etc/sysconfig/network-scripts/ifcfg-eth0 ifdown eth0;ifup eth0} function Set_dhcp () {sed-i ' 1, $s/^/#/g '/etc/dhcp/dhcpd.conf echo ' subnet 192.168.10.0 the netmask
55.0 {option routers 192.168.10.1;
Option Subnet-mask 255.255.255.0;
Range 192.168.10.10 192.168.10.50;
Next-server 192.168.10.1;
Default-lease-time 600;
Max-lease-time 7200;
FileName "pxelinux.0";
Allow booting;
Allow BOOTP; } ' >>/etc/dhcp/dhcpd.conf #need to format the text sed-i ' s/^ *//g '/etc/dhcp/dhcpd.conf #remove the blanks at beginning service dhcpd restart} function Cp_files () {cp-rv/mnt /iso/*/var/www/html cp-v/mnt/iso/isolinux/initrd.img/tftpboot cp-v/mnt/iso/isolinux/isolinux.cfg/tftpbo Ot/pxelinux.cfg/default cp-v/mnt/iso/isolinux/vmlinuz/tftpboot cp-v/mnt/iso/isolinux/vesamenu.c32/tftpbo OT/VESAMENU.C32 cp-v/usr/share/syslinux/pxelinux.0/tftpboot chmod +x/tftpboot/pxelinux.cfg/default C Hcon-u system_u-t tftpdir_t/tftpboot-r #modify The SELinux context type Chcon--reference=/var/www/html/ Var/www/html-r} function Set_kscfg () {echo ' #platform =x86, AMD64, or Intel em64t #version =de VEL # Firewall configuration Firewall--disabled # Install OS instead of upgrade Install # U SE network installation URL--url= "HTTP://192.168.10.1/" # Root password rootpw--iscrypted $1$xhujuwps$ Cze5avunerhrbqyz8yamy1#密码自己设定, available plaintext can also be encrypted # System authorization Information auth--useshadow--passalgo=sha512 # Use graphical
Install graphical firstboot--disable # system keyboard keyboard US # system language Lang en_US # SELinux configuration SELinux--permissive # does not configure the X Window System Ski PX # Installation Logging level Logging--level=info # Reboot after installation Reboot # Sy Stem timezone timezone--ISUTC asia/chongqing # Network Information Network--BOOTPROTO=DHCP--device=e Th0--onboot=on # System bootloader configuration bootloader--location=mbr # Partition Clearing Informa
tion Clearpart--all--initlabel # Disk Partitioning information part/boot--fstype= ' Ext4 '--size=200 Part/--fstype= "EXT4"--size=6000 part swap--fstype= "swap"--size=512 part/home--fstype= "Ext4"--size =1024%packaGES @additional-devel @development%end ' >/var/www/html/ks.cfg sed-i ' s/^ *//g '/VAR/WW W/html/ks.cfg chmod 755/var/www/html/ks.cfg Chcon--reference=/var/www/html/var/www/html/ks.cfg} function
Set_default () {echo ' default VESAMENU.C32 #prompt 1 timeout display boot.msg
Menu background splash.jpg menu title Welcome to CentOS 6.3! Menu Color Border 0 #ffffffff #00000000 menu Color sel 7 #ffffffff #ff000000 Menu color title 0 #ffffffff #000 00000 Menu Color tabmsg 0 #ffffffff #00000000 menu color Unsel 0 #ffffffff #00000000 menu Color Hotsel 0
#ff000000 #ffffffff Menu Color Hotkey 7 #ffffffff #ff000000 menu color scrollbar 0 #ffffffff #00000000
Label Linux menu label ^install or upgrade an existing system menu default kernel Vmlinuz Append initrd=initrd.img ks=http://192.168.10.1/ks.cfg LabeL VESA Menu Label Install system with ^basic video driver kernel vmlinuz append initrd=initrd.img Xdriver=vesa nomodeset label Rescue Menu label ^rescue installed system kernel Vmlinuz Appen D initrd=initrd.img Rescue label local menu label Boot from ^local Drive Localboot 0xFFFF Labe
L memtest86 Menu label ^memory Test kernel memtest append-' >/tftpboot/pxelinux.cfg/default
Sed-i ' s/^ *//g '/tftpboot/pxelinux.cfg/default chcon-u system_u-t Tftpdir_t/tftpboot/pxelinux.cfg/default} Init_pack if [$ (rpm-q tftp)-A $ (rpm-q DHCP)-A $ (rpm-q httpd)-A $ (rpm-q syslinux)]; Then #check if these services have been installed set_tftp Set_eth set_dhcp cp_files FG Set_default Else echo "installed incompleted." Fi
This article is from the "Strive for" blog, please be sure to keep this source http://carllai.blog.51cto.com/1664997/1060719