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.
|
|
|
|
|
2017-03-09 12:23:07 +01:00
|
|
|
track_img() {
|
|
|
|
info "mount: [%s]" "$2"
|
|
|
|
mount "$@" && IMG_ACTIVE_MOUNTS=("$2" "${IMG_ACTIVE_MOUNTS[@]}")
|
|
|
|
}
|
|
|
|
|
|
|
|
mount_img() {
|
|
|
|
IMG_ACTIVE_MOUNTS=()
|
|
|
|
mkdir -p "$2"
|
|
|
|
track_img "$1" "$2"
|
|
|
|
}
|
|
|
|
|
|
|
|
umount_img() {
|
2018-04-14 00:07:43 +02:00
|
|
|
if [[ -n ${IMG_ACTIVE_MOUNTS[@]} ]]; then
|
2017-03-09 12:23:07 +01:00
|
|
|
info "umount: [%s]" "${IMG_ACTIVE_MOUNTS[@]}"
|
|
|
|
umount "${IMG_ACTIVE_MOUNTS[@]}"
|
|
|
|
unset IMG_ACTIVE_MOUNTS
|
|
|
|
rm -r "$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-02-01 10:16:59 +01:00
|
|
|
track_fs() {
|
2017-03-09 12:23:07 +01:00
|
|
|
info "overlayfs mount: [%s]" "$5"
|
2017-02-01 10:16:59 +01:00
|
|
|
mount "$@" && FS_ACTIVE_MOUNTS=("$5" "${FS_ACTIVE_MOUNTS[@]}")
|
2016-02-27 12:31:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-25 00:16:18 +02:00
|
|
|
# $1: new branch
|
2017-02-01 10:16:59 +01:00
|
|
|
mount_fs_root(){
|
|
|
|
FS_ACTIVE_MOUNTS=()
|
2016-10-13 16:12:17 +02:00
|
|
|
mkdir -p "${mnt_dir}/work"
|
2017-02-01 10:16:59 +01:00
|
|
|
track_fs -t overlay overlay -olowerdir="${work_dir}/rootfs",upperdir="$1",workdir="${mnt_dir}/work" "$1"
|
2015-06-25 00:16:18 +02:00
|
|
|
}
|
|
|
|
|
2017-02-01 10:16:59 +01:00
|
|
|
mount_fs_desktop(){
|
|
|
|
FS_ACTIVE_MOUNTS=()
|
2016-10-13 16:12:17 +02:00
|
|
|
mkdir -p "${mnt_dir}/work"
|
2017-02-01 10:16:59 +01:00
|
|
|
track_fs -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
|
|
|
|
2017-02-01 10:16:59 +01:00
|
|
|
mount_fs_live(){
|
|
|
|
FS_ACTIVE_MOUNTS=()
|
2016-10-13 16:12:17 +02:00
|
|
|
mkdir -p "${mnt_dir}/work"
|
2017-02-01 10:16:59 +01:00
|
|
|
track_fs -t overlay overlay -olowerdir="${work_dir}/livefs":"${work_dir}/desktopfs":"${work_dir}/rootfs",upperdir="$1",workdir="${mnt_dir}/work" "$1"
|
2016-10-07 16:49:49 +02:00
|
|
|
}
|
|
|
|
|
2017-02-01 20:20:23 +01:00
|
|
|
mount_fs_net(){
|
|
|
|
FS_ACTIVE_MOUNTS=()
|
|
|
|
mkdir -p "${mnt_dir}/work"
|
|
|
|
track_fs -t overlay overlay -olowerdir="${work_dir}/livefs":"${work_dir}/rootfs",upperdir="$1",workdir="${mnt_dir}/work" "$1"
|
|
|
|
}
|
|
|
|
|
2017-02-01 10:16:59 +01:00
|
|
|
umount_fs(){
|
2018-04-14 00:07:43 +02:00
|
|
|
if [[ -n ${FS_ACTIVE_MOUNTS[@]} ]]; then
|
2021-07-20 10:19:08 +02:00
|
|
|
info "overlayfs umount: [%s]" "${FS_ACTIVE_MOUNTS[@]}"
|
2021-07-20 09:13:41 +02:00
|
|
|
#umount "${FS_ACTIVE_MOUNTS[@]}"
|
2021-07-20 09:58:50 +02:00
|
|
|
info "workdir: [%s]" "${work_dir}"
|
|
|
|
grep ${work_dir} /proc/mounts
|
2021-07-20 10:19:08 +02:00
|
|
|
$(grep ${work_dir} /proc/mounts | awk '{print$2}' | sort -r)
|
2021-07-20 09:58:50 +02:00
|
|
|
info "overlayfs umount: [%s]" "$(\"${FS_ACTIVE_MOUNTS[@]}\" | sort -r)"
|
2021-07-20 10:19:08 +02:00
|
|
|
umount -l "$(\"${FS_ACTIVE_MOUNTS[@]}\" | sort -r)"
|
2017-02-01 10:16:59 +01:00
|
|
|
unset FS_ACTIVE_MOUNTS
|
2016-10-13 16:12:17 +02:00
|
|
|
rm -rf "${mnt_dir}/work"
|
2016-09-15 23:58:18 +02:00
|
|
|
fi
|
2021-07-20 10:19:08 +02:00
|
|
|
cat /proc/mounts
|
2015-06-25 09:59:35 +02:00
|
|
|
}
|