209 lines
5.1 KiB
Bash
209 lines
5.1 KiB
Bash
#!/bin/bash
|
|
|
|
###
|
|
# Parses arguments and commands from shell
|
|
###
|
|
|
|
_GIT_DIR="./"
|
|
|
|
#Recursive argument parser
|
|
while true; do
|
|
case ${1} in
|
|
--help)
|
|
shift
|
|
HELP="${1}"
|
|
[[ -z "${HELP}" ]] && HELP=general
|
|
eval help_${HELP}
|
|
exit
|
|
;;
|
|
|
|
--info)
|
|
help_info
|
|
exit
|
|
;;
|
|
|
|
--git-dir|-g)
|
|
shift
|
|
_GIT_DIR="${1}"
|
|
;;
|
|
|
|
--batch-id|-b)
|
|
shift
|
|
_BATCHID="${1}"
|
|
;;
|
|
|
|
--force|-f)
|
|
_FORCE="force"
|
|
;;
|
|
|
|
--debug)
|
|
_DEBUG=true
|
|
echo "Debug true"
|
|
;;
|
|
|
|
*)
|
|
break
|
|
;;
|
|
|
|
esac
|
|
shift
|
|
done
|
|
|
|
case "${1}" in
|
|
init)
|
|
shift
|
|
cmd_init "${_GIT_DIR}" ${@}
|
|
EXIT=$?
|
|
[[ ${EXIT} -eq 1 ]] && echo "Database file already present"
|
|
[[ ${EXIT} -eq 3 ]] && echo "Init had errors"
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
|
|
|
;;
|
|
|
|
import)
|
|
shift
|
|
case "${1}" in
|
|
tracks)
|
|
shift
|
|
cmd_import_tracks "${_GIT_DIR}" $([[ -n "${_BATCHID}" ]] && echo "-b") ${_BATCHID} ${@}
|
|
;;
|
|
|
|
eac)
|
|
shift
|
|
cmd_import_images "${_GIT_DIR}" EAC $([[ -n "${_BATCHID}" ]] && echo "-b") ${_BATCHID} ${@}
|
|
;;
|
|
|
|
cuetools)
|
|
shift
|
|
cmd_import_images "${_GIT_DIR}" CUETOOLS $([[ -n "${_BATCHID}" ]] && echo "-b") ${_BATCHID} ${@}
|
|
;;
|
|
|
|
*)
|
|
echo "${1} not a valid command"
|
|
;;
|
|
esac
|
|
;;
|
|
|
|
exclude)
|
|
shift
|
|
cmd_exclude "${_GIT_DIR}" ${@}
|
|
EXIT=$?
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
|
;;
|
|
|
|
include)
|
|
shift
|
|
cmd_include "${_GIT_DIR}" ${@}
|
|
EXIT=$?
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
|
;;
|
|
|
|
export)
|
|
shift
|
|
while [[ -n "${1}" ]]; do
|
|
case ${1} in
|
|
--from)
|
|
shift
|
|
OLD_COMMIT=${1}
|
|
;;
|
|
|
|
*)
|
|
TARGET="${1}"
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
cmd_export $([[ ${_FORCE} == "force" ]] && echo '-f') "${_GIT_DIR}" "${TARGET}" ${OLD_COMMIT}
|
|
EXIT=$?
|
|
[[ ${EXIT} -eq 0 ]] && echo "Deployment completed successfully"
|
|
[[ ${EXIT} -eq 1 ]] && echo "Deployment completed with errors"
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
|
[[ ${EXIT} -eq 4 ]] && echo "Not enough space on device"
|
|
;;
|
|
|
|
update)
|
|
shift
|
|
while [[ -n "${1}" ]]; do
|
|
case ${1} in
|
|
--from)
|
|
shift
|
|
OLD_COMMIT=${1}
|
|
shift
|
|
;;
|
|
|
|
--include)
|
|
INCLUDE=true
|
|
shift
|
|
;;
|
|
|
|
*)
|
|
TARGET="${1}"
|
|
shift
|
|
;;
|
|
esac
|
|
done
|
|
|
|
cmd_update $([[ ${INCLUDE} ]] && echo "--include") "${_GIT_DIR}" "${TARGET}" "${OLD_COMMIT}"
|
|
EXIT=$?
|
|
[[ ${EXIT} -eq 0 ]] && echo "Update completed successfully"
|
|
[[ ${EXIT} -eq 1 ]] && echo "Update completed with errors"
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
|
;;
|
|
|
|
du)
|
|
shift
|
|
cmd_du "${_GIT_DIR}" "${@}"
|
|
EXIT=$?
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
|
;;
|
|
|
|
fsck)
|
|
shift
|
|
while [[ -n "${1}" ]]; do
|
|
case ${1} in
|
|
--nonexistent-ids)
|
|
cmdList=(${cmdList[@]} nonexistent-ids)
|
|
shift
|
|
;;
|
|
|
|
--deployed-ids)
|
|
cmdList=(${cmdList[@]} deployed-ids)
|
|
shift
|
|
;;
|
|
|
|
--metadata)
|
|
cmdList=(${cmdList[@]} metadata)
|
|
shift
|
|
;;
|
|
|
|
--duplicate-trackid)
|
|
cmdList=(${cmdList[@]} duplicate-trackid)
|
|
shift
|
|
;;
|
|
|
|
*)
|
|
TARGET="${1}"
|
|
shift
|
|
;;
|
|
|
|
esac
|
|
done
|
|
|
|
[[ -z ${cmdList[@]} ]] && cmdList=(deployed-ids nonexistent-ids metadata duplicate-trackid)
|
|
|
|
cmd_fsck "${_GIT_DIR}" "${TARGET}" ${cmdList[@]}
|
|
EXIT=$?
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
|
;;
|
|
|
|
*)
|
|
help_general
|
|
;;
|
|
esac
|
|
|