Commit 87aa45c4 authored by Daniel Bissani Furlin's avatar Daniel Bissani Furlin

SCRUM#495: Add function to mount and umount both overlay and tmpfs

parent d07d6987
SHORTNAME=le6
TMP=/home/lucas/${_DIST}/
CHROOTDIR=/home/lucas/create-iso/overlay
OVERLAY=/home/lucas/tmp
TMP=/home/${SUDO_USER}/${_DIST}/
CHROOTDIR=/home/${SUDO_USER}/overlay
TMPFS=/home/${SUDO_USER}/tmp
CHROOTFILE=${TMP}/todo.sh
DISTRO=Linux_Educacional_6.1.0
DPLIST=${PREFIX}/pkg-list/${_DIST}/dependencies.list
......
#!/bin/bash
#
# 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() {
if mount | grep -q ${TMPFS}; then
return 1
fi
mkdir -p ${TMPFS}
if [ ! -d "${TMPFS}" ]; then
echo "overlay path: '${TMPFS}' has not been found."
exit 1
fi
mount -t tmpfs tmpfs -o suid,dev,size=6291456k ${TMPFS}
}
umountTmpfs() {
if mountpoint -q ${TMPFS}; then
umount ${TMPFS}
fi
rm -r ${TMPFS}
}
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -20,58 +20,47 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
_DIST=$1
_ARCH=$2
CHROOTDIR=$3
CHROOTFILE=$4
DISTRO=$5
DPLIST=$6
INSTLIST=$7
ISOLINUX=$8
MOUNTLIST=$9
OURSOURCESLIST=${10}
RMDSKT=${11}
RMLIST=${12}
SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
REPOPKGS=${18}
PREFIX=$PWD
mountOverlay() {
mkdir -p "${TMPFS}/upper"
mkdir -p "${TMPFS}/work"
mkdir -p ${CHROOTDIR}
mkdir "${OVERLAY}/upper"
mkdir "${OVERLAY}/work"
mkdir ${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."
exit 1
fi
if [ ! -d "${OVERLAY}" ]; then
echo "overlay path: '${OVERLAY}' has not been found."
exit 1
fi
if [ ! -d "${OVERLAY}/upper" ]; then
echo "upperdir path: '${OVERLAY}/upper' has not been found."
exit 1
fi
if [ ! -d "${OVERLAY}/work" ]; then
echo "workdir path: '${OVERLAY}/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."
exit 1
fi
if ! mountpoint -q ${CHROOTDIR}; then
if ! mount -t overlay overlay -o rw,lowerdir="${PREFIX}/chroot",upperdir="${TMPFS}"/upper,workdir="${TMPFS}"/work "${CHROOTDIR}"; then
echo "Overlay could not be mounted:" >&2
echo " lowerdir: '${PREFIX}/chroot'" >&2
echo " upperdir: '${TMPFS}/upper'" >&2
echo " workdir: '${TMPFS}/work'" >&2
echo "mount point: '${CHROOTDIR}'" >&2
exit 1
fi
fi
}
if ! mountpoint ${CHROOTDIR}; then
if ! mount -t overlay overlay -o rw,lowerdir="${PREFIX}/chroot",upperdir="${OVERLAY}"/upper,workdir="${OVERLAY}"/work "${CHROOTDIR}"; then
echo "Overlay could not be mounted:" >&2
echo " lowerdir: '${PREFIX}/chroot'" >&2
echo " upperdir: '${OVERLAY}/upper'" >&2
echo " workdir: '${OVERLAY}/work'" >&2
echo "mount point: '${CHROOTDIR}'" >&2
exit 1
umountOverlay() {
if mountpoint -q ${CHROOTDIR}; then
umount ${CHROOTDIR}
fi
fi
rm -r ${TMPFS}/{upper,work}
}
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -69,16 +69,20 @@ source ${PREFIX}/conf/$_DIST/create-iso.conf \
|| log ERROR "configuration file not found for dist: \"${_DIST}\""
source common.sh
mkdir -p ${TMP}
source lib/mktmpfs.sh
source lib/overlay.sh
sudo apt-get install syslinux squashfs-tools genisoimage xorriso \
|| log ERROR "Failed to install basic tools: \"${_DIST}\""
mountTmpfs
mountOverlay
mkdir -p ${TMP}
for file in $(ls ${SCRIPTSDIR}); do
if [ -x "${SCRIPTSDIR}/${file}" ] && egrep -q '^[0-9]{2}-[a-z-]+' <<< "$file"; then
echo "$file"
if ! "${SCRIPTSDIR}/${file}" ${_DIST} ${_ARCH} ${CHROOTDIR} ${CHROOTFILE} ${DISTRO} ${DPLIST} ${INSTLIST} ${ISOLINUX} ${MOUNTLIST} ${OURSOURCESLIST} ${RMDSKT} ${RMLIST} ${SCRIPTSDIR} ${SHORTNAME} ${SOURCESLISTDEFAULT} ${TMP} ${OVERLAY} ${REPOPKGS}; then
if ! "${SCRIPTSDIR}/${file}" ${_DIST} ${_ARCH} ${CHROOTDIR} ${CHROOTFILE} ${DISTRO} ${DPLIST} ${INSTLIST} ${ISOLINUX} ${MOUNTLIST} ${OURSOURCESLIST} ${RMDSKT} ${RMLIST} ${SCRIPTSDIR} ${SHORTNAME} ${SOURCESLISTDEFAULT} ${TMP} ${TMPFS} ${REPOPKGS}; then
log ERROR "While running \"${SCRIPTSDIR}/${file}\""
fi
fi
......@@ -93,5 +97,7 @@ sudo xorriso -as mkisofs -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -c isolin
cd -
cleanTmpFiles
umountOverlay
umountTmpfs
exit 0
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -39,7 +39,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
export PREFIX=$PWD
......
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
......@@ -5,7 +5,7 @@
#
# This file is part of create-iso
#
# le6-conf is free software; you can redistribute it and/or
# 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.
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
......@@ -36,7 +36,7 @@ SCRIPTSDIR=${13}
SHORTNAME=${14}
SOURCESLISTDEFAULT=${15}
TMP=${16}
OVERLAY=${17}
TMPFS=${17}
REPOPKGS=${18}
PREFIX=$PWD
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment