Skip to content

Commit

Permalink
Update #1
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed Mar 12, 2019
1 parent 77f340a commit ad6eb6e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
8 changes: 4 additions & 4 deletions GearBoxOS/etc/bash_completion.d/box-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ _box_component_running()
{
local cur=${COMP_WORDS[COMP_CWORD]}

COMPREPLY=($(compgen -W "$(docker container ls -af label=container.project=gearbox -f status=running --format='{{.Image}}')" -- $cur))
COMPREPLY=($(compgen -W "$(docker container ls -af label=container.organization=gearboxworks -f status=running --format='{{.Image}}')" -- $cur))
return 0
}

Expand All @@ -129,7 +129,7 @@ _box_component_stopped()
{
local cur=${COMP_WORDS[COMP_CWORD]}

COMPREPLY=($(compgen -W "$(docker container ls -af label=container.project=gearbox -f status=created -f status=exited --format='{{.Image}}')" -- $cur))
COMPREPLY=($(compgen -W "$(docker container ls -af label=container.organization=gearboxworks -f status=created -f status=exited --format='{{.Image}}')" -- $cur))
return 0
}

Expand All @@ -138,7 +138,7 @@ _box_component_all()
{
local cur=${COMP_WORDS[COMP_CWORD]}

COMPREPLY=($(compgen -W "$(docker container ls -af label=container.project=gearbox --format='{{.Image}}')" -- $cur))
COMPREPLY=($(compgen -W "$(docker container ls -af label=container.organization=gearboxworks --format='{{.Image}}')" -- $cur))
return 0
}

Expand All @@ -162,7 +162,7 @@ _box_component_dockerhub()
do
if [ "${IMAGE_VERSION}" != "latest" ]
then
REPLY="$REPLY gearbox/${IMAGE_NAME}:$IMAGE_VERSION"
REPLY="$REPLY gearboxworks/${IMAGE_NAME}:$IMAGE_VERSION"
fi
done
fi
Expand Down
32 changes: 16 additions & 16 deletions cli/includes/container.functions
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ function component_info()
return $RETURN_NO_LOCAL_IMAGE
fi

DOCKER=$(docker inspect --format='{{index .Config.Labels "container.project"}};{{index .Config.Labels "container.name"}};{{index .Config.Labels "container.version"}};{{index .Config.Labels "container.majorversion"}};{{index .Config.Labels "container.latest"}};{{index .Config.Labels "container.class"}};{{index .Config.Labels "container.network"}};{{index .Config.Labels "container.ports"}};{{index .Config.Labels "container.volumes"}};{{index .Config.Labels "container.restart"}};{{index .Config.Labels "container.args"}};{{index .Config.Labels "container.env"}}' ${IMAGE})
DOCKER=$(docker inspect --format='{{index .Config.Labels "container.organization"}};{{index .Config.Labels "container.name"}};{{index .Config.Labels "container.version"}};{{index .Config.Labels "container.majorversion"}};{{index .Config.Labels "container.latest"}};{{index .Config.Labels "container.class"}};{{index .Config.Labels "container.network"}};{{index .Config.Labels "container.ports"}};{{index .Config.Labels "container.volumes"}};{{index .Config.Labels "container.restart"}};{{index .Config.Labels "container.args"}};{{index .Config.Labels "container.env"}}' ${IMAGE})
IFS=';' read -r -a state_array <<< "$DOCKER"

PROJECT="${state_array[0]}"
ORGANIZATION="${state_array[0]}"
IMAGE_NAME="${state_array[1]}"
IMAGE_VERSION="${state_array[2]}"
IMAGE_MAJORVERSION="${state_array[3]}"
Expand All @@ -241,12 +241,12 @@ function component_info()
IMAGE_ARGS="${state_array[10]}"
IMAGE_ENV="${state_array[11]}"

if [ "$PROJECT" == "" ]
if [ "$ORGANIZATION" == "" ]
then
return $RETURN_NO_IMAGE_JSON
fi

if [ "$PROJECT" != "${BOX_NAME}" ]
if [ "$ORGANIZATION" != "${BOX_ORGANIZATION}" ]
then
return $RETURN_INVALID_PROJECT
fi
Expand Down Expand Up @@ -277,15 +277,15 @@ function component_info()

