dam/src/cmd_fsck

36 lines
803 B
Bash

#!/bin/bash
# doc cmd_fsck {
#
# DESCRIPTION
# cmd_fsck - Does series of tests on target's database file
#
# USAGE
# cmd_fsck </path/to/git/dir> </path/to/target/dir>
#
# }
cmd_fsck() {
local GIT_DIR="${1}"
local TARGET="${2}"; shift 2
local cmdList=(${@})
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
[[ ! -f "${DB_FILE}" ]] && return 3
[[ ! -d "${GIT_DIR}/.git" ]] && return 2
for cmd in ${cmdList[@]}; do
case ${cmd} in
deployed-ids)
chk_deployed_ids "${TARGET}" "${DB_FILE}"
;;
nonexistent-ids)
chk_nonexistent_ids "${TARGET}" "${DB_FILE}"
;;
metadata)
chk_metadata "${GIT_DIR}" "${TARGET}" "${DB_FILE}"
;;
esac
done
}