From 39601c720701528a19c25d539565014a294caab2 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 6 Jun 2017 17:33:02 +0200 Subject: [PATCH] Erstellen der Squashfs-Datei. --- bin/create-grml-image.sh | 71 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/bin/create-grml-image.sh b/bin/create-grml-image.sh index 82ba73d..34350fd 100755 --- a/bin/create-grml-image.sh +++ b/bin/create-grml-image.sh @@ -32,8 +32,8 @@ HAS_TTY='y' BASENAME="$(basename ${0})" BIN_DIR="$(dirname ${0})" BASE_DIR=$( readlink -f "${BIN_DIR}/.." ) -ROOT_DIR="${BASE_DIR}/image" -CDROM_ROOT_DIR="${ROOT_DIR}/cdrom" +IMAGE_DIR="${BASE_DIR}/image" +CDROM_ROOT_DIR="${IMAGE_DIR}/cdrom" TGT_DIR="${BASE_DIR}/target" GRML2USB="${BASE_DIR}/grml2usb/grml2usb" @@ -188,7 +188,7 @@ MKDIR() { #------------------------------------------------------------------------------ CHROOT() { - chroot "${ROOT_DIR}" "$@" + chroot "${TGT_DIR}" "$@" } #------------------------------------------------------------------------------ @@ -197,7 +197,7 @@ description() { Dieses Script generiert ein individuell angepaßtes GRML-ISO-Image, in welchem weitere nützliche Software-Pakete enthalten sind. Nach erfolgreicher Generierung befindet sich das ISO-Image - unter '${TGT_DIR}'. + unter '${IMAGE_DIR}'. EOF ) @@ -373,6 +373,27 @@ unpack_orig() { debug "Unsquashing beendet." } +#------------------------------------------------------------------------------ +mangle_resolv_conf() { + empty_line + info "Erstelle neue ${TGT_DIR}/etc/resolv.conf ..." + if [[ -e "${TGT_DIR}/etc/resolv.conf" || -L "${TGT_DIR}/etc/resolv.conf" ]] ; then + MV "${TGT_DIR}/etc/resolv.conf" "${TGT_DIR}/etc/resolv.conf.bak" + fi + CP -p /etc/resolv.conf "${TGT_DIR}/etc/resolv.conf" + +} + +#------------------------------------------------------------------------------ +unmangle_resolv_conf() { + empty_line + info "Stelle ursprüngliche ${TGT_DIR}/etc/resolv.conf wieder her ..." + RM "${TGT_DIR}/etc/resolv.conf" + if [[ -f "${TGT_DIR}/etc/resolv.conf.bak" || -L "${TGT_DIR}/etc/resolv.conf.bak" ]] ; then + MV "${TGT_DIR}/etc/resolv.conf.bak" "${TGT_DIR}/etc/resolv.conf" + fi +} + #------------------------------------------------------------------------------ init_grml2usb() { @@ -393,13 +414,48 @@ init_grml2usb() { debug "Ausführen:\n${cmd}" eval ${cmd} + local tgt_dir="${CDROM_ROOT_DIR}/live/grml64-full" + local tgt_file="${tgt_dir}/grml64-full.squashfs" + + if [[ ! -d "${tgt_dir}" ]] ; then + error "Verzeichnis '${RED}${tgt_dir}${NORMAL}' nicht gefunden." + exit 4 + fi + + if [[ ! -f "${tgt_file}" ]] ; then + error "Datei '${RED}${tgt_file}${NORMAL}' nicht gefunden." + exit 4 + fi + +} + +#------------------------------------------------------------------------------ +create_squashfs() { + + local tgt_dir="${CDROM_ROOT_DIR}/live/grml64-full" + local tgt_file="${tgt_dir}/grml64-full.squashfs" + + if [[ -f "${tgt_file}" ]] ; then + empty_line + debug "Lösche originale '${tgt_file}' ..." + RM "${tgt_file}" + fi + + empty_line + info "Erstelle SquashFS Datei '${GREEN}${tgt_file}${NORMAL}' ..." + local np="" + if [[ "${VERBOSE}" != "y" ]] ; then + np="-no-progress" + fi + mksquashfs "${TGT_DIR}" "${tgt_file}" -comp xz ${np} + } #------------------------------------------------------------------------------ make_isofs() { empty_line - local iso_file="${ROOT_DIR}/grml64.$( date +'%Y-%m-%d_%H-%M-%S' ).iso" + local iso_file="${IMAGE_DIR}/grml64.$( date +'%Y-%m-%d_%H-%M-%S' ).iso" cd "${CDROM_ROOT_DIR}" info "Bereite mkisofs vor ,,," @@ -466,7 +522,12 @@ main() { unmount_src_image destroy_src_img_dev + mangle_resolv_conf + + + unmangle_resolv_conf init_grml2usb + create_squashfs make_isofs empty_line -- 2.39.5