1
0
Fork 0

Reorder code and create separate main function

This commit is contained in:
Braiden Vasco 2017-07-02 11:23:16 +00:00
parent 29d4f64953
commit 5d01bba490

View file

@ -31,6 +31,40 @@ export QUILT_REFRESH_ARGS='-p ab'
source "$SCRIPT_DIR/common.sh"
source "$SCRIPT_DIR/dependencies_check.sh"
main() {
dependencies_check "$BASE_DIR/depends"
source "$BASE_DIR/config"
if [ "$(id -u)" != '0' ]; then
echo 'Please run as root' 1>&2
exit 1
fi
if [ -z "${IMG_NAME}" ]; then
echo 'IMG_NAME not set' 1>&2
exit 1
fi
if [ -z "${HOSTNAME}" ]; then
echo 'HOSTNAME not set' 1>&2
exit 1
fi
if [ -z "${USERNAME}" ]; then
echo 'USERNAME not set' 1>&2
exit 1
fi
if [ -z "${PASSWORD}" ]; then
echo 'PASSWORD not set' 1>&2
exit 1
fi
mkdir -p "$WORK_DIR"
run_base
}
log_begin() {
log "Begin $1"
}
@ -208,37 +242,4 @@ run_base() {
log_end "$BASE_DIR"
}
if [ "$(id -u)" != '0' ]; then
echo 'Please run as root' 1>&2
exit 1
fi
if [ -f config ]; then
source config
fi
if [ -z "${IMG_NAME}" ]; then
echo 'IMG_NAME not set' 1>&2
exit 1
fi
if [ -z "${HOSTNAME}" ]; then
echo 'HOSTNAME not set' 1>&2
exit 1
fi
if [ -z "${USERNAME}" ]; then
echo 'USERNAME not set' 1>&2
exit 1
fi
if [ -z "${PASSWORD}" ]; then
echo 'PASSWORD not set' 1>&2
exit 1
fi
dependencies_check "$BASE_DIR/depends"
mkdir -p "$WORK_DIR"
run_base
main