From 39d701f946c7849093b687bdab5c90db44958993 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Mon, 23 Sep 2024 00:09:21 +0200 Subject: [PATCH] feat: add overlay testing script --- overlay.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 overlay.sh diff --git a/overlay.sh b/overlay.sh new file mode 100644 index 0000000..4a13c81 --- /dev/null +++ b/overlay.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +UID=$(id -u) +GID=$(id -g) +CURDIR=$(pwd) + +set -u +set -e + +echo "Umounting merge directory if it is mounted" +if mount | grep -q "${CURDIR}.merge"; then + sudo umount -lf "${CURDIR}.merge" +fi + +# echo "Removing old upper directory" +# sudo rm -rf "${CURDIR}.upper" + +echo "Creating directories" +sudo mkdir -p "${CURDIR}.upper" +sudo mkdir -p "${CURDIR}.workdir" +sudo mkdir -p "${CURDIR}.merge" + +echo "Setting permissions" +sudo chown "$UID:$GID" "${CURDIR}.upper" +sudo chown "$UID:$GID" "${CURDIR}.workdir" +sudo chown "$UID:$GID" "${CURDIR}.merge" + +echo "Mounting filesystem" +sudo mount -t overlay \ + -o "lowerdir=${CURDIR},upperdir=${CURDIR}.upper,workdir=${CURDIR}.workdir" \ + overlay \ + "${CURDIR}.merge" + +echo "Running shell" +cd "${CURDIR}.merge" || exit 1 +exec $SHELL