tools/stx-init-env
Davlet Panech fcfa8b61ac Debian env scripts: allow user overrides
- import-stx: allow users to override MINIKUBENAME
- stx-init-env: push VolumePath via the environment. This script appears
  to have been designed to be sourced (it uses "return" statements
  rather than "exit"), yet it attempts to process a command-line
  argument ($1), which doesn't work in sourced files. Solution: define
  docker mount point in import-stx as an environment variable.

Story: 2008846
Task:  43753

Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
Change-Id: I489be2276bc2f0798affaf6c334614648f5922c2
2021-10-27 15:53:45 -04:00

79 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# Starlingx Debian Build Enviroment Setup Script
# Normally this is called as 'source stx-init-env <sharedvolumedir>'
# Also we can execute the command 'source stx-init-env' as default
source import-stx
if [ $? -ne 0 ]; then
return 1
fi
MINIKUBE=minikube
HELM=helm
DOCKER=docker
if ! command -v $MINIKUBE &> /dev/null; then
echo "Command $MINIKUBE could not be found."
echo "Please install it as https://minikube.sigs.k8s.io/docs/start/"
echo ""
fi
if ! command -v $HELM &> /dev/null; then
echo "Command $HELM could not be found."
echo "Please install it as https://helm.sh/"
echo ""
fi
if ! command -v $DOCKER &> /dev/null; then
echo "Command $DOCKER could not be found. Please install it."
echo ""
fi
MINIKUBE_EXIST=$(docker ps | grep kicbase | grep $MINIKUBENAME)
if [ x"$MINIKUBE_EXIST" == x"" ]; then
echo "Start the new minikube $MINIKUBENAME"
else
echo "The minikube $MINIKUBENAME exists, we will try to stop it..."
echo "Then restart it..."
echo ""
$MINIKUBE stop -p $MINIKUBENAME >> /dev/null
ret=$(docker ps | grep kicbase | grep $MINIKUBENAME)
if [ x"$ret" != x"" ]; then
echo "minikube container $MINIKUBENAME exist!"
echo "And the command 'minikube -p $MINIKUBENAME stop' failed. The reason may be"
echo "the current MINIKUBE_HOME/HOME is not the same as the $MINIKUBENAME"
echo "Please change the MINIKUBE_HOME/HOME directory to the previous value"
echo "then re-execute this script"
unset MINIKUBE_HOME
return 1
fi
fi
if [ ! -d "$STX_BUILD_HOME" ]; then
echo "Warning: The directory $STX_BUILD_HOME doesn't exist, please create it with the command:"
echo ""
echo " mkdir -p $STX_BUILD_HOME"
echo ""
echo "Then execute this script again!"
return 1
fi
$MINIKUBE start --driver=docker -p $MINIKUBENAME --mount=true --mount-string="$STX_BUILD_HOME:/workspace"
if [ $? -ne 0 ]; then
return 1
fi
# Build the container images from the dockerfiles
DOCKERNAMES="stx-builder stx-pkgbuilder stx-lat-tool stx-aptly"
eval $(minikube -p $MINIKUBENAME docker-env)
for i in $DOCKERNAMES; do
docker build -t $i:v0.1.0 -f stx/dockerfiles/$i.Dockerfile .
if [ $? -ne 0 ]; then
return 1
fi
done
eval $(minikube -p $MINIKUBENAME docker-env -u)