alias/overlay
This commit is contained in:
parent
ecff8f16bc
commit
dc66287ed1
1 changed files with 15 additions and 15 deletions
|
@ -3,7 +3,7 @@ a__overlay_bind_mount() {
|
|||
local directory
|
||||
for directory in "dev" "dev/pts" "proc" "sys"; do
|
||||
if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then
|
||||
sh_log_error "Unable to bind mount directory: ${directory}"
|
||||
rwx_log_error "Unable to bind mount directory: ${directory}"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
@ -14,7 +14,7 @@ a__overlay_bind_unmount() {
|
|||
local directory
|
||||
for directory in "sys" "proc" "dev/pts" "dev"; do
|
||||
if ! umount --lazy "overlay/mount/${directory}"; then
|
||||
sh_log_error "Unable to bind unmount directory: ${directory}"
|
||||
rwx_log_error "Unable to bind unmount directory: ${directory}"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
@ -47,36 +47,36 @@ orm() { a__overlay_root_mount "${@}"; }
|
|||
a__overlay_root_mount() {
|
||||
local root="${1}"
|
||||
if [ -z "${root}" ]; then
|
||||
sh_log_error "No root target directory"
|
||||
rwx_log_error "No root target directory"
|
||||
return 1
|
||||
fi
|
||||
root="$(realpath "${root}")"
|
||||
if ! mkdir "overlay"; then
|
||||
sh_log_error "Unable to make overlay directory"
|
||||
rwx_log_error "Unable to make overlay directory"
|
||||
return 2
|
||||
fi
|
||||
(
|
||||
if ! cd "overlay"; then
|
||||
sh_log_error "Unable to move into overlay directory"
|
||||
rwx_log_error "Unable to move into overlay directory"
|
||||
return 3
|
||||
fi
|
||||
local directory
|
||||
for directory in "lower" "upper" "work" "mount"; do
|
||||
if ! mkdir --parents "${directory}"; then
|
||||
sh_log_error "Unable to make directory: ${directory}"
|
||||
rwx_log_error "Unable to make directory: ${directory}"
|
||||
return 4
|
||||
fi
|
||||
done
|
||||
local file="${root}/filesystem.squashfs"
|
||||
if ! mount "${file}" "lower"; then
|
||||
sh_log_error "Unable to lower mount: ${file}"
|
||||
rwx_log_error "Unable to lower mount: ${file}"
|
||||
return 5
|
||||
fi
|
||||
if ! mount \
|
||||
-o "lowerdir=lower,upperdir=upper,workdir=work" \
|
||||
-t "overlay" \
|
||||
"overlay" "mount"; then
|
||||
sh_log_error "Unable to overlay mount"
|
||||
rwx_log_error "Unable to overlay mount"
|
||||
return 6
|
||||
fi
|
||||
)
|
||||
|
@ -106,35 +106,35 @@ oru() { a__overlay_root_unmount "${@}"; }
|
|||
a__overlay_root_unmount() {
|
||||
(
|
||||
if ! cd "overlay"; then
|
||||
sh_log_error "Unable to move into overlay directory"
|
||||
rwx_log_error "Unable to move into overlay directory"
|
||||
return 1
|
||||
fi
|
||||
if ! umount "mount"; then
|
||||
sh_log_error "Unable to unmount mount directory"
|
||||
rwx_log_error "Unable to unmount mount directory"
|
||||
return 2
|
||||
fi
|
||||
if ! rmdir "mount"; then
|
||||
sh_log_error "Unable to remove mount directory"
|
||||
rwx_log_error "Unable to remove mount directory"
|
||||
return 3
|
||||
fi
|
||||
local directory
|
||||
for directory in "upper" "work"; do
|
||||
if ! rm --force --recursive "${directory}"; then
|
||||
sh_log_error "Unable to remove directory: ${directory}"
|
||||
rwx_log_error "Unable to remove directory: ${directory}"
|
||||
return 4
|
||||
fi
|
||||
done
|
||||
if ! umount "lower"; then
|
||||
sh_log_error "Unable to unmount lower directory"
|
||||
rwx_log_error "Unable to unmount lower directory"
|
||||
return 5
|
||||
fi
|
||||
if ! rmdir "lower"; then
|
||||
sh_log_error "Unable to remove lower directory"
|
||||
rwx_log_error "Unable to remove lower directory"
|
||||
return 6
|
||||
fi
|
||||
)
|
||||
if ! rmdir "overlay"; then
|
||||
sh_log_error "Unable to remove overlay directory"
|
||||
rwx_log_error "Unable to remove overlay directory"
|
||||
return 7
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue