Created
September 24, 2018 06:28
-
-
Save gm3dmo/2ffb1b0ba9975f7f08e8285da69b56fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#set -x | |
# Name: build_centos_dvd.sh | |
# Purpose: Customize a Centos DVD | |
# Author: David Morris | |
shopt -s -o nounset | |
START_TIME=$(date +%s) | |
SOURCE_ISO=$1 | |
SOURCE_ISO_DIR=/export/iso | |
SOURCE_MOUNT_POINT=/mnt/temp_mount | |
DVD_TYPE="CentOS" | |
CUSTOMER="MOESTAVERN" | |
DATE=`/bin/date +'%Y-%m-%d %H:%M:%S'` | |
KICKSTART_DIR=/export/kickstart | |
KICKSTART_FILENAME=$2 | |
KICKSTART_FILE=${KICKSTART_DIR}/$2 | |
if [ ! -f ${SOURCE_ISO_DIR}/${SOURCE_ISO} ]; then | |
echo "Cannot find ISO file: ${SOURCE_ISO_DIR}/${SOURCE_ISO}" | |
exit 255 | |
fi | |
if [ ! -f ${KICKSTART_FILE} ]; then | |
echo "Cannot find KickStart file: ${KICKSTART_FILE}" | |
exit 255 | |
fi | |
EXPLODED_ISO_DIR=/media/LaCie/isobuild | |
RPMS_DIR=/export/extra_rpms | |
TARGET_ISO_DIR=/export/custom_iso | |
ISO_FILENAME=centos5-custom.iso | |
TARGET_ISO_FILE=${TARGET_ISO_DIR}/${ISO_FILENAME} | |
TITLE="CUSTOM" | |
#echo "# ------------------------------------------------ #" | |
#echo "# Extracting Source ISO #" | |
#echo "# ------------------------------------------------ #" | |
#sudo mount -o loop ${SOURCE_ISO_DIR}/${SOURCE_ISO} ${SOURCE_MOUNT_POINT} | |
#rsync -arv ${SOURCE_MOUNT_POINT} ${EXPLODED_ISO_DIR} | |
echo "# ------------------------------------------------ #" | |
echo "# Inserting Custom Kickstart #" | |
echo "# ------------------------------------------------ #" | |
chmod 664 ${EXPLODED_ISO_DIR}/isolinux/isolinux.bin | |
chmod 764 ${EXPLODED_ISO_DIR}/isolinux/isolinux.cfg | |
ls -l ${EXPLODED_ISO_DIR}/isolinux | |
echo "Insert ${KICKSTART_FILE} file into iso image:" | |
cat ${KICKSTART_FILE} | |
cp ${KICKSTART_FILE} ${EXPLODED_ISO_DIR}/ks.cfg | |
echo "DO PERL" | |
perl -i -p -e 's{^default$}{default ks}; s{^(F5 rescue.msg)$}{$1\nF6 build.msg};' ${EXPLODED_ISO_DIR}/isolinux/isolinux.cfg | |
cat >> ${EXPLODED_ISO_DIR}/isolinux/isolinux.cfg <<EOF | |
label ks | |
kernel vmlinuz | |
append ks=cdrom:/ks.cfg initrd=initrd.img | |
EOF | |
echo "TEST BUILD" > ${EXPLODED_ISO_DIR}/isolinux/build.msg | |
echo "# ------------------------------------------------ #" | |
echo "# Inserting Custom Splash #" | |
echo "# ------------------------------------------------ #" | |
SPLASH_DIR=/export/custom_splash | |
if [ ! -z ${CUSTOMER} ]; then | |
echo "Embedding build info in gif" | |
#convert -font Courier -pointsize 22 -fill red -annotate +200+200 \ | |
# "Linux: ${DVD_TYPE}\nBuild Date: ${DATE}\n" \ | |
# ${SPLASH_DIR}/${CUSTOMER}_original.gif ${SPLASH_DIR}/${CUSTOMER}_splash.gif | |
echo "Converting gif to pmn" | |
giftopnm ${SPLASH_DIR}/${CUSTOMER}_splash.gif > ${SPLASH_DIR}/${CUSTOMER}_splash.ppm | |
echo "Converting pnm to lss" | |
ppmtolss16 < ${SPLASH_DIR}/${CUSTOMER}_splash.ppm > ${SPLASH_DIR}/${CUSTOMER}_splash.lss | |
cp ${SPLASH_DIR}/${CUSTOMER}_splash.lss ${EXPLODED_ISO_DIR}/isolinux/splash.lss | |
fi | |
echo "# ------------------------------------------------ #" | |
echo "# Inserting Custom RPM's # " | |
echo "# ------------------------------------------------ #" | |
cp ${RPMS_DIR}/*.rpm ${EXPLODED_ISO_DIR}/${DVD_TYPE} | |
cd ${EXPLODED_ISO_DIR} | |
createrepo -g repodata/comps.xml ${EXPLODED_ISO_DIR} | |
echo "# ------------------------------------------------ #" | |
echo "# Mastering ISO #" | |
echo "# ------------------------------------------------ #" | |
mkisofs -o ${TARGET_ISO_FILE} -b isolinux/isolinux.bin \ | |
-c isolinux/boot.cat \ | |
-no-emul-boot -boot-load-size 4 \ | |
-boot-info-table -R -m TRANS.TBL . | |
END_TIME=$(date +%s) | |
DURATION=((END_TIME-START_TIME)) | |
print "Job Completed in ${DURATION} seconds" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment