Files
WP-hpc-tools/containers/simg-list-all-files.sh
Wirawan Purwanto 9edb1e040d * Imported tools to dump information about files in a container.
The "dump-info" tool works only for Debian-based distro for now.
2021-06-29 13:29:56 -04:00

30 lines
828 B
Bash
Executable File

#!/bin/bash
# Dumps all the filenames on the container.
# By default, run this on the root directory of the container.
# This tool does NOT assume that the root directory is "/"
# to allow access to sandbox _outside_ the container itself.
# All external mount points are ignored.
_simg_list_all_files () {
local ROOT_DIR="${1:-.}"
find "$ROOT_DIR" -mount \
| sort \
| awk -v ROOT="$ROOT_DIR" '
BEGIN {
ROOTX = ROOT
gsub(/\/+$/, "", ROOTX)
ROOTX = (ROOTX "/")
len_ROOTX = length(ROOTX)
}
$0 == ROOT { next }
(substr($0, 1, len_ROOTX) == ROOTX) {
print(substr($0, len_ROOTX))
next
}
'
}
_simg_list_all_files "$@"