2018-03-26 19:34:44 -04:00
|
|
|
#!/bin/bash
|
2018-03-19 15:09:06 -04:00
|
|
|
|
|
|
|
###
|
|
|
|
# Parses arguments and commands from shell
|
|
|
|
###
|
|
|
|
|
2018-04-07 20:31:51 -04:00
|
|
|
GIT_DIR="./"
|
|
|
|
|
|
|
|
#Recursive argument parser
|
2018-05-04 10:31:53 -07:00
|
|
|
while true; do
|
2018-04-07 20:31:51 -04:00
|
|
|
case ${1} in
|
|
|
|
--help)
|
2018-04-07 21:02:31 -04:00
|
|
|
shift
|
|
|
|
HELP="${1}"
|
|
|
|
[[ -z "${HELP}" ]] && HELP=general
|
2018-04-30 08:54:24 -07:00
|
|
|
eval help_${HELP}
|
|
|
|
exit
|
|
|
|
;;
|
2018-04-07 20:31:51 -04:00
|
|
|
|
2018-04-30 08:54:24 -07:00
|
|
|
--info)
|
2018-04-07 21:02:31 -04:00
|
|
|
help_info
|
2018-04-30 08:54:24 -07:00
|
|
|
exit
|
|
|
|
;;
|
2018-04-07 20:31:51 -04:00
|
|
|
|
2018-04-15 22:58:41 -04:00
|
|
|
--git-dir)
|
|
|
|
shift
|
|
|
|
GIT_DIR="${1}"
|
2018-05-04 12:19:19 -07:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2018-05-04 12:31:01 -07:00
|
|
|
break
|
2018-04-07 20:31:51 -04:00
|
|
|
;;
|
|
|
|
|
2018-04-30 08:54:24 -07:00
|
|
|
esac
|
|
|
|
shift
|
2018-04-07 20:31:51 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-19 15:09:06 -04:00
|
|
|
case "${1}" in
|
2018-05-16 00:03:13 -07:00
|
|
|
init)
|
|
|
|
shift
|
|
|
|
cmd_init "${GIT_DIR}" ${@}
|
|
|
|
EXIT=$?
|
|
|
|
[[ ${EXIT} -eq 1 ]] && echo "Database file already present"
|
|
|
|
[[ ${EXIT} -eq 2 ]] && echo "Init had errors"
|
|
|
|
;;
|
|
|
|
|
2018-05-18 20:16:42 -07:00
|
|
|
import)
|
|
|
|
shift
|
|
|
|
case "${1}" in
|
|
|
|
tracks)
|
|
|
|
shift
|
|
|
|
cmd_import_tracks "${GIT_DIR}" ${@}
|
|
|
|
;;
|
|
|
|
|
|
|
|
images)
|
|
|
|
shift
|
|
|
|
cmd_import_images "${GIT_DIR}" ${@}
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "${1} not a valid command"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
2018-03-19 15:09:06 -04:00
|
|
|
exclude)
|
|
|
|
shift
|
2018-04-07 20:31:51 -04:00
|
|
|
cmd_exclude "${GIT_DIR}" ${@}
|
2018-04-07 21:18:44 -04:00
|
|
|
EXIT=$?
|
2018-04-07 21:40:41 -04:00
|
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
2018-04-07 21:18:44 -04:00
|
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
2018-03-19 15:09:06 -04:00
|
|
|
;;
|
|
|
|
|
2018-03-28 19:26:38 -04:00
|
|
|
include)
|
2018-03-19 15:09:06 -04:00
|
|
|
shift
|
2018-04-08 13:03:22 -04:00
|
|
|
cmd_include "${GIT_DIR}" ${@}
|
2018-04-07 21:18:44 -04:00
|
|
|
EXIT=$?
|
2018-04-07 21:40:41 -04:00
|
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
2018-04-07 21:18:44 -04:00
|
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
2018-04-07 20:31:51 -04:00
|
|
|
;;
|
2018-03-19 15:09:06 -04:00
|
|
|
|
2018-06-15 17:40:53 -08:00
|
|
|
export)
|
2018-03-19 15:09:06 -04:00
|
|
|
shift
|
2018-04-15 22:58:41 -04:00
|
|
|
while [[ -n "${1}" ]]; do
|
|
|
|
case ${1} in
|
|
|
|
--from)
|
|
|
|
shift
|
|
|
|
OLD_COMMIT=${1}
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
TARGET="${1}"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2018-06-15 17:40:53 -08:00
|
|
|
cmd_export "${GIT_DIR}" "${TARGET}" "${OLD_COMMIT}"
|
2018-04-07 21:18:44 -04:00
|
|
|
EXIT=$?
|
2018-04-07 22:40:46 -04:00
|
|
|
[[ ${EXIT} -eq 0 ]] && echo "Deployment completed successfully"
|
2018-04-15 21:30:01 -04:00
|
|
|
[[ ${EXIT} -eq 1 ]] && echo "Deployment completed with errors"
|
2018-04-07 21:40:41 -04:00
|
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
2018-04-07 21:18:44 -04:00
|
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
2018-04-07 20:31:51 -04:00
|
|
|
;;
|
2018-03-19 15:09:06 -04:00
|
|
|
|
|
|
|
update)
|
|
|
|
shift
|
2018-04-15 22:58:41 -04:00
|
|
|
while [[ -n "${1}" ]]; do
|
|
|
|
case ${1} in
|
|
|
|
--from)
|
|
|
|
shift
|
|
|
|
OLD_COMMIT=${1}
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
TARGET="${1}"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2018-04-15 23:05:39 -04:00
|
|
|
cmd_update "${GIT_DIR}" "${TARGET}" "${OLD_COMMIT}"
|
2018-04-07 21:18:44 -04:00
|
|
|
EXIT=$?
|
2018-04-07 22:40:46 -04:00
|
|
|
[[ ${EXIT} -eq 0 ]] && echo "Update completed successfully"
|
2018-04-15 21:30:01 -04:00
|
|
|
[[ ${EXIT} -eq 1 ]] && echo "Update completed with errors"
|
2018-04-07 21:40:41 -04:00
|
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
2018-04-07 21:18:44 -04:00
|
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
2018-04-07 20:31:51 -04:00
|
|
|
;;
|
2018-04-06 19:02:10 -04:00
|
|
|
|
|
|
|
du)
|
|
|
|
shift
|
2018-04-07 20:31:51 -04:00
|
|
|
cmd_du "${GIT_DIR}" "${@}"
|
2018-04-07 21:18:44 -04:00
|
|
|
EXIT=$?
|
2018-04-07 21:40:41 -04:00
|
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
2018-04-07 21:18:44 -04:00
|
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
2018-04-07 20:31:51 -04:00
|
|
|
;;
|
2018-04-07 20:08:23 -04:00
|
|
|
|
|
|
|
fsck)
|
|
|
|
shift
|
2018-04-15 22:33:45 -04:00
|
|
|
while [[ -n "${1}" ]]; do
|
2018-04-15 22:29:45 -04:00
|
|
|
case ${1} in
|
|
|
|
--nonexistent-ids)
|
|
|
|
cmdList=(${cmdList[@]} nonexistent-ids)
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
--deployed-ids)
|
|
|
|
cmdList=(${cmdList[@]} deployed-ids)
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
--metadata)
|
|
|
|
cmdList=(${cmdList[@]} metadata)
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2018-04-15 22:32:21 -04:00
|
|
|
TARGET="${1}"
|
|
|
|
shift
|
|
|
|
;;
|
2018-04-15 22:29:45 -04:00
|
|
|
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
[[ -z ${cmdList[@]} ]] && cmdList=(deployed-ids nonexistent-ids metadata)
|
|
|
|
|
2018-04-15 22:32:21 -04:00
|
|
|
cmd_fsck "${GIT_DIR}" "${TARGET}" ${cmdList[@]}
|
2018-04-07 21:18:44 -04:00
|
|
|
EXIT=$?
|
2018-04-07 21:40:41 -04:00
|
|
|
[[ ${EXIT} -eq 3 ]] && echo "Database file non-existent"
|
2018-04-07 21:18:44 -04:00
|
|
|
[[ ${EXIT} -eq 2 ]] && echo "Git directory not a valid git repository"
|
2018-04-07 20:08:23 -04:00
|
|
|
;;
|
2018-05-18 20:16:42 -07:00
|
|
|
|
|
|
|
*)
|
|
|
|
help_general
|
|
|
|
;;
|
2018-03-19 15:09:06 -04:00
|
|
|
esac
|
|
|
|
|