From 6257227b955d919035d589c34a34af7454bd7380 Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Sat, 24 Feb 2024 12:48:53 -0700 Subject: [PATCH] Add local option to cleanup local files --- openc3.bat | 22 ++++++++++++++++------ openc3.sh | 11 +++++++++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/openc3.bat b/openc3.bat index 63b3076d7a..3ee60c5899 100644 --- a/openc3.bat +++ b/openc3.bat @@ -72,15 +72,25 @@ GOTO :EOF :cleanup if "%2" == "force" ( goto :cleanup_y - ) else ( - set /P c=Are you sure? Cleanup removes ALL docker volumes and all COSMOS data! [Y/N]? - if /I "!c!" EQU "Y" goto :cleanup_y - if /I "!c!" EQU "N" goto :EOF - goto :cleanup ) + if "%3" == "force" ( + goto :cleanup_y + ) + +:try_cleanup + set /P c=Are you sure? Cleanup removes ALL docker volumes and all COSMOS data! [Y/N]? + if /I "!c!" EQU "Y" goto :cleanup_y + if /I "!c!" EQU "N" goto :EOF +goto :try_cleanup :cleanup_y docker compose -f compose.yaml down -t 30 -v + + if "%2" == "local" ( + SET "sourcedir=plugins\DEFAULT" + FOR /d %%a IN ("%sourcedir%\*") DO RD /S /Q "%%a" + FOR %%a IN ("%sourcedir%\*") DO IF /i NOT "%%~nxa"=="README.md" DEL "%%a" + ) @echo off GOTO :EOF @@ -128,7 +138,7 @@ GOTO :EOF @echo * cliroot: run a cli command as the root user ('cli help' for more info) 1>&2 @echo * start: run the docker containers for openc3 1>&2 @echo * stop: stop the running docker containers for openc3 1>&2 - @echo * cleanup: cleanup network and volumes for openc3 1>&2 + @echo * cleanup [local] [force]: cleanup network and volumes for openc3 1>&2 @echo * build: build the containers for openc3 1>&2 @echo * run: run the prebuilt containers for openc3 1>&2 @echo * dev: run openc3 in dev mode 1>&2 diff --git a/openc3.sh b/openc3.sh index a8789d3cb2..4a6039a6bd 100755 --- a/openc3.sh +++ b/openc3.sh @@ -40,7 +40,7 @@ usage() { echo "* cliroot: run a cli command as the root user ('cli help' for more info)" 1>&2 echo "* start: start the docker compose openc3" >&2 echo "* stop: stop the running dockers for openc3" >&2 - echo "* cleanup: cleanup network and volumes for openc3" >&2 + echo "* cleanup [local] [force]: cleanup network and volumes for openc3" >&2 echo "* build: build the containers for openc3" >&2 echo "* run: run the prebuilt containers for openc3" >&2 echo "* dev: run openc3 in a dev mode" >&2 @@ -92,7 +92,8 @@ case $1 in ${DOCKER_COMPOSE_COMMAND} -f compose.yaml down -t 30 ;; cleanup ) - if [ "$2" == "force" ] + # They can specify 'cleanup force' or 'cleanup local force' + if [ "$2" == "force" ] || [ "$3" == "force" ] then ${DOCKER_COMPOSE_COMMAND} -f compose.yaml down -t 30 -v else @@ -104,6 +105,12 @@ case $1 in esac done fi + if [ "$2" == "local" ] + then + cd plugins/DEFAULT + ls | grep -xv "README.md" | xargs rm -r + cd ../.. + fi ;; build ) scripts/linux/openc3_setup.sh