2015-06-25 00:16:18 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This program 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; version 2 of the License.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2016-02-27 12:31:29 +01:00
|
|
|
track_image() {
|
2016-09-15 23:58:18 +02:00
|
|
|
info "%s mount: [%s]" "${iso_fs}" "$5"
|
|
|
|
mount "$@" && IMAGE_ACTIVE_MOUNTS=("$5" "${IMAGE_ACTIVE_MOUNTS[@]}")
|
2016-02-27 12:31:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-25 00:16:18 +02:00
|
|
|
# $1: new branch
|
2016-02-25 15:51:25 +01:00
|
|
|
mount_image(){
|
2016-09-15 23:58:18 +02:00
|
|
|
IMAGE_ACTIVE_MOUNTS=()
|
2016-10-13 16:12:17 +02:00
|
|
|
mkdir -p "${mnt_dir}/work"
|
|
|
|
track_image -t overlay overlay -olowerdir="${work_dir}/rootfs",upperdir="$1",workdir="${mnt_dir}/work" "$1"
|
2015-06-25 00:16:18 +02:00
|
|
|
}
|
|
|
|
|
2016-02-25 15:51:25 +01:00
|
|
|
mount_image_custom(){
|
2016-09-15 23:58:18 +02:00
|
|
|
IMAGE_ACTIVE_MOUNTS=()
|
2016-10-13 16:12:17 +02:00
|
|
|
mkdir -p "${mnt_dir}/work"
|
|
|
|
track_image -t overlay overlay -olowerdir="${work_dir}/desktopfs":"${work_dir}/rootfs",upperdir="$1",workdir="${mnt_dir}/work" "$1"
|
2015-06-25 00:16:18 +02:00
|
|
|
}
|
2015-06-25 09:59:35 +02:00
|
|
|
|
2016-10-07 16:49:49 +02:00
|
|
|
mount_image_live(){
|
|
|
|
IMAGE_ACTIVE_MOUNTS=()
|
2016-10-13 16:12:17 +02:00
|
|
|
mkdir -p "${mnt_dir}/work"
|
|
|
|
track_image -t overlay overlay -olowerdir="${work_dir}/livefs":"${work_dir}/rootfs",upperdir="$1",workdir="${mnt_dir}/work" "$1"
|
2016-10-07 16:49:49 +02:00
|
|
|
}
|
|
|
|
|
2015-06-25 09:59:35 +02:00
|
|
|
umount_image(){
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ -n ${IMAGE_ACTIVE_MOUNTS[@]} ]];then
|
|
|
|
info "%s umount: [%s]" "${iso_fs}" "${IMAGE_ACTIVE_MOUNTS[@]}"
|
|
|
|
umount "${IMAGE_ACTIVE_MOUNTS[@]}"
|
|
|
|
unset IMAGE_ACTIVE_MOUNTS
|
2016-10-13 16:12:17 +02:00
|
|
|
rm -rf "${mnt_dir}/work"
|
2016-09-15 23:58:18 +02:00
|
|
|
fi
|
2015-06-25 09:59:35 +02:00
|
|
|
}
|