|
10 | 10 | exit
|
11 | 11 | fi
|
12 | 12 |
|
13 |
| -if [ -n "${DEVON_IDE_TRACE}" ]; then set -vx; fi |
14 | 13 | # shellcheck source=scripts/functions
|
15 | 14 | source "$(dirname "${0}")"/../functions
|
16 | 15 |
|
17 | 16 | function doSetup() {
|
18 |
| - if command -v az &> /dev/null |
| 17 | + if [ "${1}" != "silent" ] || [[ ! $(command -v az) =~ ${DEVON_IDE_HOME}/software/ ]] |
19 | 18 | then
|
20 |
| - if [ "${1}" != "silent" ] && ! doIsQuiet |
21 |
| - then |
22 |
| - doEcho "Azure CLI is already installed at $(command -v az)" |
23 |
| - fi |
24 |
| - else |
25 |
| - doRequireNotBatch |
26 |
| - if doIsWindows |
27 |
| - then |
28 |
| - # Get leatest release |
29 |
| - if [ -z "${AZ_VERSION}" ] |
30 |
| - then |
31 |
| - doEcho "Getting latest release..." |
32 |
| - AZ_VERSION=$(curl -s https://api.github.com/repos/Azure/azure-cli/releases/latest | awk -F ":" '/tag_name/ {print $2}'| awk -F "\"" '{print $2}' | awk -F "-" '{print $3}') |
33 |
| - fi |
34 |
| - |
35 |
| - doInstall "-" "${AZ_HOME}" "az" "${AZ_VERSION}" |
36 |
| - if [ "${?}" = 0 ] |
37 |
| - then |
38 |
| - doPackageInstall "${AZ_HOME}" |
39 |
| - fi |
40 |
| - fi |
| 19 | + doDevonCommand pip install azure-cli az |
| 20 | + setConfig |
41 | 21 | fi
|
42 |
| -} |
43 |
| - |
44 |
| -function doPackageInstall() { |
45 |
| - local path_to_package="${1}" |
46 |
| - if doIsWindows |
47 |
| - then |
48 |
| - local winPath |
49 |
| - winPath=$(cygpath -w "${path_to_package}") |
50 |
| - powershell.exe -Command "Start-Process msiexec.exe -verb runas -Wait -ArgumentList '/I ${winPath}\az-${AZ_VERSION}-windows.msi /QB-!'" &> /dev/null |
51 |
| - if [ "${?}" = 0 ] |
52 |
| - then |
53 |
| - setConfigDir |
54 |
| - doSuccess "Azure CLI ist installed now. Great! \nTo get started you may need to restart your current shell." |
55 |
| - else |
56 |
| - doError "The setup was canceled or failed. Rerun the setup to install Azure CLI." |
57 |
| - fi |
58 |
| - else |
59 |
| - doFail "Sorry, Azure CLI installation support is not yet implemented for your OS. Please install manually or help devonfw-ide to support it for your OS by contributing a pull-request." |
| 22 | + if [ "${1}" != "silent" ] && ! doIsQuiet |
| 23 | + then |
| 24 | + doRunCommand "az -v" "verify installation of azure cli" |
60 | 25 | fi
|
61 |
| - doRunCommand "rm -rf ${path_to_package}" |
62 | 26 | }
|
63 |
| - |
64 |
| -# Set directory for azure cli configuration file |
65 |
| -function setConfigDir() { |
66 |
| - azureconf_dir="${DEVON_IDE_HOME}/conf/.azure" |
67 |
| - azurecli_export="export AZURE_CONFIG_DIR=${azureconf_dir}" |
68 |
| - if ! grep -q "${azurecli_export}" "${DEVON_IDE_HOME}/conf/devon.properties" |
69 |
| - then |
70 |
| - doRunCommand "${azurecli_export}" |
71 |
| - echo -e "\n${azurecli_export}" >> "${DEVON_IDE_HOME}/conf/devon.properties" |
72 |
| - doEcho "Location of Azure's configuration file is set to ${azureconf_dir}" |
| 27 | + |
| 28 | +function setConfig() { |
| 29 | + local az_config_dir="${DEVON_IDE_HOME}/conf/.azure" |
| 30 | + local az_config_export="export AZURE_CONFIG_DIR=${az_config_dir}" |
| 31 | + if ! grep -q "${az_config_export}" "${DEVON_IDE_HOME}/conf/devon.properties" |
| 32 | + then |
| 33 | + doRunCommand "${az_config_export}" |
| 34 | + echo -e "\n${az_config_export}" >> "${DEVON_IDE_HOME}/conf/devon.properties" |
| 35 | + doEcho "Location of Azure's configuration file is set to ${az_config_dir}" |
73 | 36 | fi
|
74 | 37 | }
|
75 | 38 |
|
76 | 39 | function doRun() {
|
77 | 40 | doSetup silent
|
78 |
| - if command -v az &> /dev/null |
79 |
| - then |
80 |
| - doEcho "Running: Azure CLI ${*}" |
81 |
| - setConfigDir |
82 |
| - az "${@}" |
83 |
| - fi |
| 41 | + doEcho "Running: az ${*}" |
| 42 | + az "${@}" |
84 | 43 | }
|
85 | 44 |
|
86 |
| -AZ_HOME="${DEVON_IDE_HOME}/updates/install/az" |
87 |
| - |
88 |
| -# CLI |
89 | 45 | case ${1} in
|
90 | 46 | "help" | "-h")
|
91 | 47 | echo "Install Azure CLI."
|
92 | 48 | echo
|
93 | 49 | echo "Arguments:"
|
94 |
| - echo " setup install Azure CLI on your machine (global installation)." |
| 50 | + echo " setup install Azure CLI on your machine." |
95 | 51 | echo " <<args>> call Azure CLI with the specified arguments. Call az --help for details or use Azure CLI directly as preferred."
|
96 | 52 | echo
|
97 | 53 | ;;
|
|
0 commit comments