stx tool: Add the cleanup for config file and configmap data
Add the '--clean' option for stx-init-env to support to refresh the config file stx.conf, and to drop the configmap data and the intermediate files. Story: 2008862 Task: 44080 Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com> Change-Id: I53cdb50e7f3244940ec4ab26cd68e62aa15ba64f
This commit is contained in:
parent
0e37270dbb
commit
cd956cf61f
38
stx-init-env
38
stx-init-env
|
@ -43,6 +43,7 @@ DOCKER_TAG_LOCAL="v0.1.0"
|
||||||
BUILD_DOCKER=0
|
BUILD_DOCKER=0
|
||||||
DELETE_MINIKUBE=0
|
DELETE_MINIKUBE=0
|
||||||
RESTART_MINIKUBE=0
|
RESTART_MINIKUBE=0
|
||||||
|
CLEAN_CONFIG=0
|
||||||
|
|
||||||
minikube_started() {
|
minikube_started() {
|
||||||
docker ps | grep kicbase | grep -q $MINIKUBENAME
|
docker ps | grep kicbase | grep -q $MINIKUBENAME
|
||||||
|
@ -61,6 +62,10 @@ END
|
||||||
$MINIKUBE profile list -l -o json | $PYTHON3 -c "$script" "$MINIKUBENAME"
|
$MINIKUBE profile list -l -o json | $PYTHON3 -c "$script" "$MINIKUBENAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helm_started() {
|
||||||
|
helm ls | grep -q stx
|
||||||
|
}
|
||||||
|
|
||||||
cmdline_error() {
|
cmdline_error() {
|
||||||
if [[ -n "$1" ]] ; then
|
if [[ -n "$1" ]] ; then
|
||||||
echo "error: $1" >&2
|
echo "error: $1" >&2
|
||||||
|
@ -70,7 +75,7 @@ cmdline_error() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# process command line
|
# process command line
|
||||||
temp=$(getopt -o hR --long help,restart-minikube,rebuild,nuke -n "$PROGNAME" -- "$@") || cmdline_error
|
temp=$(getopt -o hR --long help,clean,restart-minikube,rebuild,nuke -n "$PROGNAME" -- "$@") || cmdline_error
|
||||||
eval set -- "$temp"
|
eval set -- "$temp"
|
||||||
while true ; do
|
while true ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -82,6 +87,10 @@ while true ; do
|
||||||
RESTART_MINIKUBE=1
|
RESTART_MINIKUBE=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--clean)
|
||||||
|
CLEAN_CONFIG=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--rebuild)
|
--rebuild)
|
||||||
BUILD_DOCKER=1
|
BUILD_DOCKER=1
|
||||||
shift
|
shift
|
||||||
|
@ -104,10 +113,6 @@ while true ; do
|
||||||
done
|
done
|
||||||
[[ "$#" -le 0 ]] || cmdline_error "too many arguments"
|
[[ "$#" -le 0 ]] || cmdline_error "too many arguments"
|
||||||
|
|
||||||
|
|
||||||
# import environment
|
|
||||||
source import-stx || return 1
|
|
||||||
|
|
||||||
# make sure required programs are installed
|
# make sure required programs are installed
|
||||||
if ! command -v $MINIKUBE &> /dev/null; then
|
if ! command -v $MINIKUBE &> /dev/null; then
|
||||||
echo >&2 "Command $MINIKUBE could not be found."
|
echo >&2 "Command $MINIKUBE could not be found."
|
||||||
|
@ -127,6 +132,29 @@ if ! command -v $DOCKER &> /dev/null; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# clean the configuration and configmap data
|
||||||
|
if [[ $CLEAN_CONFIG -eq 1 ]] ; then
|
||||||
|
if helm_started ; then
|
||||||
|
notice "Please firstly stop the helm project with 'stx control stop' command."
|
||||||
|
notice "Then execute this cleanup operation again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
notice "Clean the config file and configmap data for builder|pkgbuilder container."
|
||||||
|
# copy a fresh config file
|
||||||
|
rm -f stx.conf
|
||||||
|
cp stx.conf.sample stx.conf
|
||||||
|
|
||||||
|
rm -f stx/lib/stx/__pycache__/*
|
||||||
|
rm -f stx/stx-build-tools-chart/stx-builder/Chart.lock
|
||||||
|
rm -f stx/stx-build-tools-chart/stx-builder/charts/*
|
||||||
|
rm -f stx/stx-build-tools-chart/stx-builder/configmap/stx-localrc
|
||||||
|
rm -f stx/stx-build-tools-chart/stx-builder/dependency_chart/stx-pkgbuilder/configmap/stx-localrc
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# import environment
|
||||||
|
source import-stx || return 1
|
||||||
|
|
||||||
# Make sure $STX_BUILD_HOME exists
|
# Make sure $STX_BUILD_HOME exists
|
||||||
if [[ ! -d "$STX_BUILD_HOME" ]] ; then
|
if [[ ! -d "$STX_BUILD_HOME" ]] ; then
|
||||||
echo >&2 "The directory $STX_BUILD_HOME doesn't exist, please create it with the command:"
|
echo >&2 "The directory $STX_BUILD_HOME doesn't exist, please create it with the command:"
|
||||||
|
|
Loading…
Reference in New Issue