sort out exit codes

This commit is contained in:
George Danchev 2011-07-02 18:55:09 +00:00
parent f8a36b3fc9
commit 5360404f82
2 changed files with 26 additions and 21 deletions

View File

@ -35,7 +35,7 @@ HLP
##################################################################### #####################################################################
# cleanup # cleanup
if [ "${1}" == "-cleanup" ]; then if [ "${1}" == "-cleanup" ]; then
cd "${START_DIR_DONT_CHANGE}" || exit 80 cd "${START_DIR_DONT_CHANGE}" || exit 2
if [ -d "${GEN_DATA_DIR}" ]; then if [ -d "${GEN_DATA_DIR}" ]; then
rm -rf ${GEN_DATA_DIR} rm -rf ${GEN_DATA_DIR}
printf "${SELF}: removed %s\n" ${GEN_DATA_DIR} printf "${SELF}: removed %s\n" ${GEN_DATA_DIR}
@ -46,14 +46,14 @@ if [ "${1}" == "-cleanup" ]; then
fi fi
# help # help
if [ ! "${1}" ]; then print_help && exit 10; fi if [ ! "${1}" ]; then print_help && exit 3; fi
# config file # config file
if [ "${1}" == "-rc" ]; then if [ "${1}" == "-rc" ]; then
if [ -e ${CONFFILE} ]; then if [ -e ${CONFFILE} ]; then
. ${CONFFILE} . ${CONFFILE}
printf "${SELF}: Using config file %s\n" ${CONFFILE} printf "${SELF}: Using config file %s\n" ${CONFFILE}
else else
echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 20 echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 4
fi fi
if [ "${2}" == "-keep" ]; then KEEP=1; fi if [ "${2}" == "-keep" ]; then KEEP=1; fi
# command line args # command line args
@ -68,26 +68,31 @@ elif [ "${3}" ]; then
fi fi
# the rest # the rest
else else
print_help && exit 30 print_help && exit 5
fi fi
# data dir # data dir
if [ -d "${GEN_DATA_DIR}" ]; then if [ -d "${GEN_DATA_DIR}" ]; then
printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR} printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
printf "\n${SELF}: use '${SELF} -cleanup' to remove.\n" printf "\n${SELF}: use '${SELF} -cleanup' to remove.\n"
exit 2 exit 6
else else
mkdir "${GEN_DATA_DIR}" mkdir "${GEN_DATA_DIR}"
fi fi
if [ "${RELENG_XORRISO}" == "" -o "${RELENG_DIR}" == "" -o "${RELENG_IMG}" == "" ]; then if [ "${RELENG_XORRISO}" == "" -o "${RELENG_DIR}" == "" -o "${RELENG_IMG}" == "" ]; then
echo -e "\n${SELF}: xorriso_cmd IN_dir and OUT_image are required\n" echo -e "\n${SELF}: xorriso_cmd IN_dir and OUT_image are required\n"
exit 40 exit 7
fi fi
if [ ! -x "${RELENG_XORRISO}" ]; then if [ ! -x "${RELENG_XORRISO}" ]; then
printf "${SELF}: Not found or not an executable: $RELENG_XORRISO\n" printf "${SELF}: $RELENG_XORRISO not found or not an executable.\n"
exit 50 exit 8
fi
if [ ! -d "${RELENG_DIR}" ]; then
printf "${SELF}: $RELENG_DIR does not exist or not a directory.\n"
exit 9
fi fi
# all must be set at this point # all must be set at this point
@ -101,7 +106,7 @@ RES="${RELENG_IMG}.iso ${RELENG_IMG}.new ${RELENG_IMG}.md5 ${RELENG_IMG}.jigdo $
if ! "${RELENG_XORRISO}" -version | grep libjte >/dev/null 2>&1; then if ! "${RELENG_XORRISO}" -version | grep libjte >/dev/null 2>&1; then
printf "\n${SELF}: JTE not supported with this xorriso build. Install jigit and rebuild." printf "\n${SELF}: JTE not supported with this xorriso build. Install jigit and rebuild."
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n" printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
exit 51 exit 10
fi fi
# remove cruft from previous runs # remove cruft from previous runs
@ -121,7 +126,7 @@ if which jigdo-gen-md5-list >/dev/null 2>&1; then
else else
printf "\n${SELF}: Not found: jigdo-gen-md5-list. Install jigit." printf "\n${SELF}: Not found: jigdo-gen-md5-list. Install jigit."
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n" printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
exit 60 exit 11
fi fi
# build the command - general section # build the command - general section
@ -176,7 +181,7 @@ if which jigit-mkimage >/dev/null 2>&1; then
else else
printf "\n${SELF}: Not found: jigit-mkimage. Install jigit." printf "\n${SELF}: Not found: jigit-mkimage. Install jigit."
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n" printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
exit 70 exit 12
fi fi
# trap the exit code of diff and let the Universe explode # trap the exit code of diff and let the Universe explode
@ -195,7 +200,7 @@ esac
if [ ${KEEP} -eq 0 ]; then if [ ${KEEP} -eq 0 ]; then
# safety net, just in case -> we want to be in the starting # safety net, just in case -> we want to be in the starting
# directory before removing whatever self-generated stuff # directory before removing whatever self-generated stuff
cd "${START_DIR_DONT_CHANGE}" || exit 80 cd "${START_DIR_DONT_CHANGE}" || exit 13
rm -rf ${GEN_DATA_DIR} rm -rf ${GEN_DATA_DIR}
printf "${SELF}: removed %s\n" ${GEN_DATA_DIR} printf "${SELF}: removed %s\n" ${GEN_DATA_DIR}
else else