function is_component_in_repo()
{
local RETURN IFS PROJECT IMAGE_NAME IMAGE_VERSION IMAGE
local RETURN IFS ORGANIZATION IMAGE_NAME IMAGE_VERSION IMAGE
IMAGE=$1

IFS='/:' read -r -a state_array <<< "${IMAGE}"
PROJECT="${state_array[0]}"
ORGANIZATION="${state_array[0]}"
IMAGE_NAME="${state_array[1]}"
IMAGE_VERSION="${state_array[2]}"

# wget -qO /dev/null https://hub.docker.com/v2/repositories/${BOX_NAME}/${IMAGE_NAME}/tags/
# wget -qO /dev/null https://hub.docker.com/v2/repositories/${BOX_ORGANIZATION}/${IMAGE_NAME}/tags/
if [ -f "${BOX_ETC_DIR}/images/${IMAGE_NAME}.json" ]
then
jq --raw-output ".results | .[] | .name" "${BOX_ETC_DIR}/images/${IMAGE_NAME}.json" | grep -q "^${IMAGE_VERSION}\$"
Expand Down Expand Up @@ -315,12 +315,12 @@ function update_components()
sudo mkdir -p "${BOX_ETC_DIR}/images"
fi

sudo wget -qNO "${BOX_ETC_DIR}/repositories.json" "https://hub.docker.com/v2/repositories/${BOX_NAME}/?page_size=256"
sudo wget -qNO "${BOX_ETC_DIR}/repositories.json" "https://hub.docker.com/v2/repositories/${BOX_ORGANIZATION}/?page_size=256"
IMAGES="$(jq -r '.results|.[]|.name' "${BOX_ETC_DIR}/repositories.json")"
for IMAGE_NAME in $IMAGES
do
echo -n "."
sudo wget -qNO "${BOX_ETC_DIR}/images/${IMAGE_NAME}.json" "https://hub.docker.com/v2/repositories/${BOX_NAME}/${IMAGE_NAME}/tags/?page_size=256"
sudo wget -qNO "${BOX_ETC_DIR}/images/${IMAGE_NAME}.json" "https://hub.docker.com/v2/repositories/${BOX_ORGANIZATION}/${IMAGE_NAME}/tags/?page_size=256"
done
echo " ${GREEN}OK${RESET}"
}
Expand All @@ -341,7 +341,7 @@ function available_components()
do
if [ "${IMAGE_VERSION}" != "latest" ]
then
echo "${BOX_NAME}/${IMAGE_NAME}:${IMAGE_VERSION}"
echo "${BOX_ORGANIZATION}/${IMAGE_NAME}:${IMAGE_VERSION}"
fi
done
fi
Expand All @@ -366,9 +366,9 @@ function reallyclean()
echo "$ECHO_PREFIX ${GREEN}Shutting down all Gearbox components.${RESET}"
$0 container shutdown
echo "$ECHO_PREFIX ${GREEN}Removing all Gearbox components.${RESET}"
docker container ls -qaf "label=container.project=${BOX_NAME}" | xargs -r docker container rm
docker container ls -qaf "label=container.organization=${BOX_ORGANIZATION}" | xargs -r docker container rm
echo "$ECHO_PREFIX ${GREEN}Removing all Gearbox component downloads.${RESET}"
docker image ls -qaf "label=container.project=${BOX_NAME}" | xargs -r docker image rm
docker image ls -qaf "label=container.organization=${BOX_ORGANIZATION}" | xargs -r docker image rm
fi
else
echo "$ECHO_PREFIX ${GREEN}Doing nothing.${RESET}"
Expand Down Expand Up @@ -765,7 +765,7 @@ function shutdown()

echo "$ECHO_PREFIX ${GREEN}Stopping all Gearbox components. ${RESET} ... "
TEMPFILE="$(mktemp /tmp/box-container.XXX)"
docker container ls -qaf "label=container.project=${BOX_NAME}" | xargs docker stop &> $TEMPFILE
docker container ls -qaf "label=container.organization=${BOX_ORGANIZATION}" | xargs docker stop &> $TEMPFILE
if [ "$?" == "1" ]
then
echo "${RED}NOT OK${RESET}"
Expand Down Expand Up @@ -804,15 +804,15 @@ function component_list()
$RETURN_NO_IMAGE_NAME)
echo "$ECHO_PREFIX ${GREEN}Downloaded components: ${CYAN}${IMAGE}${RESET}"
echo "Image Size"
docker image ls -af "label=container.project=${BOX_NAME}" --format "{{.Repository}}:{{.Tag}} \t{{.Size}}"
docker image ls -af "label=container.organization=${BOX_ORGANIZATION}" --format "{{.Repository}}:{{.Tag}} \t{{.Size}}"
echo ""
echo "$ECHO_PREFIX ${GREEN}Stopped components: ${CYAN}${IMAGE}${RESET}"
echo "Container Size Status"
docker container ls -af "label=container.project=${BOX_NAME}" -f "status=created" -f "status=exited" --format "{{.Image}} \t{{.Size}}\t{{.Status}}"
docker container ls -af "label=container.organization=${BOX_ORGANIZATION}" -f "status=created" -f "status=exited" --format "{{.Image}} \t{{.Size}}\t{{.Status}}"
echo ""
echo "$ECHO_PREFIX ${GREEN}Running components: ${CYAN}${IMAGE}${RESET}"
echo "Container Size Status"
docker container ls -af "label=container.project=${BOX_NAME}" -f "status=running" --format "{{.Image}} \t{{.Size}}\t{{.Status}}"
docker container ls -af "label=container.organization=${BOX_ORGANIZATION}" -f "status=running" --format "{{.Image}} \t{{.Size}}\t{{.Status}}"
;;

$RETURN_NO_LOCAL_IMAGE)
Expand Down
1 change: 1 addition & 0 deletions cli/includes/functions
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export PROJECT_ROOT="${BOX_PROJECTS_ROOT}/${BOX_CURRENT_PROJECT}"
export BOX_PROJECT_DIR="${BOX_PROJECTS_ROOT}/${BOX_CURRENT_PROJECT}"


export BOX_ORGANIZATION="gearboxworks"
export BOX_USER="gearbox"
export BOX_USER_UID="1000"
export BOX_USER_GID="1000"
Expand Down

0 comments on commit ad6eb6e

Please sign in to comment.