diff --git a/sh/alias/overlay.sh b/sh/alias/overlay.sh index b2bd77f..82fe273 100644 --- a/sh/alias/overlay.sh +++ b/sh/alias/overlay.sh @@ -1,4 +1,5 @@ -mo() { +orm() { a__overlay_root_mount "${@}"; } +a__overlay_root_mount() { local root="${1}" if [ -z "${root}" ]; then sh_log_error "No root target directory" @@ -36,7 +37,8 @@ mo() { ) } -uo() { +oru() { a__overlay_root_unmount "${@}"; } +a__overlay_root_unmount() { ( if ! cd "overlay"; then sh_log_error "Unable to move into overlay directory" @@ -72,7 +74,8 @@ uo() { fi } -mr() { +obm() { a__overlay_bind_mount "${@}"; } +a__overlay_bind_mount() { local directory for directory in "dev" "dev/pts" "proc" "sys"; do if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then @@ -82,18 +85,21 @@ mr() { done } -cr() { +ocr() { a__overlay_command_root "${@}"; } +a__overlay_command_root() { chroot \ "overlay/mount" "${@}" } -cru() { +ocu() { a__overlay_command_user "${@}"; } +a__overlay_command_user() { chroot \ --userspec "1000:1000" \ "overlay/mount" "${@}" } -ur() { +obu() { a__overlay_bind_unmount "${@}"; } +a__overlay_bind_unmount() { local directory for directory in "sys" "proc" "dev/pts" "dev"; do if ! umount --lazy "overlay/mount/${directory}"; then @@ -103,15 +109,18 @@ ur() { done } -mm() { +omm() { a__overlay_mirror_mount "${@}"; } +a__overlay_mirror_mount() { mount --make-rslave --rbind "/deb" "overlay/mount/deb" } -um() { +omu() { a__overlay_mirror_unmount "${@}"; } +a__overlay_mirror_unmount() { umount --recursive "overlay/mount/deb" } -ms() { +ors() { a__overlay_root_squash "${@}"; } +a__overlay_root_squash() { local directory="${1}" local file local level="${2}"