Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame^] | 3 | usage () |
| 4 | { |
| 5 | cat <<EOF |
| 6 | Usage: run.sh [-y] [-h] Command |
| 7 | Optional arguments: |
| 8 | -y |
| 9 | Skips warning prompt. |
| 10 | -h |
| 11 | Shows help about this program. |
| 12 | -s <suite> |
| 13 | Test suite to use in testing mode. |
| 14 | -c <case> |
| 15 | Test case to use in testing mode. |
| 16 | Commands: |
| 17 | all_in_one Deploy in all-in-one mode. |
| 18 | dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc Deploy chosen service. |
| 19 | testing Deploy in testing mode. |
| 20 | EOF |
| 21 | } |
| 22 | |
| 23 | run=false |
| 24 | test_suite="*" |
| 25 | test_case="*" |
| 26 | |
| 27 | COMMAND=${@: -1} |
| 28 | |
| 29 | while getopts "yhs:c:" OPTION; do |
| 30 | case "$OPTION" in |
| 31 | y) |
| 32 | run=true |
| 33 | ;; |
| 34 | s) |
| 35 | if [ "$COMMAND" != "testing" ] ; then |
| 36 | echo "Test suite should only be specified in testing mode." |
| 37 | echo "./run.sh -h for usage." |
| 38 | exit 0 |
| 39 | fi |
| 40 | test_suite=$OPTARG |
| 41 | ;; |
| 42 | c) |
| 43 | if [ "$COMMAND" != "testing" ] ; then |
| 44 | echo "Test case should only be specified in testing mode." |
| 45 | echo "./run.sh -h for usage." |
| 46 | exit 0 |
| 47 | fi |
| 48 | test_case=$OPTARG |
| 49 | ;; |
| 50 | h) |
| 51 | usage |
| 52 | exit 0 |
| 53 | ;; |
| 54 | esac |
| 55 | done |
| 56 | |
| 57 | case $COMMAND in |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 58 | "all_in_one" ) |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame^] | 59 | export DEPLOY_MODE='all-in-one' |
| 60 | ;; |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 61 | "dns" | "mr" | "sdc" | "aai" | "mso" | "robot" | "vid" | "sdnc" | "portal" | "dcae" | "policy" | "appc" ) |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame^] | 62 | export DEPLOY_MODE='individual' |
| 63 | ;; |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 64 | "testing" ) |
| 65 | export DEPLOY_MODE='testing' |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame^] | 66 | if [ "$run" == false ] ; then |
| 67 | while true ; do |
| 68 | echo "Warning: This test script will delete the contents of ../opt/ and ~/.m2." |
| 69 | read -p "Would you like to continue? [y]es/[n]o: " yn |
| 70 | case $yn in |
| 71 | [Yy]*) |
| 72 | break |
| 73 | ;; |
| 74 | [Nn]*) |
| 75 | echo "Exiting." |
| 76 | exit 0 |
| 77 | ;; |
| 78 | esac |
| 79 | done |
| 80 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 81 | |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame^] | 82 | export TEST_SUITE=$test_suite |
| 83 | export TEST_CASE=$test_case |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 84 | rm -rf ../opt/ |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame^] | 85 | rm -rf ~/.m2/ |
| 86 | ;; |
Victor Morales | 2016306 | 2017-08-09 10:50:44 -0500 | [diff] [blame] | 87 | * ) |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame^] | 88 | usage |
Victor Morales | 2016306 | 2017-08-09 10:50:44 -0500 | [diff] [blame] | 89 | exit 1 |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 90 | esac |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame^] | 91 | |
| 92 | vagrant destroy -f $COMMAND |
| 93 | vagrant up $COMMAND |