echo "eg: if your want to mount the disk fixed,please write to /etc/fstab,eg: /dev/sr0 /var/www/html/os/6x86_64 iso9660 defaults 0 0 "
;;
esac
#prepare ks file in /var/www/html/ksdir
echo "If your have put ks file in other hosts,your should input remote ,and input the remote file full path,and it will use scp cmd to copy the ks file directory to /var/www/html/ksdir"
echo "If you put dir in local host,input local,it will will cp cmd to copy the ks file directory to /var/www/html/ksdir"
echo "if you input any other,you should cp ksdir to /var/www/html/ksdir"
read -p "Do you want to copy remote ks dir( r (remote) or l (local) or any other input ): " ifcopy
mkdir -p /var/www/html/ksdir/
case $ifcopy in
r|remote)
read -p "input the remote ksdir directory(defaults:root@172.18.50.75:/var/www/html/ksdir/*): " ksdir
if [ -z ${ksdir:-} ];then
ksdir="root@172.18.50.75:/var/www/html/ksdir/*"
fi
read -p "input host user's password you have put: " passwd
expect -c "
spawn scp $ksdir /var/www/html/ksdir/
expect {
\"*assword\" {set timeout 300; send \"$passwd\r\"; }
\"yes/no\" { send \"yes\r\"; exp_continue; }
}
expect eof"
ls /var/www/html/ksdir | while read ksfile; do
sed -i "s@url --url=\"http://.*/os/@url --url=\"http://$ip/os/@g" /var/www/html/ksdir/$ksfile
done
;;
l|local )
read -p "Please input your local ks directory(eg:/root/ksdir/*): " ksdir
cp $ksdir /var/www/html/ksdir/
;;
*)
echo "your input is wrong,please manual copy ksdir to /var/www/html/ksdir/"
;;
esac
#config dhcp
echo "Now config dhcp server..."
read -p "Input your next-server ip(default is your host ip): " nextip
if [ -z ${nextip:-} ];then
nextip="$ip"
fi
echo nextip is "$nextip"
mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf."$time".bak
cat >/etc/dhcp/dhcpd.conf<<eof
option domain-name "sunny.com";
option domain-name-servers 192.168.32.61;
default-lease-time 86400;
max-lease-time 86400;
subnet 192.168.32.0 netmask 255.255.255.0 {
range 192.168.32.100 192.168.32.200;
option routers 192.168.32.1;
next-server $nextip;
filename "pxelinux.0";
}
log-facility local7;
eof
echo "As default,the dhcp server will alocate ip 192.168.32.100--192.168.32.200,dns server is 192.168.32.61,router is 192.168.32.1,if you want to change these config ,please run 'vim /etc/dhcp/dhcpd.conf' to change /etc/dhcp/dhcpd.conf"
echo "dhcp is complete config now"
#config tltp
echo "If you want to copy linux kernel file to /var/lib/tftpboot/{6i386,6x86_64,7}"
read -p "Please input m(means manual) or a (means auto): " copyfile
case $copyfile in
a)
mkdir -p /var/lib/tftpboot/{6i386,6x86_64,7}
cp /var/www/html/os/6i386/isolinux/{initrd.img,vmlinuz} /var/lib/tftpboot/6i386
cp /var/www/html/os/6x86_64/isolinux/{initrd.img,vmlinuz} /var/lib/tftpboot/6x86_64
cp /var/www/html/os/7/isolinux/{initrd.img,vmlinuz} /var/lib/tftpboot/7
;;
*)
echo "Your input is m or other things"
echo "you should do two things after the scripts"
echo "create directory under /var/lib/tftpboot/,such as mkdir /var/lib/tftpboot/6i386"