Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add local option to cleanup local files #1121

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions openc3.bat
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,24 @@ 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" (
FOR /d %%a IN (%~dp0plugins\DEFAULT\*) DO RD /S /Q "%%a"
FOR %%a IN (%~dp0plugins\DEFAULT\*) DO IF /i NOT "%%~nxa"=="README.md" DEL "%%a"
)
@echo off
GOTO :EOF

Expand Down Expand Up @@ -128,7 +137,7 @@ GOTO :EOF
@echo * cliroot: run a cli command as the root user ('cli help' for more info) 1>&2
@echo * start: build and run 1>&2
@echo * stop: stop the containers (compose stop) 1>&2
@echo * cleanup: REMOVE volumes / data (compose down -v) 1>&2
@echo * cleanup [local] [force]: REMOVE volumes / data (compose down -v) 1>&2
@echo * build: build the containers (compose build) 1>&2
@echo * run: run the containers (compose up) 1>&2
@echo * dev: run using compose-dev 1>&2
Expand Down
11 changes: 9 additions & 2 deletions openc3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ usage() {
echo "* cliroot: run a cli command as the root user ('cli help' for more info)" 1>&2
echo "* start: build and run" >&2
echo "* stop: stop the containers (compose stop)" >&2
echo "* cleanup: REMOVE volumes / data (compose down -v)" >&2
echo "* cleanup [local] [force]: REMOVE volumes / data (compose down -v)" >&2
echo "* build: build the containers (compose build)" >&2
echo "* run: run the containers (compose up)" >&2
echo "* dev: run using compose-dev" >&2
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading