Commit 130bbe48 authored by sulzbach's avatar sulzbach

WIP: SCRUM#601

parent 6df32bda
chroot
overlay
kernel
*.swp
iso/**/*.iso
src/preseed/.preseed.bkp
initrd
cache/*
iso/*
initrd/*
initrd.lz
chroot*.tar.gz
packages-needed
base
todos.txt
vmlinuz-*-generic
initrd.img-*-generic
.Trash-1000
\ No newline at end of file
......@@ -18,5 +18,6 @@ echo -e "$files"| xargs shellcheck -s bash && \
echo "AWESOME! No problems found." ; \
exit 0
#else
echo -e "Understand errors in: ${BLUE}https://github.com/koalaman/shellcheck/wiki${NC}"
echo -e "Understand errors in: \
${BLUE}https://github.com/koalaman/shellcheck/wiki${NC}"
exit 1
{
// sulzbach:
"editor.rulers": [80],
"editor.fontSize": 16
}
\ No newline at end of file
#!/bin/bash
# shellcheck disable=SC1090
#
# Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of create-iso
#
# create-iso is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
initChroot() {
local chrootdir="${1}"
local chrootdir="$1"
# Create the log file; this file will be bind to appear in "${VARLOG}"
# directory in the target machine that generates the iso.
......@@ -16,7 +36,7 @@ initChroot() {
mount --bind "${LOG_FILE}" "${chrootdir}/${LOG_FILE}"
mount --bind "/etc/resolv.conf" "${chrootdir}/etc/resolv.conf"
mount --bind --options ro "/etc/resolv.conf" "${chrootdir}/etc/resolv.conf"
# Prevent services from being started in the chrooted environment
rm -rf "${chrootdir:?}/fakebin"
......@@ -31,7 +51,7 @@ initChroot() {
}
closeChroot() {
local chrootdir="${1}"
local chrootdir="$1"
umount --lazy "${chrootdir}/etc/resolv.conf"
umount --lazy "${chrootdir}/${LOG_FILE}"
......@@ -39,7 +59,7 @@ closeChroot() {
}
function create_stub() {
local script="${1}"
local script="$1"
cat << EOF > "${script}"
#!/usr/bin/env bash
......@@ -53,31 +73,28 @@ EOF
}
addToChrootFile() {
local chrootdir="${1}"
local script_name="${2}"
local cmd="${3}"
local chrootdir="$1"
local cmd="${2}"
if [ ! -f "${chrootdir}/tmp/${script_name}" ]; then
create_stub "${chrootdir}/tmp/${script_name}"
if [ ! -f "${chrootdir}/tmp/exec.sh" ]; then
create_stub "${chrootdir}/tmp/exec.sh"
fi
echo "${cmd}" >> "${chrootdir}/tmp/${script_name}"
echo "${cmd}" >> "${chrootdir}/tmp/exec.sh"
}
execChroot() {
local chrootdir="${1}"
local script_name="${2}"
local chrootdir="$1"
[ ! -x "${chrootdir}/tmp/${script_name}" ] && chmod +x "${chrootdir}/tmp/${script_name}"
chroot "${chrootdir}" "/tmp/${script_name}"
rm --recursive --force "${chrootdir}/tmp/${script_name:?}" &>/dev/null
[ ! -x "${chrootdir}/tmp/exec.sh" ] && chmod +x "${chrootdir}/tmp/exec.sh"
chroot "${chrootdir}" "/tmp/exec.sh"
rm --recursive --force "${chrootdir:?}/tmp/exec.sh" &>/dev/null
return $?
}
function cleanup() {
local chrootdir="${1}"
local tmp="${2}"
local chrootdir="$1"
if mountpoint --quiet "${chrootdir}/etc/resolv.conf"; then
umount --lazy "${chrootdir}/etc/resolv.conf"
......@@ -97,5 +114,4 @@ function cleanup() {
if mountpoint --quiet "${chrootdir}/proc"; then
umount --lazy "${chrootdir}/proc"
fi
rm --recursive --force "${tmp:?}"
}
TMPFS="${PREFIX}/tmp"
TMPFS_SIZE="6291456k"
TMP="${TMPFS}/${_PROF}"
CHROOTDIR="${PREFIX}/overlay"
SCRIPTSDIR="${PREFIX}/scripts-enabled/${_PROF}"
ISODIR="${PREFIX}/iso"
CACHEDIR="${PREFIX}/cache/${_PROF}/${_REPO}"
PKGLIST="${PREFIX}/pkg-list/${_PROF}"
SOURCESLIST="${PREFIX}/sources-list"
LOG_PATH="/var/log"
NAME="Linux Comunicacoes"
WEBSITE="https://cidadesdigitais.c3sl.ufpr.br/linux-comunicacoes/"
ISOURL="http://cdimage.ubuntu.com/ubuntu-gnome/releases/16.04/release"
KEYURL="http://repo.c3sl.ufpr.br/lc2/lc.c3sl.ufpr.br.key"
NAME="Linux Educacional"
WEBSITE="https://linuxeducacional.c3sl.ufpr.br"
ISOURL="http://cdimage.ubuntu.com/ubuntu-gnome/releases/16.04/release"
KEYURL="http://repo.c3sl.ufpr.br/le6/le.c3sl.ufpr.br.key"
SHORTNAME=le6
TMP=${PREFIX}/${_DIST}
CHROOTDIR=${PREFIX}/overlay
TMPFS=${PREFIX}/tmp
DISTRO=Linux_Educacional_6.1.0
DPLIST=${PREFIX}/pkg-list/${_DIST}/dependencies.list
INSTLIST=${PREFIX}/pkg-list/${_DIST}/install.list
ISOLINUX=${PREFIX}/src/isolinux
MOUNTLIST=${TMP}/mountlist
OURSOURCESLIST=${PREFIX}/sources-list/${_DIST}/${SHORTNAME}.list
RMDSKT=${PREFIX}/pkg-list/${_DIST}/remove-desktop.list
RMLIST=${PREFIX}/pkg-list/${_DIST}/remove.list
REPOPKGS=${PREFIX}/pkg-list/${_DIST}/repo-local.list
SCRIPTSDIR=${PREFIX}/scripts-enabled/${_DIST}
SOURCESLISTDEFAULT=${PREFIX}/sources-list/${_DIST}/default.list
SCRIPT_NAME="exec.sh"
LOG_PATH="/var/log"
_HELP=false
_DIST=""
_ARCH="amd64"
_PROF=""
_INPUT=""
_OUTPUT=""
_REPO="stable"
_VERSION=""
_DEBUG=false
......@@ -22,128 +22,285 @@
# USA.
export PREFIX="${PWD}"
source "${PREFIX}/conf/pre.conf"
source "${PREFIX}/conf/opts.conf"
while true; do
case "${1}" in
-h | --help ) _HELP=true; shift ;;
-d | --distro ) _DIST="${2}"; shift; shift ;;
-a | --arch ) _ARCH="${2}"; shift; shift ;;
-r | --repo ) _REPO="${2}"; shift; shift ;;
-* ) echo "Unrecognized option. Try with --help."; exit 1 ;;
* ) break ;;
-h | --help ) _HELP=true; break ;;
-p | --profile ) _PROF="$2"; shift; shift ;;
-v | --version ) _VERSION="$2"; shift; shift ;;
-i | --input ) _INPUT="$2"; shift; shift ;;
-o | --output ) _OUTPUT="$2"; shift; shift ;;
-r | --repo ) _REPO="$2"; shift; shift ;;
-d | --debug ) _DEBUG=true; shift ;;
-* ) echo "Unrecognized option. Try with --help."; \
exit 1 ;;
* ) break ;;
esac
done
if [ "${_HELP}" = true ]; then
echo "Usage: ${0} [OPTION] [ARGUMENT]..."
echo ""
echo "Examples:"
echo " sudo ${0} --distro le6/testing # Generate default arch (amd64) le6 iso image"
echo " sudo ${0} -d le6/testing -a i386 # Generate i386 architecture le6 iso image"
echo ""
echo "Options:"
echo " -h, --help Show this help list"
echo " -d, --distro [DIST] Select iso image's distro"
echo " -a, --arch [amd64 | i386] Select iso image's architecture"
echo " -r, --repo [stable | testing | unstable] Select remote repository codename to download packages from"
exit 2
echo "Usage: $0 [OPTION] [ARGUMENT]..."
echo ""
echo "Examples:"
echo " sudo $0 --profile le6/testing # Generate le6 iso image"
echo ""
echo "Options:"
echo " -h, --help Show this help list"
echo -n " -p, --profile [PROF] Select profile to "
echo "load configurations and run enabled scripts from"
echo -n " -v, --version [VERSION] Select version of "
echo "the distro"
echo -n " -i, --input [PATH] Select ISO file "
echo "which contains the filesystem to be used as base"
echo -n " -o, --output [PATH] Select path to "
echo "output the created ISO image"
echo -n " -r, --repo [stable | testing | unstable] Select remote "
echo "repository codename to download packages from"
echo " -d, --debug Cache from last"
echo "execution"
exit 0
fi
if [ -z "${_DIST}" ]; then
echo "No distro specified. Try with --help."
exit 1
if [ "$(id -u)" != "0" ]; then
echo "You must have more power to run this script. Are you root?"
exit -1
fi
if [ "${_ARCH}" != "amd64" ] && [ "${_ARCH}" != "i386" ]; then
echo "Unrecognized architecture. Try with --help."
if [ -z "${_PROF}" ]; then
echo "No profile specified. Try with --help or --list-profiles."
exit 1
fi
if [ "${_REPO}" != "stable" ] && [ "${_REPO}" != "testing" ] && [ "${_REPO}" != "unstable" ]; then
echo "Unrecognized remote repository codename. Try with --help."
if ! source "${PREFIX}/conf/${_PROF}.conf"; then
echo "Unavailable profile. Try with --help or --list-profiles."
exit 1
fi
if [ "$(id -u)" != "0" ]; then
echo "You must have more power to run this script. Are you root?"
exit -1
source "${PREFIX}/conf/general.conf"
if [ -z "${_VERSION}" ]; then
echo "No version specified. Ommiting."
else
NAME="${NAME} ${_VERSION}"
fi
source "${PREFIX}/conf/${_DIST}/create-iso.conf"
if [ -z "${_OUTPUT}" ]; then
_OUTPUT="${ISODIR}/output"
fi
if [ "${_REPO}" != "stable" ] && [ "${_REPO}" != "testing" ] && \
[ "${_REPO}" != "unstable" ]; then
echo "Unrecognized remote repository codename. Try with --help."
exit 1
fi
TIME_STAMP="$(date +'%Y-%m-%dT%H:%M:%S')"
export LOG_FILE="${LOG_PATH}/create-iso-${TIME_STAMP}.log"
exec 1<&-
exec 2<&-
exec 1<> "${LOG_FILE}"
exec 1>&1
mkdir --parents "${TMP}"
source "${PREFIX}/common.sh"
source "${PREFIX}/helper/logging.incsh"
source "${PREFIX}/lib/mktmpfs.sh"
source "${PREFIX}/lib/overlay.sh"
# Disable debug logging if not in debug mode
# [ "${_DEBUG}" == false ] && let VERBOSE_FLAGS="${ALL} ^ ${DEBUG}"
# Installation of create-iso's dependencies
apt-get install isolinux syslinux squashfs-tools genisoimage xorriso --yes || \
createIsoLogger --message "Failed to install basic tools" --tag "apt-get"
mountTmpfs "${TMPFS}"
mountOverlay "${CHROOTDIR}" "${TMPFS}"
if [ -z "${_INPUT}" ]; then
NEWMD5="$(wget "${ISOURL}/MD5SUMS" -O- | grep "amd64" | sort \
--version-sort | tail --lines=1)"
ISONAME="$(cut --delimiter='*' --fields=2 <<< "${NEWMD5}")"
NEWMD5="$(cut --delimiter=' ' --fields=1 <<< "${NEWMD5}")"
OLDMD5="$(cat "${ISODIR}/input/MD5SUMS")"
if [ "${OLDMD5}" != "${NEWMD5}" ]; then
mkdir --parents "${ISODIR}/input"
pushd "${ISODIR}/input" || createIsoLogger --message \
"Unable to change directory" --tag "pushd"
wget "${ISOURL}/${ISONAME}" || createIsoLogger --message \
"Unable to download image" --tag "wget"
popd || createIsoLogger --message "Unable to change directory" --tag \
"popd"
echo "${NEWMD5}" > "${ISODIR}/input/MD5SUMS"
fi
mkdir --parents "${PREFIX}/isobase"
# Mount if it isn't already mounted
(mountpoint --quiet "${PREFIX}/isobase" || mount \
"${ISODIR}/input/${ISONAME}" "${PREFIX}/isobase" --types iso9660 --options \
ro,loop) || createIsoLogger --message "Unable to mount iso9660 fs" --tag \
"mount"
SQUASHFSPATH="${PREFIX}/isobase/casper/filesystem.squashfs"
else
mkdir --parents "${PREFIX}/isobase"
# Mount if it isn't already mounted
(mountpoint --quiet "${PREFIX}/isobase" || mount "${_INPUT}" \
"${PREFIX}/isobase" --types iso9660 --options ro,loop) || createIsoLogger \
--message "Unable to mount iso9660 fs" --tag "mount"
SQUASHFSPATH="${PREFIX}/isobase/casper/filesystem.squashfs"
fi
mkdir --parents "${TMPFS}"
# Mount if it isn't already mounted
(mountpoint --quiet "${TMPFS}" || mount tmpfs "${TMPFS}" --types tmpfs \
--options "suid,dev,size=${TMPFS_SIZE}") || createIsoLogger --message \
"Unable to mount tmpfs" --tag "mount"
mkdir --parents "${CACHEDIR}"
find="$(find "${CACHEDIR}" -mindepth 1 -maxdepth 1 -type d | sort --numeric)"
if [ -z "${find}" ]; then
# TODO: Mount iso in place
mkdir --parents "${TMP}/lower"
lowerdir="${TMP}/lower"
else
lowerdir="$(head --lines=1 <<< "${find}")"
find="$(grep --invert-match "${lowerdir}" <<< "${find}")"
lowerdir="$(sed 's/:/\\:/g' <<< "${lowerdir}")/image"
for dir in ${find}; do
lowerdir="$(sed 's/:/\\:/g' <<< "${dir}")/image:${lowerdir}"
done
fi
upperdir="${TMP}/upper"
workdir="${TMP}/work"
mkdir --parents "${upperdir}"
mkdir --parents "${workdir}"
mkdir --parents "${TMP}/image"
# Mount if it isn't already mounted
(mountpoint --quiet "${TMP}/image" || mount overlay "${TMP}/image" --types \
overlay --options \
rw,lowerdir="${lowerdir}",upperdir="${upperdir}",workdir="${workdir}") || \
createIsoLogger --message "Unable to mount overlay fs" --tag "mount"
# TODO: Fix this mess
[ "${lowerdir}" != "${TMP}/lower" ] && SQUASHFSPATH="${TMP}/image/casper/filesystem.squashfs"
mkdir --parents "${PREFIX}/squashfsbase"
# Mount if it isn't already mounted
(mountpoint --quiet "${PREFIX}/squashfsbase" || mount "${SQUASHFSPATH}" \
"${PREFIX}/squashfsbase" --types squashfs --options ro,loop) || \
createIsoLogger --message "Unable to mount squashfs" --tag "mount"
lowerdir="${PREFIX}/squashfsbase"
upperdir="${TMPFS}/upper"
workdir="${TMPFS}/work"
mkdir --parents "${upperdir}"
mkdir --parents "${workdir}"
mkdir --parents "${CHROOTDIR}"
# Mount if it isn't already mounted
(mountpoint --quiet "${CHROOTDIR}" || mount overlay "${CHROOTDIR}" --types \
overlay --options \
rw,lowerdir="${lowerdir}",upperdir="${upperdir}",workdir="${workdir}") || \
createIsoLogger --message "Unable to mount overlay fs" --tag "mount"
source "${PREFIX}/common.sh"
# TODO: Organize variables
# Each one of the available scripts is executed in numeric order
for script in "${SCRIPTSDIR}"/*; do
if [ -x "${script}" ] && grep -E --quiet '^[0-9]{2}-[A-Za-z]+' <<< "$(basename "${script}")"; then
createIsoLogger --message "Running $(basename "${script}")..." --type info
if [ -x "${script}" ] && grep -E --quiet '^[0-9]{2}-[A-Za-z]+' \
<<< "$(basename "${script}")"; then
createIsoLogger --message "Running $(basename "${script}")..." --type \
info
if ! "${script}"\
"${_DIST}" \
"${_ARCH}" \
"${_REPO}" \
"${_PROF}" \
"${NAME}" \
"${WEBSITE}" \
"${TMPFS}" \
"${TMP}" \
"${CHROOTDIR}" \
"${SCRIPT_NAME}" \
"${DISTRO}" \
"${DPLIST}" \
"${INSTLIST}" \
"${ISOLINUX}" \
"${MOUNTLIST}" \
"${OURSOURCESLIST}" \
"${RMDSKT}" \
"${RMLIST}" \
"${SCRIPTSDIR}" \
"${SHORTNAME}" \
"${SOURCESLISTDEFAULT}" \
"${TMP}" \
"${TMPFS}" \
"${REPOPKGS}" \
"${LOG_FILE}"; then
cleanup "${CHROOTDIR}" "${TMP}"
"${PKGLIST}" \
"${SOURCESLIST}" \
"${_REPO}" \
"${KEYURL}" \
"${CACHEDIR}"; then
cleanup "${CHROOTDIR}"
createIsoLogger --message "Failed to run script"
exit 1
fi
# If the script is marked as 'chroot', it means it performs changes in the overlayed chroot filesystem,
# therefore, the 'chroot script', filled with the required commands by the marked script, is executed
# If the script is marked as 'chroot', it means it performs changes in
# the overlaid chroot filesystem,
# therefore, the 'chroot script', filled with the required commands by
# the marked script, is executed
# This warning is disabled because the literal '-' is actually needed:
# shellcheck disable=SC1001
if [[ "$(basename "${script}")" =~ [0-9]+\-chroot\.* ]]; then
initChroot "${CHROOTDIR}" "${LOG_FILE}"
execChroot "${CHROOTDIR}" "${SCRIPT_NAME}"
# [[ "$(basename "${script}")" =~ [0-9]+\-chroot\.update-sourceslist\.sh ]] && createIsoLogger -m "Breakpoint" -t d
closeChroot "${CHROOTDIR}" "${LOG_FILE}"
fi
fi
done
# The name of the generated ISO is a concatenation of lowered-cased
# hyphen-delimited distribution version, repo codename and timestamp
ISONAME="$(sed -e 's/ /-/g' -e 's/\(.*\)/\L\1/g' \
<<< "${NAME}")-${_REPO}-${TIME_STAMP}.iso"
# Finally generates the resulting iso image
NAME="LinuxEducacional6-$(echo "${_DIST}" | cut --delimiter='/' --fields=2).iso"
pushd "${TMP}/image" || createIsoLogger --message "Unable to change directory" --tag "pushd"
xorriso -as mkisofs -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -c isolinux/boot.cat -b isolinux/isolinux.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -no-emul-boot -isohybrid-gpt-basdat \
-o "${PREFIX}/iso/${NAME}" . || createIsoLogger --message "Failed to generate iso image." --tag "xorriso"
mkdir --parents "${_OUTPUT}"
pushd "${TMP}/image" || createIsoLogger --message "Unable to change directory" \
--tag "pushd"
xorriso -as mkisofs -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -c \
isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 \
-boot-info-table -eltorito-alt-boot -no-emul-boot -isohybrid-gpt-basdat -o \
"${_OUTPUT}/${ISONAME}" . || createIsoLogger --message \
"Failed to generate iso image." --tag "xorriso"
popd || createIsoLogger --message "Unable to change directory" --tag "popd"
cleanup "${CHROOTDIR}" "${TMP}"
umountOverlay "${CHROOTDIR}" "${TMPFS}"
umountTmpfs "${TMPFS}"
cleanup "${CHROOTDIR}"
# Umount if it is mounted
(! mountpoint --quiet "${CHROOTDIR}" || umount "${CHROOTDIR}") || \
createIsoLogger --message "Unable to umount overlay fs" --tag "umount"
rm --recursive --force "${CHROOTDIR:?}" "${upperdir:?}" "${workdir:?}"
# Umount if it is mounted
(! mountpoint --quiet "${PREFIX}/squashfsbase" || umount \
"${PREFIX}/squashfsbase") || createIsoLogger --message \
"Unable to umount squashfs" --tag "umount"
rm --recursive --force "${PREFIX:?}/squashfsbase"
# Umount if it is mounted
(! mountpoint --quiet "${TMP}/image" || umount "${TMP}/image") || \
createIsoLogger --message "Unable to umount overlay fs" --tag "umount"
if [ "${_DEBUG}" == true ]; then
mkdir --parents "${CACHEDIR}/${TIME_STAMP}"
mv "${TMP}/MD5SUMS" "${CACHEDIR}/${TIME_STAMP}/" || createIsoLogger \
--message "Unable to move file" --tag "mv"
mv "${TMP}/upper" "${CACHEDIR}/${TIME_STAMP}/image" || createIsoLogger \
--message "Unable to move directory" --tag "mv"
fi
# Umount if it is mounted
(! mountpoint --quiet "${TMPFS}" || umount "${TMPFS}") || createIsoLogger \
--message "Unable to umount tmpfs" --tag "umount"
rm --recursive --force "${TMPFS:?}"
# Umount if it is mounted
(! mountpoint --quiet "${PREFIX}/isobase" || umount "${PREFIX}/isobase") || \
createIsoLogger --message "Unable to umount iso9660 fs" --tag "umount"
rm --recursive --force "${PREFIX:?}/isobase"
exit 0
#!/bin/bash
# shellcheck disable=SC1090
mount --bind /dev chroot/dev
mount --bind /dev/pts chroot/dev/pts
mount --bind /sys chroot/sys
mount --bind /proc chroot/proc
#chroot chroot dbus-uuidgen > chroot/var/lib/dbus/machine-id
chroot chroot
......@@ -7,30 +7,32 @@ readonly ALL=15
VERBOSE_FLAGS=${ALL}
mapType() {
case "${1}" in
case "$1" in
e | error ) echo "${ERROR}" ;;
w | warning ) echo "${WARNING}" ;;
i | info ) echo "${INFO}" ;;
d | debug ) echo "${DEBUG}" ;;
* ) createIsoLogger -m "Invalid type '${1}'" -T "LOGGER"; return 1 ;;
* ) createIsoLogger -m "Invalid type '$1'" -T "LOGGER"; return 1 ;;
esac
}
createIsoLogger() {
TYPE="${ERROR}"
TAG=""
MSG=""
SCRIPT="$(basename "${BASH_SOURCE[1]}")"
LINE="${BASH_LINENO[0]}"
while true; do
case "${1}" in
-t | --type ) TYPE="$(mapType "${2}")" || return; shift; shift ;;
-T | --tag ) TAG="${2}"; shift; shift ;;
-m | --message ) MSG="${2}"; shift; shift ;;
-s | --script ) SCRIPT="${2}"; shift; shift ;;
-l | --line ) LINE="${2}"; shift; shift ;;
-* ) createIsoLogger -m "Unrecognized option '${1}'" -T "LOGGER"; return ;;
-t | --type ) TYPE="$(mapType "$2")" || return; shift; shift ;;
-T | --tag ) TAG="$2"; shift; shift ;;
-m | --message ) MSG="$2"; shift; shift ;;
-s | --script ) SCRIPT="$2"; shift; shift ;;
-l | --line ) LINE="$2"; shift; shift ;;
-* ) createIsoLogger -m \
"Unrecognized option '$1'" -T "LOGGER"; return ;;
* ) break ;;
esac
done
......@@ -50,13 +52,12 @@ createIsoLogger() {
esac
echo -e "${LOG_LINE}" 1>&2
echo -e "${LOG_LINE}" >> "${LOG_FILE}"
if [ "${TYPE}" -eq "${ERROR}" ] || [ "${TYPE}" -eq "${DEBUG}" ]; then
/bin/bash
fi
else
createIsoLogger -m "Tried to use disabled type '${TYPE}'" -T "LOGGER"
return
fi
if [ "${TYPE}" -eq "${ERROR}" ]; then
/bin/bash
fi
}
......
#!/bin/bash
# shellcheck disable=SC1090
#
# Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of create-iso
#
# create-iso is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
mountTmpfs() {
local tmpfs="${1}"
if mountpoint --quiet "${tmpfs}"; then
return 1
fi
mkdir --parents "${tmpfs}"
if [ ! -d "${tmpfs}" ]; then
echo "overlay path: '${tmpfs}' has not been found."
exit 1
fi
mount --types tmpfs tmpfs --options suid,dev,size=6291456k "${tmpfs}"
}
umountTmpfs() {
local tmpfs="${1}"
if mountpoint --quiet "${tmpfs}"; then
umount "${tmpfs}"
fi
rm --recursive --force "${tmpfs:?}"
}
#!/bin/bash
# shellcheck disable=SC1090
#
# Copyright (C) 2017 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of create-iso
#
# create-iso is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
mountOverlay() {
local chrootdir="${1}"
local tmpfs="${2}"
local prefix="${PWD}"
mkdir --parents "${tmpfs}/upper"
mkdir --parents "${tmpfs}/work"
mkdir --parents "${chrootdir}"
if [ ! -d "${tmpfs}" ]; then
echo "overlay path: '${tmpfs}' has not been found."
exit 1
fi
if [ ! -d "${tmpfs}/upper" ]; then
echo "upperdir path: '${tmpfs}/upper' has not been found."
exit 1
fi
if [ ! -d "${tmpfs}/work" ]; then
echo "workdir path: '${tmpfs}/work' has not been found."
exit 1
fi
if [ ! -d "${chrootdir}" ]; then
echo "merge point path: '${chrootdir}' has not been found."
exit 1
fi
if [ ! -d "${prefix}/chroot" ]; then
echo "chroot path: '${prefix}/chroot' has not been found."