Built and documented more logic functions, started an exit codes help section adding exit codes as I go. Ceated a tester script for testing logic functions from functions.lib.sh without the need to run the entire code base.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
TITLE="DebMirror Manager"
|
||||
VERSION="0.0.1"
|
||||
VERSION="0.0.3"
|
||||
URL="https://git.3volve.net.za/thisiszeev/debmirrorman"
|
||||
LICENSE="GPL 3"
|
||||
AUTHOR="Ze'ev Schurmann"
|
||||
AUTHORURL="https://reddit.com/u/thisiszeev"
|
||||
|
||||
@@ -10,46 +11,54 @@ source vars.lib.sh
|
||||
source functions.lib.sh
|
||||
source actions.lib.sh
|
||||
|
||||
if funcValidateSettings; then
|
||||
source "${etcdirectory}/settings.conf"
|
||||
else
|
||||
funcError "Unknown error loading '${etcdirectory}/settings.conf'..." 29
|
||||
fi
|
||||
|
||||
if [[ -z "${1}" ]]; then
|
||||
doHelper
|
||||
exit
|
||||
else
|
||||
command="${1,,}"
|
||||
if [[ -z "${commands[${command}]}" ]]; then
|
||||
echo "Command ${1} not valid..."
|
||||
exit 1
|
||||
funcError "Command '${1}' not valid..." 1
|
||||
else
|
||||
if [[ -n "${2}" ]]; then
|
||||
if [[ "${commandsneedreponame[${command}]}" == "none" ]]; then
|
||||
echo "Command ${1} does not support a repo name..."
|
||||
exit 1
|
||||
funcError "Command '${1}' does not support a repo name..." 2
|
||||
elif [[ "${commandsneedreponame[${command}]}" == "help" ]]; then
|
||||
helpcommand="${2,,}"
|
||||
if [[ -z "${commands[${helpcommand}]}" ]]; then
|
||||
echo "Command ${2} not valid..."
|
||||
exit 1
|
||||
else
|
||||
# if [[ -z "${commands[${helpcommand}]}" ]]; then
|
||||
# funcError "Command '${2}' not valid..." 11
|
||||
# else
|
||||
if [[ -z "${helpercommands[${helpcommand}]}" ]]; then
|
||||
echo "No help documentation for command ${2}..."
|
||||
exit 1
|
||||
funcError "No help documentation for command '${2}'..." 12
|
||||
else
|
||||
${helpercommands[${helpcommand}]}
|
||||
${helpercommands[${helpcommand}]} | less
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
# fi
|
||||
else
|
||||
if funcCheckLocalRepo "${2}"; then
|
||||
funcCheckLocalRepo "${2}"
|
||||
ec=$?
|
||||
if [[ ${ec} == 0 ]]; then
|
||||
${commands[${command}]} "${2}"
|
||||
exit
|
||||
elif [[ ${ec} == 1 ]]; then
|
||||
funcError "Repo name '${2}' not valid..." 4
|
||||
elif [[ ${ec} == 2 ]]; then
|
||||
funcError "Repo name '${2}' is not found in '${etcdirectory}/settings.conf'..." 5
|
||||
elif [[ ${ec} == 3 ]]; then
|
||||
funcError "File '${etcdirectory}/${repo}.repo' does not exist..." 6
|
||||
else
|
||||
echo "Invalid local repo name..."
|
||||
exit 1
|
||||
funcError "Unknown error with local repo '${2}'..." 9
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [[ "${commandsneedreponame[${command}]}" == "required" ]]; then
|
||||
echo "Command ${1} requires a repo name..."
|
||||
exit 1
|
||||
funcError "Command '${1}' requires a repo name..." 3
|
||||
else
|
||||
${commands[${command}]}
|
||||
exit
|
||||
@@ -57,4 +66,5 @@ else
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
exit 127
|
||||
|
||||
funcError "Unknown error with DebMirror Manager..." 127
|
||||
|
||||
Reference in New Issue
Block a user