github.com/cptmikhailov/conmon@v2.0.20+incompatible/contrib/cirrus/setup_environment.sh (about)

     1  #!/bin/bash
     2  
     3  set -e
     4  source $(dirname $0)/lib.sh
     5  
     6  req_env_var "
     7      USER $USER
     8      HOME $HOME
     9      ENVLIB $ENVLIB
    10      SCRIPT_BASE $SCRIPT_BASE
    11      CIRRUS_REPO_NAME $CIRRUS_REPO_NAME
    12      CIRRUS_CHANGE_IN_REPO $CIRRUS_CHANGE_IN_REPO
    13      CIRRUS_WORKING_DIR $CIRRUS_WORKING_DIR
    14  "
    15  
    16  [[ "$SHELL" =~ "bash" ]] || chsh -s /bin/bash
    17  
    18  cd "$CIRRUS_WORKING_DIR"  # for clarity of initial conditions
    19  
    20  # Verify basic dependencies
    21  for depbin in gcc rsync sha256sum curl make
    22  do
    23      if ! type -P "$depbin" &> /dev/null
    24      then
    25          echo "***** WARNING: $depbin binary not found in $PATH *****"
    26      fi
    27  done
    28  
    29  # Setup env. vars common to all tasks/scripts/platforms and
    30  # ensure they return for every following script execution.
    31  MARK="# Added by $0, manual changes will be lost."
    32  touch "$HOME/$ENVLIB"
    33  if ! grep -q "$MARK" "$HOME/$ENVLIB"
    34  then
    35      cp "$HOME/$ENVLIB" "$HOME/${ENVLIB}_original"
    36      # N/B: Single-quote items evaluated every time, double-quotes only once (right now).
    37      for envstr in \
    38          "$MARK" \
    39          "export SRC=\"$CIRRUS_WORKING_DIR\"" \
    40          "export OS_RELEASE_ID=\"$(os_release_id)\"" \
    41          "export OS_RELEASE_VER=\"$(os_release_ver)\"" \
    42          "export OS_REL_VER=\"$(os_release_id)-$(os_release_ver)\"" \
    43          "export BUILT_IMAGE_SUFFIX=\"-$CIRRUS_REPO_NAME-${CIRRUS_CHANGE_IN_REPO:0:8}\""
    44      do
    45          # Make permanent in later shells, and set in current shell
    46          X=$(echo "$envstr" | tee -a "$HOME/$ENVLIB") && eval "$X" && echo "$X"
    47      done
    48  
    49      # Do the same for golang env. vars
    50      go env | while read envline
    51      do
    52          X=$(echo "export $envline" | tee -a "$HOME/$ENVLIB") && eval "$X" && echo "$X"
    53      done
    54  
    55      show_env_vars
    56  
    57      # Nothing further required on image-builder VM
    58      if ((IMAGE_BUILD))
    59      then
    60          exit 0
    61      fi
    62  
    63      # Owner/mode may have changed
    64      setup_gopath
    65  
    66      case "$OS_REL_VER" in
    67          fedora-29)
    68              install_testing_deps
    69              build_and_replace_conmon
    70  
    71              cd "$CRIO_SRC"  # cri-o source
    72              echo "Building binaries required for testing"
    73              ooe.sh make test-binaries
    74  
    75              echo "Configuring firewall/networking for integration tests"
    76              ooe.sh iptables -F
    77              ooe.sh iptables -t nat -I POSTROUTING -s 127.0.0.1 ! -d 127.0.0.1 -j MASQUERADE
    78              echo "Setting read_only flag to false"
    79              sudo sed -i 's/read_only = true/read_only = false/g' /etc/crio/crio.conf
    80              echo "Removing nodev flag"
    81              sudo sed -i 's/nodev//g' /etc/containers/storage.conf
    82              iptables -L -n -v
    83              ;;
    84          *) bad_os_id_ver ;;
    85      esac
    86  
    87      # Verify nothing was set empty
    88      # N/B: Some multi-user environment variables are pre-cooked into /etc/environ
    89      #      (see setup_gopath in $SCRIPT_BASE/lib.sh)
    90      req_env_var "
    91          OS_RELEASE_ID $OS_RELEASE_ID
    92          OS_RELEASE_VER $OS_RELEASE_VER
    93          OS_REL_VER $OS_REL_VER
    94          BUILT_IMAGE_SUFFIX $BUILT_IMAGE_SUFFIX
    95      "
    96  fi
    97  
    98  echo "***** TESTING STARTS: $(date --iso-8601=seconds)"