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