From 37eabd9018c7d7bad5c2535be816a10f415e4f58 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Tue, 3 Mar 2020 05:56:14 +0000 Subject: [PATCH] add a help file and alphabetize --- travis.sh | 119 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 89 insertions(+), 30 deletions(-) diff --git a/travis.sh b/travis.sh index e375abec..58943b87 100755 --- a/travis.sh +++ b/travis.sh @@ -1,13 +1,61 @@ #!/bin/bash -################# travis.sh ################# +################# ./travis.sh ################# # This script takes care of the common steps -# found in the Travis CI builds. +# found in the frappe_docker Travis CI builds. +# +# Usage: [-a | -s | -w | -h] [-n ] [-t | -g ] [-o] +# +# Argumets: +# +# -a | --assets (exclusive): Build the nginx + static assets image +# -s | --socketio (exclusive): Build the frappe-socketio image +# -w | --worker (exclusive): Build the python environment image +# -h | --help (exclusive): Print this page +# +# -n | --service : Name of the service to build: "erpnext" or "frappe" +# Note: --socketio does not respect this argument +# Note: This will build an image with the name "$SERVICE-assets" (i.e. "erpnext-worker", "frappe-assets", etc.) +# +# -t | --tag (exclusive): The image tag (i.e. erpnext-worker:$TAG ) +# -g | --git-version (exclusive): The version number of --service (i.e. "11", "12", etc.) +# Note: This must be a number, not a string! +# +# -o | --tag-only: Only tag an image and push it. +# +# + while [[ $# -gt 0 ]]; do key="$1" case $key in + -a|--assets) + ASSETS=1 + shift + ;; + -g|--git-version) + version="$2" + shift + shift + ;; + -h|--help) + HELP=1 + shift + ;; + -n|--service) + SERVICE="$2" + shift + shift + ;; + -o|--tag-only) + TAGONLY=1 + shift + ;; + -s|--socketio) + SOCKETIO=1 + shift + ;; -t|--tag) TAG="$2" shift @@ -17,31 +65,37 @@ while [[ $# -gt 0 ]]; do WORKER=1 shift ;; - -a|--assets) - ASSETS=1 - shift - ;; - -s|--socketio) - SOCKETIO=1 - shift - ;; - -n|--name) - NAME="$2" + *) + HELP=1 shift - shift - ;; - -o|--tag-only) - TAGONLY=1 - shift - ;; - -g|--git-branch) - BRANCH="$2" - shift - shift ;; esac done +function help() { + echo "################ $0 #################" + echo " This script takes care of the common steps found in the frappe_docker Travis CI builds." + echo "" + echo " Usage: [-a | -s | -w | -h] [-n ] [-t | -g ] [-o]" + echo "" + echo " Argumets:" + echo "" + echo " -a | --assets (exclusive): Build the nginx + static assets image" + echo " -s | --socketio (exclusive): Build the frappe-socketio image" + echo " -w | --worker (exclusive): Build the python environment image" + echo " -h | --help (exclusive): Print this page" + echo "" + echo " -n | --service : Name of the service to build: \"erpnext\" or \"frappe\"" + echo " Note: --socketio does not respect this argument" + echo " Note: This will build an image with the name \"\$SERVICE-assets\" (i.e. \"erpnext-worker\", \"frappe-assets\", etc.)" + echo "" + echo " -t | --tag (exclusive): The image tag (i.e. erpnext-worker:\$TAG)" + echo " -g | --git-version (exclusive): The version number of --service (i.e. \"11\", \"12\", etc.)" + echo " Note: This must be a number, not a string!" + echo "" + echo " -o | --tag-only: Only tag an image and push it." +} + function gitVersion() { echo "Pulling ${1} v${2}" git clone https://github.com/frappe/${1} --branch version-${2} @@ -64,28 +118,33 @@ function build () { tagAndPush "${1}-${3}" ${2} } -if [[ $BRANCH ]]; then - gitVersion $NAME $BRANCH +if [[ HELP ]]; then + help + exit 1 +fi + +if [[ $VERSION ]]; then + gitVersion $SERVICE $VERSION fi DOCKERFILE=${DOCKERFILE:-Dockerfile} if [[ $WORKER ]]; then if [[ $TAGONLY ]]; then - tagAndPush "${NAME}-worker" ${TAG} + tagAndPush "${SERVICE}-worker" ${TAG} else - build $NAME $TAG worker ${DOCKERFILE} + build $SERVICE $TAG worker ${DOCKERFILE} fi elif [[ $ASSETS ]]; then if [[ $TAGONLY ]]; then - tagAndPush "${NAME}-assets" ${TAG} + tagAndPush "${SERVICE}-assets" ${TAG} else - build $NAME $TAG assets ${DOCKERFILE} + build $SERVICE $TAG assets ${DOCKERFILE} fi elif [[ $SOCKETIO ]]; then if [[ $TAGONLY ]]; then - tagAndPush "${NAME}-socketio" ${TAG} + tagAndPush "frappe-socketio" ${TAG} else - build $NAME $TAG socketio ${DOCKERFILE} + build frappe $TAG socketio ${DOCKERFILE} fi fi \ No newline at end of file