Blob Blame History Raw
#!/bin/bash

#################################################################################
# 
# Name :  CentOS Live Media [CD,DVD] build script 
# Function : Builds Live CD and DVD media
# How to call it : see usage()
# Author : Fabian Arrotin (arrfab@centos.org)
#          Karanbir Singh (kbsingh@centos.org)
# Notes: its possible to build both i386 and x86_64 media on the same vm
#
#################################################################################

usage() {

cat <<  EOF

You need to call the script like this : $0 -arguments

  -a : define the arch (required, default:none, values : [i386,x86_64])   
  -p : define the full repo path including file:// or http:// (required, default:none)
  -m : define the media type (required, default:none, values : [cd,dvd])
  -r : release to build ( eg. 6.0 )
  -h : display this help

EOF

}

varcheck() {
if [ -z "$1" ] ; then
        usage
        exit 1
fi

}


while getopts “ha:p:m:r:” OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         a)
             arch=$OPTARG
             ;;
         m)
             media=$(echo $OPTARG|tr [:lower:] [:upper:])
             ;;
         p)
             repopath=$OPTARG
             ;;
         r)
             release=$OPTARG
             ;;
         ?)
             usage
             exit
             ;;
     esac
done

varcheck $arch
varcheck $media
varcheck $repopath
varcheck $release

if [ `id -u` -ne "0" ]; then
	echo "you must call this script as root or with proper sudo permissions !"
	exit 1
fi

# Checking that we have the proper build tools installed
for package in livecd-tools python-imgcreate;
do
	rpm -q $package >/dev/null 2>&1 
	if [ $? -ne 0 ];then
		echo "Package $package not installed and needed for the $0 script to run !"
		exit 1
	fi
done

cd `dirname $0`

# checking selinux state on the machine, needed to go to Permissive for the livecd-tool to work
isSelinuxOn=`/usr/sbin/getenforce`
if [ "$isSelinuxOn" = "Enforcing" ] ;then
	/usr/sbin/setenforce 0
fi

/bin/cp $(dirname $0)/ks/centos6-live${media}-desktop.cfg /tmp/
sed -i s#REPOPATH#$repopath#g /tmp/centos6-live${media}-desktop.cfg
setarch $arch livecd-creator -c /tmp/centos6-live${media}-desktop.cfg -f "CentOS-${release}-${arch}-Live${media}" 

if [ "$isSelinuxOn" = "Enforcing" ] ;then
        /usr/sbin/setenforce 1
fi