Chinaunix首页 | 论坛 | 博客
  • 博客访问: 221221
  • 博文数量: 71
  • 博客积分: 1649
  • 博客等级: 上尉
  • 技术积分: 725
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-25 11:20
文章分类

全部博文(71)

文章存档

2012年(1)

2011年(11)

2010年(59)

我的朋友

分类: LINUX

2010-02-25 11:58:16

#!/bin/bash

# Make a Customed Linux from the current OS.

 

awk '/^Installing/{print $2}' /root/install.log | sed 's/^[0-9]*://g' > /tmp/packlist.txt

 

FILE='/tmp/packlist.txt'

DDIR='/root/iso'

SDIR='/media/cdrom'

let COUNT=0

 

[ -e $DDIR ] && mv $DDIR $DDIR.old && mkdir -p $DDIR/{Server,VT,Cluster,ClusterStorage} 2>>/tmp/error.txt || mkdir -p $DDIR/{Server,VT,Cluster,ClusterStorage} 2>>/tmp/error.txt

 

echo -e "Starting to copy the packages..."

while read LINE

do

  for I in Server VT Cluster ClusterStorage

  do

    if cp -r $SDIR/$I/$LINE.rpm $DDIR/$I/$LINE.rpm 2>>/tmp/cperr.txt ; then

      COUNT=$[ $COUNT+1 ]

      echo -e "${COUNT}. \033[32m${LINE}\033[0m copyed successfully..."

      break

    else

      continue

    fi

  done

done < $FILE

echo -e "Total \033[31m${COUNT}\033[0m packages was coped..."

 

cp -r $SDIR/{images,isolinux,.treeinfo,.discinfo,EULA,GPL,TRANS.TBL,eula.en_US} $DDIR

 

[ -e /usr/bin/createrepo ] || rpm -i $SDIR/Server/createrepo-*.noarch.rpm &> /dev/null

 

#cre_repo() {

#  case REPO in

#  'Server')

#    createrepo -g $SDIR/$1/repodata/comps-rhel5-server-core.xml $DDIR/$I

#    ;;

#  'VT')

#    createrepo -g $SDIR/$1/repodata/comps-rhel5-vt.xml $DDIR/$I

#    ;;

#  'Cluster')

#    createrepo -g $SDIR/$1/repodata/comps-rhel5-cluster.xml $DDIR/$I

#    ;;

#  'ClusterStorage')

#    createrepo -g $SDIR/$1/repodata/comps-rhel5-cluster-st.xml $DDIR/$I

#    ;;

#esac

#}

 

echo -e "\nStarting to create repodata..."

for REPODIR in Server VT Cluster ClusterStorage

do

  createrepo -g $SDIR/$REPODIR/repodata/comps-rhel5-*.xml $DDIR/$REPODIR

  echo -e "The repository of $REPODIR created successfully..."

done

 

find $DDIR/isolinux -name "*" -exec chmod u+w {} \;

 

echo "\nStarting to create ks.cfg..."

sed -i 's@^default linux@default linux ks=cdrom:/ks.cfg@g' $DDIR/isolinux/isolinux.cfg

 

if [ -e /root/anaconda-ks.cfg ]; then

  cp /root/anaconda-ks.cfg $DDIR/ks.cfg

  sed -i '/^# not g/,/^%packages/s/^#\([a-z].*\)/\1/g' $DDIR/ks.cfg

  sed -i -e 's/^install$/text/g' -e '/^%packages/i \reboot' $DDIR/ks.cfg

  sed -i -e 's/^url.*$/cdrom/g' -e 's/^nfs.*$/cdrom/g' $DDIR/ks.cfg

else

  echo -e "The \033[31mks.cfg\033[0m cannot create,Please create one ..."

  exit 1

fi

echo "ks.cfg file created successfully..."

 

if [ ! -e /usr/bin/mkisofs ]; then

  rpm -i $SDIR/Server/mkisofs-*.i386.rpm &> /dev/null

fi

 

echo -e "\nStarting to create the iso, please wait for a moment..."

cd /root

mkisofs -o MyCustom_Redhat.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T iso/

 

echo -e "\n\033[31mCongratulations, the Customed Linux created successfully, it's name is \033[32mMyCustom_Redhat.iso\033[0m ."

 

阅读(2693) | 评论(0) | 转发(0) |
0

上一篇:su&sudo

下一篇:用户和组的管理

给主人留下些什么吧!~~