diff --git a/.gitignore b/.gitignore index 7a36284..17988b4 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ # Software repos software embedded +mission9 diff --git a/Makefile b/Makefile index b353a8b..f308eb8 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,15 @@ run-all: ./maav-software/bin/maav-exec clean: - rm -r /software/bin; rm -r /software/lib; cd /software/build && make clean + rm -r /software/bin + rm -r /software/lib + cd /software/build && make clean nuke: - cd; rm -r /software/bin; rm -r /software/lib; rm -r /software/build + cd + rm -r /software/bin + rm -r /software/lib + rm -r /software/build .PHONY: build .PHONY: bash diff --git a/docker-compose.yml b/docker-compose.yml index 7693e5d..39d36bb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3" +version: "2" services: maav-run: @@ -7,4 +7,4 @@ services: - ./software:/software - ${PWD}/Makefile:/Makefile container_name: maav-run - command: "make ${ACTION}" \ No newline at end of file + command: "make ${ACTION}" diff --git a/maav-uninstall.sh b/maav-uninstall.sh new file mode 100755 index 0000000..3ecc2d9 --- /dev/null +++ b/maav-uninstall.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Get directory of the bash script, which is the MAAV directory +MAAV_DIR=$(dirname "$0") + +# Ask for confirmation of uninstallation; make user type "uninstall" +read -p "Are you sure you want to uninstall? Type \"uninstall\": " -r +if [ $REPLY != "uninstall" ] +then + exit 1 +fi + +echo "Starting Uninstall" + +echo "Deleting Software Folder..." +rm -rf $MAAV_DIR/software/ +rm -rf $MAAV_DIR/Software/ + +echo "Deleting Docker image" +docker image rm maav-software diff --git a/maav.sh b/maav.sh index 79a34c9..40dc5c4 100755 --- a/maav.sh +++ b/maav.sh @@ -1,35 +1,41 @@ #!/bin/bash -CMD=$1 +# Set command requested; "help" by default +CMD=${1:-help} + +# Set argument for command; for now, "build" and "run" use an argument ARG=$2 # TODO: read this from ~/.maavrc -MAAV_DIR=/home/rpash/maav +# Set the directory of the MAAV repository on this machine +# Note: this will be the directory of this script +MAAV_DIR=$(dirname "$0") +# Run the built MAAV code function run() { + # Change to the MAAV directory cd $MAAV_DIR - ACTION=$1 docker-compose run --rm maav-run -} -function print_where() { - echo $MAAV_DIR + # Get the action we are running; docker-compose by default + ACTION=${1:-docker-compose run --rm maav-run} + + # TODO Run action } +# Delete the following folders: +# * software/bin - Contains executable files built from source +# * software/lib - Contains MAAV libraries, not third party libraries +# * software/build - Contains build data function nuke() { - if [ -d "$MAAV_DIR/software/bin" ]; then - echo "Removing $MAAV_DIR/software/bin" - rm -r $MAAV_DIR/software/bin - fi - if [ -d "$MAAV_DIR/software/lib" ]; then - echo "Removing $MAAV_DIR/software/lib" - rm -r $MAAV_DIR/software/lib - fi - if [ -d "$MAAV_DIR/software/build" ]; then - echo "Removing $MAAV_DIR/software/build" - rm -r $MAAV_DIR/software/build - fi + echo "Removing $MAAV_DIR/software/bin" + rm -rf $MAAV_DIR/software/bin + echo "Removing $MAAV_DIR/software/lib" + rm -rf $MAAV_DIR/software/lib + echo "Removing $MAAV_DIR/software/build" + rm -rf $MAAV_DIR/software/build } +# Print script usage function print_help() { echo "Usage: maav [command]" echo -e "Commands:" @@ -41,9 +47,13 @@ function print_help() { echo -e "\trun [exe]\tRun a compiled executable" } -if [ $CMD == "help" ]; then - print_help -elif [ $CMD == "where" ]; then +# Print the location of the MAAV directory +function print_where() { + echo $MAAV_DIR +} + +# Read command, and call appropriate function +if [ $CMD == "where" ]; then print_where elif [ $CMD == "build" ]; then run build $ARG @@ -53,4 +63,6 @@ elif [ $CMD == "nuke" ]; then nuke elif [ $CMD == "run" ]; then run $ARG -fi \ No newline at end of file +else + print_help +fi