2014-10-14 16:02:12 +00:00
|
|
|
#!/bin/bash
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Configurations
|
|
|
|
# ------------------------------------------------------------------------------
|
2015-02-10 15:07:44 +00:00
|
|
|
export IMG="${1}"
|
2014-07-28 16:53:49 +00:00
|
|
|
export LC_ALL=POSIX
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2011-09-25 20:41:27 +00:00
|
|
|
RETCODE=0
|
|
|
|
|
2011-09-24 09:58:14 +00:00
|
|
|
: ${DIST=fc14}
|
|
|
|
|
2015-02-10 15:07:44 +00:00
|
|
|
if [ "${VERBOSE}" -ge 2 -o "${DEBUG}" == "1" ]; then
|
2014-10-14 16:02:12 +00:00
|
|
|
set -x
|
|
|
|
else
|
|
|
|
set -e
|
|
|
|
fi
|
2013-02-16 20:06:11 +00:00
|
|
|
|
2015-03-10 03:19:28 +00:00
|
|
|
. ./builder_setup >/dev/null
|
|
|
|
. ./umount_kill.sh >/dev/null
|
|
|
|
|
2013-01-25 08:03:51 +00:00
|
|
|
if ! [ $# -eq 1 ]; then
|
2015-02-10 15:07:44 +00:00
|
|
|
echo "usage ${0} <img_file_name>"
|
2014-10-14 16:02:12 +00:00
|
|
|
exit
|
2010-06-18 23:41:29 +00:00
|
|
|
fi
|
|
|
|
|
2015-02-10 15:07:44 +00:00
|
|
|
if [ "${VERBOSE}" == "1" ]; then
|
|
|
|
export YUM_OPTS="${YUM_OPTS} -q"
|
2012-11-18 03:01:49 +00:00
|
|
|
fi
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
2015-02-10 15:07:44 +00:00
|
|
|
# Make sure INSTALLDIR exists
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
2014-11-06 01:11:07 +00:00
|
|
|
export INSTALLDIR="$(readlink -m mnt)"
|
2015-02-10 15:07:44 +00:00
|
|
|
mkdir -p "${INSTALLDIR}"
|
2014-10-14 16:02:12 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
2015-02-10 15:07:44 +00:00
|
|
|
# Prepare for mount
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
2015-02-10 15:07:44 +00:00
|
|
|
echo "-> Preparing instalation of ${DIST} template..."
|
|
|
|
"${SCRIPTSDIR}/00_prepare.sh"
|
2014-10-14 20:30:12 +00:00
|
|
|
|
2015-02-10 15:07:44 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Mount image and install core OS
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
if [ -f "${IMG}" ]; then
|
2014-10-14 16:02:12 +00:00
|
|
|
echo "-> Image file already exists, assuming *update*..."
|
2010-06-18 23:41:29 +00:00
|
|
|
else
|
2014-10-14 16:02:12 +00:00
|
|
|
echo "-> Initializing empty image..."
|
2015-02-10 15:07:44 +00:00
|
|
|
truncate -s 10G "${IMG}" || exit 1
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
echo "-> Creating filesystem..."
|
2015-02-10 15:07:44 +00:00
|
|
|
mkfs.ext4 -q -F "${IMG}" || exit 1
|
2010-06-18 23:41:29 +00:00
|
|
|
fi
|
|
|
|
|
2015-02-10 15:07:44 +00:00
|
|
|
mount -o loop "${IMG}" "${INSTALLDIR}" || exit 1
|
|
|
|
trap "umount_kill $(readlink -m ${INSTALLDIR})" EXIT
|
|
|
|
"${SCRIPTSDIR}/01_install_core.sh"
|
2014-10-14 20:30:12 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Install package groups
|
|
|
|
# ------------------------------------------------------------------------------
|
2010-06-18 23:41:29 +00:00
|
|
|
echo "-> Installing package groups..."
|
2015-02-10 15:07:44 +00:00
|
|
|
"${SCRIPTSDIR}/02_install_groups.sh"
|
2010-06-18 23:41:29 +00:00
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Cleanup
|
|
|
|
# ------------------------------------------------------------------------------
|
2014-05-13 02:30:01 +00:00
|
|
|
trap - EXIT
|
2014-10-14 16:02:12 +00:00
|
|
|
|
2013-02-16 20:18:20 +00:00
|
|
|
echo "-> Unmounting prepared_image..."
|
2015-02-10 15:07:44 +00:00
|
|
|
umount_kill "$(readlink -m ${INSTALLDIR})" || true
|
2011-09-25 20:41:27 +00:00
|
|
|
|
2015-02-10 15:07:44 +00:00
|
|
|
exit ${RETCODE}
|