#!/bin/bash # doc cmd_du { # # DESCRIPTION # cmd_du - Prints disk usage information like TOTAL USAGE of IMAGEID files on TARGET. # # USAGE # cmd_du # # DEPENDENCIES bunc/src/* src/print_imageid_du # # } cmd_du() { local GIT_DIR="${1}" local TARGET="${2}" local DB_FILE="${TARGET}/${_OPT_DB_FILE}" [[ ! -f "${DB_FILE}" ]] && return 3 [[ ! -d "${GIT_DIR}/.git" ]] && return 2 [[ "$(git -C "${GIT_DIR}" rev-list HEAD | tail -n 1)" != "$(awk 'BEGIN{FS="\t"}{if($1=="REPO_ID"){print $2}}' "${DB_FILE}")" ]] && return 2 local imageidList=($(awk 'BEGIN{FS="\t"}{if($1=="true"){print $2}}' ${DB_FILE} | awk '!seen[$0]++')) local DU="$(print_imageid_du ${GIT_DIR} ${imageidList[@]})" _msg ECHO "Current estimated disk usage: ${DU} bytes" }