|
Fabian Arrotin |
9e7827 |
#!/bin/bash
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
#################################################################################
|
|
Fabian Arrotin |
9e7827 |
#
|
|
Karanbir Singh |
15eccd |
# Name : CentOS Live Media [CD,DVD] build script
|
|
Karanbir Singh |
15eccd |
# Function : Builds Live CD and DVD media
|
|
Fabian Arrotin |
9e7827 |
# How to call it : see usage()
|
|
Fabian Arrotin |
9e7827 |
# Author : Fabian Arrotin (arrfab@centos.org)
|
|
Karanbir Singh |
15eccd |
# Karanbir Singh (kbsingh@centos.org)
|
|
Karanbir Singh |
15eccd |
# Notes: its possible to build both i386 and x86_64 media on the same vm
|
|
Fabian Arrotin |
9e7827 |
#
|
|
Fabian Arrotin |
9e7827 |
#################################################################################
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
usage() {
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
cat << EOF
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
You need to call the script like this : $0 -arguments
|
|
Fabian Arrotin |
9e7827 |
|
|
Karanbir Singh |
4e0ef8 |
-a : define the arch (required, default:none, values : [i386,x86_64])
|
|
|
ee99ce |
-p : define the full repo path including file:// or http:// (required, default:none)
|
|
Karanbir Singh |
4e0ef8 |
-m : define the media type (required, default:none, values : [cd,dvd])
|
|
Karanbir Singh |
4e0ef8 |
-r : release to build ( eg. 6.0 )
|
|
Karanbir Singh |
4e0ef8 |
-h : display this help
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
EOF
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
}
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
varcheck() {
|
|
Fabian Arrotin |
9e7827 |
if [ -z "$1" ] ; then
|
|
Fabian Arrotin |
9e7827 |
usage
|
|
Fabian Arrotin |
9e7827 |
exit 1
|
|
Fabian Arrotin |
9e7827 |
fi
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
}
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
|
|
|
bcd086 |
while getopts “ha:p:m:r:” OPTION
|
|
Fabian Arrotin |
9e7827 |
do
|
|
Fabian Arrotin |
9e7827 |
case $OPTION in
|
|
Fabian Arrotin |
9e7827 |
h)
|
|
Fabian Arrotin |
9e7827 |
usage
|
|
Fabian Arrotin |
9e7827 |
exit 1
|
|
Fabian Arrotin |
9e7827 |
;;
|
|
Fabian Arrotin |
9e7827 |
a)
|
|
Fabian Arrotin |
9e7827 |
arch=$OPTARG
|
|
Fabian Arrotin |
9e7827 |
;;
|
|
Fabian Arrotin |
9e7827 |
m)
|
|
Fabian Arrotin |
9e7827 |
media=$(echo $OPTARG|tr [:lower:] [:upper:])
|
|
Fabian Arrotin |
9e7827 |
;;
|
|
Fabian Arrotin |
9e7827 |
p)
|
|
Fabian Arrotin |
9e7827 |
repopath=$OPTARG
|
|
Fabian Arrotin |
9e7827 |
;;
|
|
Karanbir Singh |
4e0ef8 |
r)
|
|
Karanbir Singh |
4e0ef8 |
release=$OPTARG
|
|
Karanbir Singh |
4e0ef8 |
;;
|
|
Fabian Arrotin |
9e7827 |
?)
|
|
Fabian Arrotin |
9e7827 |
usage
|
|
Fabian Arrotin |
9e7827 |
exit
|
|
Fabian Arrotin |
9e7827 |
;;
|
|
Fabian Arrotin |
9e7827 |
esac
|
|
Fabian Arrotin |
9e7827 |
done
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
varcheck $arch
|
|
Fabian Arrotin |
9e7827 |
varcheck $media
|
|
Fabian Arrotin |
9e7827 |
varcheck $repopath
|
|
|
bcd086 |
varcheck $release
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
if [ `id -u` -ne "0" ]; then
|
|
Fabian Arrotin |
9e7827 |
echo "you must call this script as root or with proper sudo permissions !"
|
|
Fabian Arrotin |
9e7827 |
exit 1
|
|
Fabian Arrotin |
9e7827 |
fi
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
# Checking that we have the proper build tools installed
|
|
Fabian Arrotin |
9e7827 |
for package in livecd-tools python-imgcreate;
|
|
Fabian Arrotin |
9e7827 |
do
|
|
Fabian Arrotin |
9e7827 |
rpm -q $package >/dev/null 2>&1
|
|
Fabian Arrotin |
9e7827 |
if [ $? -ne 0 ];then
|
|
Fabian Arrotin |
9e7827 |
echo "Package $package not installed and needed for the $0 script to run !"
|
|
Fabian Arrotin |
9e7827 |
exit 1
|
|
Fabian Arrotin |
9e7827 |
fi
|
|
Fabian Arrotin |
9e7827 |
done
|
|
Fabian Arrotin |
9e7827 |
|
|
Fabian Arrotin |
9e7827 |
cd `dirname $0`
|
|
|
4e8f16 |
|
|
|
4e8f16 |
# checking selinux state on the machine, needed to go to Permissive for the livecd-tool to work
|
|
|
4e8f16 |
isSelinuxOn=`/usr/sbin/getenforce`
|
|
|
4e8f16 |
if [ "$isSelinuxOn" = "Enforcing" ] ;then
|
|
|
4e8f16 |
/usr/sbin/setenforce 0
|
|
|
4e8f16 |
fi
|
|
|
4e8f16 |
|
|
|
bcd086 |
/bin/cp $(dirname $0)/ks/centos6-live${media}-desktop.cfg /tmp/
|
|
Fabian Arrotin |
9e7827 |
sed -i s#REPOPATH#$repopath#g /tmp/centos6-live${media}-desktop.cfg
|
|
Karanbir Singh |
4e0ef8 |
setarch $arch livecd-creator -c /tmp/centos6-live${media}-desktop.cfg -f "CentOS-${release}-${arch}-Live${media}"
|
|
|
4e8f16 |
|
|
|
4e8f16 |
if [ "$isSelinuxOn" = "Enforcing" ] ;then
|
|
|
4e8f16 |
/usr/sbin/setenforce 1
|
|
|
4e8f16 |
fi
|
|
|
4e8f16 |
|