View File

@ -36,7 +36,7 @@ HLP
##################################################################### #####################################################################
# cleanup # cleanup
if [ "${1}" == "-cleanup" ]; then if [ "${1}" == "-cleanup" ]; then
cd "${START_DIR_DONT_CHANGE}" || exit 80 cd "${START_DIR_DONT_CHANGE}" || exit 2
if [ -d "${GEN_DATA_DIR}" ]; then if [ -d "${GEN_DATA_DIR}" ]; then
rm -rf ${GEN_DATA_DIR} rm -rf ${GEN_DATA_DIR}
printf "${SELF}: removed %s\n" ${GEN_DATA_DIR} printf "${SELF}: removed %s\n" ${GEN_DATA_DIR}
@ -47,14 +47,14 @@ if [ "${1}" == "-cleanup" ]; then
fi fi
# help # help
if [ ! "${1}" ]; then print_help && exit 10; fi if [ ! "${1}" ]; then print_help && exit 3; fi
# config file # config file
if [ "${1}" == "-rc" ]; then if [ "${1}" == "-rc" ]; then
if [ -e ${CONFFILE} ]; then if [ -e ${CONFFILE} ]; then
. ${CONFFILE} . ${CONFFILE}
printf "${SELF}: Using config file %s\n" ${CONFFILE} printf "${SELF}: Using config file %s\n" ${CONFFILE}
else else
echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 20 echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 4
fi fi
if [ "${2}" == "-keep" ]; then KEEP=1; fi if [ "${2}" == "-keep" ]; then KEEP=1; fi
# command line args # command line args
@ -63,26 +63,26 @@ elif [ "${1}" ]; then
if [ "${2}" == "-keep" ]; then KEEP=1; fi if [ "${2}" == "-keep" ]; then KEEP=1; fi
# the rest # the rest
else else
print_help && exit 30 print_help && exit 5
fi fi
# data dir # data dir
if [ -d "${GEN_DATA_DIR}" ]; then if [ -d "${GEN_DATA_DIR}" ]; then
printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR} printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
printf "\n${SELF}: use '${SELF} -cleanup' to remove.\n" printf "\n${SELF}: use '${SELF} -cleanup' to remove.\n"
exit 2 exit 6
else else
mkdir "${GEN_DATA_DIR}" mkdir "${GEN_DATA_DIR}"
fi fi
if [ "${RELENG_XORRISO}" == "" ]; then if [ "${RELENG_XORRISO}" == "" ]; then
echo -e "\n${SELF}: xorriso_cmd is required\n" echo -e "\n${SELF}: xorriso_cmd is required\n"
exit 40 exit 7
fi fi
if [ ! -x "${RELENG_XORRISO}" ]; then if [ ! -x "${RELENG_XORRISO}" ]; then
printf "${SELF}: Not found or not an executable: $RELENG_XORRISO\n" printf "${SELF}: Not found or not an executable: $RELENG_XORRISO\n"
exit 50 exit 8
fi fi
# all must be set at this point # all must be set at this point
@ -94,7 +94,7 @@ printf "\n\txorriso_cmd=${RELENG_XORRISO}\n"
if ! "${RELENG_XORRISO}" -version | grep libjte >/dev/null 2>&1; then if ! "${RELENG_XORRISO}" -version | grep libjte >/dev/null 2>&1; then
printf "\n${SELF}: JTE not supported with this xorriso build. Install jigit and rebuild." printf "\n${SELF}: JTE not supported with this xorriso build. Install jigit and rebuild."
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n" printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
exit 51 exit 9
fi fi
################################################ ################################################
@ -128,7 +128,7 @@ if [ -x ${RELENG_MKISOFS} ]; then
fi fi
if [ ${KEEP} -eq 0 ]; then if [ ${KEEP} -eq 0 ]; then
cd ${START_DIR_DONT_CHANGE} || exit 2 cd ${START_DIR_DONT_CHANGE} || exit 10
rm -rf ${GEN_DATA_DIR} rm -rf ${GEN_DATA_DIR}
fi fi