From f27b60586c654322653adfcac30abb680c63b976 Mon Sep 17 00:00:00 2001 From: Karl Bishop Date: Sat, 6 Jan 2018 12:45:34 -0500 Subject: [PATCH 01/11] Many major enhancements to both installers --- README.md | 23 +- idt_release_notes.md | 12 + linux-installer/README.md | 57 ++-- linux-installer/idt-installer | 406 ++++++++++++------------ windows-installer/idt-win-installer.ps1 | 108 ++++--- 5 files changed, 316 insertions(+), 290 deletions(-) diff --git a/README.md b/README.md index 0a1004c..de9020e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # IBM Cloud Developer Tools [![](https://img.shields.io/badge/IBM%20Cloud-powered-blue.svg)](https://bluemix.net) -![Platform](https://img.shields.io/badge/platform-BASH-lightgrey.svg?style=flat) -![Platform](https://img.shields.io/badge/platform-PowerShell-lightgrey.svg?style=flat) This repo provides support for the IBM Cloud Developer Tools (IDT) CLI environment. The IDT tools currently consists of the IBM Cloud CLI (bx) 'dev' and other plugins, as well as extensions to multiple IDEs. @@ -12,7 +10,7 @@ These tools work for the following environments: - [IBM **Cloud** Dedicated](https://www.ibm.com/cloud-computing/bluemix/dedicated) - [IBM MicroService Builder](https://developer.ibm.com/microservice-builder/) -If you run into any issues, please let us know on the [IBM Cloud Tech Slack :: #developer-tools](https://slack-invite-ibm-cloud-tech.mybluemix.net/) or file an issue on our [GitHub repo](https://github.com/IBM-Bluemix/ibm-cloud-developer-tools). +If you run into any issues, please let us know on the [IBM Cloud Tech Slack :: #developer-tools](https://slack-invite-ibm-cloud-tech.mybluemix.net/) or file an issue on our [GitHub repo](https://github.com/IBM-Cloud/ibm-cloud-developer-tools). @@ -24,19 +22,10 @@ The following command will install the IBM Cloud Developer Tools in a single inv $ curl -sL https://ibm.biz/idt-installer | bash ``` -By default, this installer will use the 'brew' installer on MacOS, if available. If you explicitly do not want to use brew, execute the following command using the `--nobrew` option: - -``` -curl -sL https://ibm.biz/idt-installer | bash -s -- --nobrew -``` - -Once complete, there will be three aliases defined to access the IBM Cloud Developer Tools: -- `idt` : Main command line tool. Shorthand for standard 'bx dev' command -- `idt-update` : Update your IBM Cloud Developer Tools to the latest versions -- `idt-uninstall` : Uninstall the IBM Cloud Developer Tools - -Note: In order to access these aliases, you need to either restart your terminal session, -or reload your bash env (ie `. ~/.bashrc`) +Once complete, there will be three shortcuts defined to access the IBM Cloud Developer Tools: +- `idt` : Main command line tool. Shorthand for 'bx dev' command +- `idt update` : Update your IBM Cloud Developer Tools to the latest versions +- `idt uninstall` : Uninstall the IBM Cloud Developer Tools Access the [platform-specific readme](./linux-installer/README.md) for additional details. @@ -70,5 +59,5 @@ Notice: These extensions are provided "as-is". IBM does not explicitly endorse, We can be reached in the following ways. We encourage and welcome all feedback and suggestions - [IBM Cloud Tech Slack](https://slack-invite-ibm-cloud-tech.mybluemix.net/): Find us on the `#developer-tools` channel -- [IBM Cloud Developer Tools GitHub repo](https://github.com/IBM-Cloud/ibm-cloud-developer-tools): Use to file any issues specific to installation of the tools +- [IBM Cloud Developer Tools GitHub repo](https://github.com/IBM-Cloud/ibm-cloud-developer-tools): Use to file any issues specific to installation of the tools or the IDE extensions. diff --git a/idt_release_notes.md b/idt_release_notes.md index bf942ed..0f8b006 100644 --- a/idt_release_notes.md +++ b/idt_release_notes.md @@ -1,3 +1,15 @@ + +## v1.1.0 Dec 13, 2017 +- Integrate DevOps (CF or Kube) during app creation +- Use Docker Compose to Develop a Multi-Container Application +- Launch a Deployed Web Application with View +- Access Local Containers with Shell +- Improved Create Interaction +- Usability Improvements +- and bug fixes + +You can read about this new release here: https://www.ibm.com/blogs/bluemix/2017/12/whats-included-ibm-cloud-developer-tools-cli-version-1-1-0/ + ## v1.0.8 Oct 26, 2018 - modifies the `bx dev console` command for the new location of projects due to the app-services changes to the Public Cloud console. diff --git a/linux-installer/README.md b/linux-installer/README.md index 5705549..aa1166a 100644 --- a/linux-installer/README.md +++ b/linux-installer/README.md @@ -19,7 +19,7 @@ ## Summary -This script performs an installation of the IBM Developer Tools CLI environment. The IDT is a plugin to the IBM Bluemix CLI. Our general target environment is the IBM Cloud, including public, dedicated, and local hybrid. +This script performs an installation of the IBM Developer Tools CLI environment. The IDT consists of the 'dev' (and several other) plugins to the IBM Cloud CLI. Our general target environment is the IBM Cloud, including public, dedicated, and local hybrid. ## Installation @@ -29,18 +29,16 @@ Before running the installation script, you should set this environment variable export DESIRED_VERSION=v2.4.2 ``` -To install the IBM Developer Tools CLI, run the following command: +To install the IBM Cloud Developer Tools CLI, run the following command: ``` $ curl -sL https://ibm.biz/idt-installer | bash ``` -Once complete, there will be three aliases defined to access the IDT: -- `idt` : Main command line tool for IBM cloud native development (shortcut to 'bx dev') -- `idt-update` : Update your IDT environment to the latest versions -- `idt-uninstall` : Uninstall the IBM Developer Tools - -Note: You will need to either restart your terminal session, or reload your bash environment (ie `. ~/.bashrc`) to access these commands. +Once complete, there will be three added shortcuts defined to access the IDT: +- `idt` : Main command line tool for IBM cloud native development (shortcut to 'bx dev' command) +- `idt update` : Update your IDT environment to the latest versions +- `idt uninstall` : Uninstall the IBM Developer Tools ### Debugging @@ -51,18 +49,25 @@ If you have any issues with the instaler, try running with the `--trace` argumen curl -sL https://ibm.biz/idt-installer | bash -s -- --trace ``` +If updating an existing IDT installation, you can run the following: +``` +idt update --trace +``` + ## Updating -If you wish to update the IBM Developer Tools CLI, run `idt-update`. This command is simply an alias defined during initial install that runs the installer shown here: +If you wish to update the IBM Developer Tools CLI, run `idt update`. There is also a `--force` (or `-f`) argument that will force update to all dependencies too. + +This command is simply an alias defined during initial install that runs the installer shown here: ``` -$ curl -sL https://ibm.biz/idt-installer | bash +$ curl -sL https://ibm.biz/idt-installer | bash -c -- [--force] ``` ## Uninstall -If you wish to remove the IBM Developer Tools CLI, run `idt-uninstall`. This command is simply an alias defined during install that runs the following: +If you wish to remove the IBM Developer Tools CLI, run `idt uninstall`. This command is simply an alias defined during install that runs the following: ``` $ curl -sL https://ibm.biz/idt-installer | bash -s uninstall @@ -75,6 +80,7 @@ The script will check for the following prereqs, and attempt to install them if - Git command line - Docker command line - Kubernetes CLI (kubectl) +- Kubernetes helm ## Usage @@ -85,7 +91,7 @@ Where is: install [Default] Perform full install (or update) of all needed CLIs and Plugins uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins help | -h | -? Show this help - --nobrew Force not using brew installer on MacOS + --force | -f Force updates of dependencies and other settings during update --trace Eanble verbose tracing of all activity @@ -95,14 +101,14 @@ If "install" (or no action provided), a full CLI installation (or update) will o 3. Install all required plugins 4. Defines aliases to improve useability - idt : Shortcut for normal "bx dev" command - - idt-update : Runs this installer checking for and installing any updates - - idt-uninstall : Uninstalls 'bx cli' and all plugins + - idt update : Runs this installer checking for and installing any updates + - idt uninstall : Uninstalls IDT, including the 'bx cli' and all plugins If "uninstall", the IBM Cloud CLI and plugins are removed from the system, including personal metadata. Note: Pre-req CLIs listed above are NOT uninstalled. -Chat with us on Slack: https://ibm.biz/IBMCloudNativeSlack -Submit any issues to : https://github.com/ibm-cloud-tools/idt-installer +Chat with us on Slack: https://slack-invite-ibm-cloud-tech.mybluemix.net/ +Submit any issues to : https://github.com/IBM-Cloud/ibm-cloud-developer-tools/issues ``` @@ -110,13 +116,18 @@ Submit any issues to : https://github.com/ibm-cloud-tools/idt-installer The following are platform specific concerns and notes you should be aware of. +Note: Previous versions of this installer set up aliases within you shell env (ie ~/.bashrc). Current version have switched over to use a wrapper shell scripty (/usr/local/bin/idt) to achieve better results. The old env entries are automatically removed. + + ### MacOS -By default, this installer will use the 'brew' installer if it is available. You can use the `--nobrew` argument to disable use of 'brew'. Note that you must be consistent with the use of `--nobrew` when installing, updating, and uninstalling. +The installer uses the "homebrew" utility, and it will be installed as needed. ### Linux -This script has only been tested on Ubuntu Linux systems, although it should behave properly on other distros. If you run into any issues, please let us know on [Slack](https://ibm.biz/IBMCloudNativeSlack) or file an issue on our [GitHub repo](https://github.com/ibm-cloud-tools/idt-installer). +This script has only been tested on Ubuntu Linux systems, although it should behave properly on other distros that use 'apt-get'. + +If you run into any issues, please let us know on [IBM Cloud Tech Slack](https://slack-invite-ibm-cloud-tech.mybluemix.net/) - #developer-tools channel, or file an issue on our [GitHub repo](https://github.com/IBM-Cloud/ibm-cloud-developer-tools/issues). ### Windows @@ -127,13 +138,5 @@ This script has only been tested on Ubuntu Linux systems, although it should beh ## Internal IBM users -IBM users can utilize this installer pulling the Bluemix CLI and plugins from pre-release internal servers. In order to have the installer utilize internal servers, set the following environment variables (eg in `~/.bashrc`), substituting the proper internal URLs. Shown below are the default public URLs: - -``` -export IDT_INSTALL_USE_PROD=true -export IDT_INSTALL_BMX_URL="https://clis.ng.bluemix.net/install" -export IDT_INSTALL_BMX_REPO_NAME="internal" -export IDT_INSTALL_BMX_REPO_URL="https://plugins.ng.bluemix.net" -``` +IBM users can use pre-release versions of the IDT (bx and all plugins). The installer will check if you have the internal "stage1" plugin repo defined, and ask if you want to use it for updates. Note: Since during initial install of the bx CLI does not have extra plugin repos defined, it only applies during subsequent updates. -If you need assistance on the proper values, just ask in any of the IBM internal slack channels. diff --git a/linux-installer/idt-installer b/linux-installer/idt-installer index 10a8d22..19c3bb2 100755 --- a/linux-installer/idt-installer +++ b/linux-installer/idt-installer @@ -4,43 +4,17 @@ #------------------------------------------------------------------------------ # IBM Cloud Developer Tools - CLI installer script for MacOS and Linux systems #------------------------------------------------------------------------------ -# Copyright (c) 2017, International Business Machines. All Rights Reserved. +# Copyright (c) 2018, International Business Machines. All Rights Reserved. #------------------------------------------------------------------------------ -VERSION="1.1.0" +VERSION="1.2.0" PROG="IBM Cloud Developer Tools - Installer" INSTALLER_URL="https://ibm.biz/idt-installer" GIT_URL="https://github.com/IBM-Cloud/ibm-cloud-developer-tools" SLACK_URL="https://slack-invite-ibm-cloud-tech.mybluemix.net/" -DEFAULT_BMX_URL="https://clis.ng.bluemix.net/install" - -# Only use sudo if not running as root: -[ "$(id -u)" -ne 0 ] && SUDO=sudo || SUDO="" - -if [[ "$IDT_INSTALL_USE_PROD" != false ]]; then - unset IDT_INSTALL_BMX_URL IDT_INSTALL_BMX_REPO_NAME IDT_INSTALL_BMX_REPO_URL -fi -IDT_INSTALL_BMX_URL="${IDT_INSTALL_BMX_URL:=$DEFAULT_BMX_URL}" -IDT_INSTALL_BMX_REPO_NAME="${IDT_INSTALL_BMX_REPO_NAME:=Bluemix}" -IDT_INSTALL_BMX_REPO_URL="${IDT_INSTALL_BMX_REPO_URL:=https://plugins.ng.bluemix.net}" - -#-- External programs, format is "binary, curl, install url" -EXT_PROGS=( - "git,git,https://git-scm.com/downloads" - "docker,docker,https://docs.docker.com/engine/installation/" - "kubectl,kubectl,https://kubernetes.io/docs/tasks/tools/install-kubectl/" - "helm,kubernetes-helm,https://github.com/kubernetes/helm/blob/master/docs/install.md" -) - -#-- BX plugins to process -PLUGINS=( - "Cloud-Functions" - "container-registry" - "container-service" - "dev" - "schematics" - "sdk-gen" -) +IDT_INSTALL_BMX_URL="https://clis.ng.bluemix.net/install" +IDT_INSTALL_BMX_REPO_NAME="Bluemix" +IDT_INSTALL_BMX_REPO_URL="https://plugins.ng.bluemix.net" #------------------------------------------------------------------------------ function help { @@ -49,28 +23,25 @@ function help { Usage: ${PROG} [] Where is: - install [Default] Perform full install (or update) of all needed CLIs and Plugins + install [Default] Perform full install (or update) of all needed CLIs and Plugins uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins help | -h | -? Show this help - --nobrew Force not using 'brew' installer on MacOS + --force | -f Force updates of dependencies and other settings during update --trace Eanble verbose tracing of all activity If "install" (or no action provided), a full CLI installation (or update) will occur: 1. Pre-req check for 'git', 'docker', 'kubectl', and 'helm' 2. Install latest IBM Cloud 'bx' CLI 3. Install all required plugins - 4. Defines aliases to improve useability - - idt : Shortcut for normal "bx dev" command - - idt-update : Runs this installer checking for and installing any updates - - idt-uninstall : Uninstalls 'bx cli' and all plugins - - If "uninstall", the IBM Cloud CLI and plugins are removed from the system, including personal metadata. - Note: Pre-req CLIs listed above are NOT uninstalled. + 4. Defines 'idt' shortcut to improve useability. + - idt : Shortcut for normal "bx dev" command + - idt update : Runs this installer checking for and installing any updates + - idt uninstall : Uninstalls IDT, 'bx' cli, and all plugins Chat with us on Slack: ${SLACK_URL}, channel #developer-tools Submit any issues to : ${GIT_URL}/issues -!!EOF + !!EOF } @@ -122,10 +93,6 @@ function uninstall { warn "Starting Uninstall..." [ "$SUDO" ] && log "You may be prompted for 'sudo' password." - log "Removing IBM Cloud 'bx' CLI..." - if [[ "${PLATFORM}" == "Darwin" && "$USEBREW" == true ]]; then - brew cask uninstall "bluemix-cli" - fi #-- Run the following regardless $SUDO rm -f /usr/local/bin/bluemix $SUDO rm -f /usr/local/bin/bx @@ -160,114 +127,151 @@ function uninstall { #------------------------------------------------------------------------------ function install { log "Starting Full Installation..." + + #-- Check if internal IBM setup + if [[ -n "$(which bx)" ]]; then + read -r repo url <<< $(bx plugin repos | grep stage1) + if [[ -n "$repo" ]]; then + echo + prompt "Use IBM internal '$repo' repos for install/updates (Y/n)?" + echo + if [[ "$REPLY" == [Yy]* ]]; then + IDT_INSTALL_BMX_URL="https://clis.stage1.ng.bluemix.net/install" + IDT_INSTALL_BMX_REPO_NAME="${repo}" + IDT_INSTALL_BMX_REPO_URL="${url}" + fi + fi + fi [ "$SUDO" ] && log "Note: You may be prompted for your 'sudo' password during install." + install_deps install_bx install_plugins env_setup add - log "Install finished." -} -#------------------------------------------------------------------------------ -function warn_unsupported { - warn "Only MacOS and Linux systems are supported by this installer." - warn "For Windows, please follow manual installation instructions at:" - warn "${GIT_URL}" - error "Unsupported platform: ${PLATFORM}" + log "Install finished." } #------------------------------------------------------------------------------ function install_deps { - has_error=false #-- check for/install brew for macos - if [[ "$PLATFORM" == "Darwin" && "$USEBREW" != false ]]; then + case "$PLATFORM" in + "Darwin") + log "Checking for external dependency: brew" if [[ -z "$(which brew)" && -n "$(which ruby)" ]]; then - warn "'brew' installer not found, attempting to install..." + log "'brew' installer not found, attempting to install..." ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" log "'brew' installation completed." fi - fi - [[ -z "$(which brew)" ]] && USEBREW=false + if [[ "$FORCE" == true ]]; then + log "Updating 'brew'..." + brew update + fi + + #-- Xcode and Cocoapods + log "Checking if Xcode is installed" + if [[ -z "$(ls -d /Applications/Xcode*.zpp)" ]]; then + log "Xcode does not appear to be installed on this system." + fi + log "Installing/updating external dependency: cocoapods" + if [[ -z "$(gem list --local | grep "^cocoapods ")" || "$FORCE" == true ]]; then + $SUDO gem install cocoapods + fi + + #-- GIT: + log "Installing/updating external dependency: git" + if [[ -z "$(which git)" ]]; then + brew install git + log "Please review any setup requirements for 'git' from: https://git-scm.com/downloads" + elif [[ "$FORCE" == true ]]; then + brew upgrade git + fi + + #-- Docker: + log "Installing/updating external dependency: docker" + if [[ -z "$(which docker)" ]]; then + brew install docker + log "Please review any setup requirements for 'docker' from: https://docs.docker.com/engine/installation/" + elif [[ "$FORCE" == true ]]; then + brew upgrade docker + fi + + #-- kubectl: + log "Installing/updating external dependency: kubectl" + if [[ -z "$(which kubectl)" ]]; then + brew install kubectl + log "Please review any setup requirements for 'kubectl' from: https://kubernetes.io/docs/tasks/tools/install-kubectl/" + elif [[ "$FORCE" == true ]]; then + brew upgrade kubectl + fi + + #-- helm: + log "Installing/updating external dependency: helm" + if [[ -z "$(which helm)" ]]; then + brew install kubernetes-helm + log "Please review any setup requirements for 'helm' from: https://github.com/kubernetes/helm/blob/master/docs/install.md" + elif [[ "$FORCE" == true ]]; then + brew upgrade kubernetes-helm + fi + ;; + + + "Linux") + log "Checking for and updating 'apt-get' support on Linux" + if [[ -z "$(which apt-get)" ]]; then + error "'apt-get' is not found. Thats the only linux installer I know, sorry." + fi + if [[ -z "$(which add-apt-repository)" ]]; then + $SUDO apt-get install -y software-properties-common python-software-properties + fi + $SUDO add-apt-repository -y ppa:git-core/ppa + $SUDO apt-get -y update - # Install curl if not already installed. - if ! $(which curl >/dev/null 2>&1); then - if [ "$PLATFORM" = Linux ]; then - $SUDO apt-get -y update + #-- CURL: + log "Installing/updating external dependency: curl" + if [[ -z "$(which curl)" || "$FORCE" == true ]]; then $SUDO apt-get -y install curl fi - fi + #-- GIT: + log "Installing/updating external dependency: git" + if [[ -z "$(which git)" || "$FORCE" == true ]]; then + $SUDO apt-get -y install git + log "Please review any setup requirements for 'git' from: https://git-scm.com/downloads" + fi - for item in "${EXT_PROGS[@]}"; do - #-- Parse array item into vars - IFS="," read -r prog_bin prog_brew prog_url <<< "$item" - log "Checking for external dependency: ${prog_bin}" - if [[ -z "$(which "$prog_bin")" ]]; then - log "${prog_bin} not found, attempting to install..." - if [[ "$PLATFORM" == "Darwin" && "$USEBREW" == true ]]; then - brew install "$prog_brew" - log "You should review any setup requirements for '${prog_bin}' from: ${prog_url}" - elif [[ "$prog_bin" == "git" ]]; then - if [[ -n "$(which "apt-get")" ]]; then - # Get up-to-date git. - $SUDO apt-get -y update - - # Make sure add-apt-repository is installed. - if ! $(which add-apt-repository >/dev/null 2&>1); then - $SUDO apt-get install -y software-properties-common python-software-properties - fi - $SUDO add-apt-repository -y ppa:git-core/ppa - $SUDO apt-get -y update - $SUDO apt-get -y install git - log "Review any setup requirements for '${prog_bin}' from: ${prog_url}" - else - warn_unsupported - fi - elif [[ "$prog_bin" == "docker" ]]; then - case $PLATFORM in - "Linux") - curl -fsSL get.docker.com | $SUDO sh - - if [ "$SUDO" ]; then - # Allow docker to run as a non-root user (if not running as root). - sudo groupadd docker - sudo usermod -aG docker $USER - else - log 'If you want to run docker without sudo run: "sudo groupadd docker && sudo usermod -aG docker $USER"' - fi - log "Review any setup requirements for '${prog_bin}' from: ${prog_url}" - ;; - *) - warn_unsupported - ;; - esac - log "Review any setup requirements for '${prog_bin}' from: ${prog_url}" - elif [[ "$prog_bin" == "kubectl" ]]; then - case $PLATFORM in - "Linux") - curl --progress-bar -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl - ;; - "Darwin") - curl --progress-bar -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl - ;; - *) - warn_unsupported - ;; - esac - chmod +x ./kubectl - $SUDO mv ./kubectl /usr/local/bin/kubectl - log "Review any setup requirements for '${prog_bin}' from: ${prog_url}" - elif [[ "$prog_bin" == "helm" ]]; then - curl -fsSL https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash - log "Review any setup requirements for '${prog_bin}' from: ${prog_url}" + #-- Docker: + log "Installing/updating external dependency: docker" + if [[ -z "$(which docker)" || "$FORCE" == true ]]; then + curl -fsSL get.docker.com | $SUDO sh - + if [ "$SUDO" ]; then + # Allow docker to run as a non-root user (if not running as root). + sudo groupadd docker 2>/dev/null + sudo usermod -aG docker $USER 2>/dev/null else - warn "Unable to automatically install '${prog_bin}'" - log "You must manually install '${prog_bin}' from: ${prog_url}" - has_error=true + log 'If you want to run docker without sudo run: "sudo groupadd docker && sudo usermod -aG docker $USER"' fi + log "Please review any setup requirements for 'docker' from: https://docs.docker.com/engine/installation/" fi - done - if [[ "$has_error" == true ]]; then - error "One or more prereqs are missing. You must install these prior to using re-running this utility" - fi + + #-- kubectl: + log "Installing/updating external dependency: kubectl" + if [[ -z "$(which kubectl)" || "$FORCE" == true ]]; then + curl --progress-bar -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl + $SUDO mv ./kubectl /usr/local/bin/kubectl + $SUDO chmod +x /usr/local/bin/kubectl + log "Please review any setup requirements for 'kubsctl' from: https://kubernetes.io/docs/tasks/tools/install-kubectl/" + fi + + #-- helm: + log "Installing/updating external dependency: helm" + if [[ -z "$(which helm)" || "$FORCE" == true ]]; then + curl -fsSL https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash + log "Please review any setup requirements for 'helm' from: https://github.com/kubernetes/helm/blob/master/docs/install.md" + fi + + ;; + esac + } #------------------------------------------------------------------------------ @@ -276,13 +280,8 @@ function install_bx { log "Installing IBM Cloud 'bx' CLI for platform '${PLATFORM}'..." case "$PLATFORM" in "Darwin") - #-- Only use BREW if using default bluemix URL (not an internal url) - if [[ "$USEBREW" == true && "$IDT_INSTALL_BMX_REPO_NAME" == "Bluemix" ]]; then - brew cask reinstall "caskroom/cask/bluemix-cli" - else - log "Downloading and installing IBM Cloud 'bx' CLI from: ${IDT_INSTALL_BMX_URL}/osx" - sh <(curl -fsSL ${IDT_INSTALL_BMX_URL}/osx) - fi + log "Downloading and installing IBM Cloud 'bx' CLI from: ${IDT_INSTALL_BMX_URL}/osx" + sh <(curl -fsSL ${IDT_INSTALL_BMX_URL}/osx) ;; "Linux") log "Downloading and installing IBM Cloud 'bx' CLI from: ${IDT_INSTALL_BMX_URL}/linux" @@ -300,11 +299,17 @@ function install_bx { #------------------------------------------------------------------------------ function install_plugins { + #-- BX plugins to process + PLUGINS=( + "Cloud-Functions" + "container-registry" + "container-service" + "dev" + "schematics" + "sdk-gen" + ) + log "Installing / updating required plugins..." - if [[ -z "$(bx plugin repos | grep ${IDT_INSTALL_BMX_REPO_NAME})" ]]; then - log "Adding repo definition for: ${IDT_INSTALL_BMX_REPO_NAME} >> ${IDT_INSTALL_BMX_REPO_URL}" - bx plugin repo-add "${IDT_INSTALL_BMX_REPO_NAME}" "${IDT_INSTALL_BMX_REPO_URL}" - fi for plugin in "${PLUGINS[@]}"; do log "Checking status of plugin: ${plugin}" read -r p ver <<< "$(bx plugin list | grep "^${plugin} ")" @@ -323,61 +328,64 @@ function install_plugins { #------------------------------------------------------------------------------ function env_setup { + idt_prog="/usr/local/bin/idt" env_file="" - show_warn=false + if [[ -f ~/.bashrc ]] ; then env_file=~/.bashrc elif [[ -f ~/.bash_profile ]]; then env_file=~/.bash_profile elif [[ -f ~/.profile ]] ; then env_file=~/.profile - else - env_file=~/.bashrc - warn "Creating new '${env_file}' file to contain aliases" - touch "${env_file}" || error "Failed to create '${env_file}' file!" fi - case "$1" in - "add") - if [[ -z "$(grep 'alias idt="bx dev"' "$env_file")" ]]; then - log "Adding 'idt' aliases to: ${env_file}" - cp -f "$env_file" "$env_file".idt_install_bak || error "Add - Failed to backup file: ${env_file}" - echo '#-- Added by the IDT Installer' >> "$env_file" - echo 'alias idt="bx dev"' >> "$env_file" - if [[ "$PLATFORM" == "Darwin" && "$USEBREW" == false ]]; then - echo 'alias idt-update="curl -sL' "$INSTALLER_URL" '| bash -s -- --nobrew"' >> "$env_file" - echo 'alias idt-uninstall="curl -sL' "$INSTALLER_URL" '| bash -s -- --nobrew uninstall"' >> "$env_file" - else - echo 'alias idt-update="curl -sL' "$INSTALLER_URL" '| bash"' >> "$env_file" - echo 'alias idt-uninstall="curl -sL' "$INSTALLER_URL" '| bash -s uninstall"' >> "$env_file" - fi - show_warn=true - else - log "'idt' aliases are already defined in: ${env_file}" - fi - if [[ -f ~/.bash_profile && -z "$(grep '.bashrc' ~/.bash_profile)" ]]; then - log "Adding '~/.bashrc' loader into '~/.bash_profile'" - echo "# Load .bashrc settings" >> ~/.bash_profile - echo "[ -f ~/.bashrc ] && source ~/.bashrc" >> ~/.bash_profile - fi - log "The following aliases are defined to access the IBM Cloud Developer Tools CLI:" - log " ${GRN}idt${NRM} : Main command line. Shorthand for standard '${CYN}bx dev${NRM}' command" - log " ${GRN}idt-update${NRM} : Update your IBM Cloud Developer Tools to the latest version" - log " ${GRN}idt-uninstall${NRM} : Uninstall the IBM Cloud Developer Tools" - if [[ "$show_warn" == true ]]; then - warn "To access the aliases above, you need to either restart your terminal session," - warn "or reload your bash env (ie '. ${env_file}')" - fi - ;; - "remove") - if [[ -n "$(grep 'alias idt="bx dev"' "$env_file")" ]]; then - log "Removing 'idt' aliases from: ${env_file}" - sed -E -i ".idt_uninstall_bak" \ - -e '/^#-- Added by the IDT Installer$/d' \ - -e '/^alias idt=\"bx dev\"$/d' \ - -e '/^alias idt-update=/d' \ - -e '/^alias idt-uninstall=/d' \ - ${env_file} + + #-- Clear up any old aliases + if [[ -n "$(grep 'alias idt="bx dev"' "$env_file")" ]]; then + log "Removing old 'idt' aliases from: ${env_file}" + sed -E -i ".idt_uninstall_bak" \ + -e '/^#-- Added by the IDT Installer$/d' \ + -e '/^alias idt=\"bx dev\"$/d' \ + -e '/^alias idt-update=/d' \ + -e '/^alias idt-uninstall=/d' \ + ${env_file} + fi + + if [[ "$1" == "add" ]]; then + if [[ ! -f "$idt_prog" || "$FORCE" == true ]]; then + cat <<-!!EOF > ~/idt + #!/bin/bash + #----------------------------------------------------------- + # IBM Cloud Developer Tools (IDT), version ${VERSION} + # Wrapper for the 'bx dev' command, and external helpers. + #----------------------------------------------------------- + # Syntax: + # idt - Run 'bx dev ' + # idt update [--trace] [--force] - Update IDT and deps + # idt uninstall [--trace] - Uninstall IDT + #----------------------------------------------------------- + case "\$1" in + "update") + echo "Updating IBM Cloud Developer Tools (IDT) CLI..." + curl -sL $INSTALLER_URL | bash -s -- \$* + ;; + "uninstall") + echo "Uninstalling IBM Cloud Developer Tools (IDT) CLI..." + curl -sL $INSTALLER_URL | bash -s -- uninstall \$* + ;; + *) + bx dev \$* + esac + #----------------------------------------------------------- + !!EOF + $SUDO mv ~/idt $idt_prog + $SUDO chmod 755 $idt_prog + log "The following shortcuts defined to access the IBM Cloud Developer Tools CLI:" + log " ${GRN}idt${NRM} : Main command, shorthand for '${CYN}bx dev${NRM}'" + log " ${GRN}idt update${NRM} : Update your IBM Cloud Developer Tools to the latest version" + log " ${GRN}idt uninstall${NRM} : Uninstall the IBM Cloud Developer Tools" fi - ;; - *) error "Internal error - called with invalid parameter: ${1}";; - esac + elif [[ "$1" == "remove" ]]; then + $SUDO rm -f $idt_prog + else + error "Internal error - called with invalid parameter: ${1}" + fi } #------------------------------------------------------------------------------ @@ -390,7 +398,9 @@ function main { TMPDIR=${TMPDIR:-"/tmp"} PLATFORM=$(uname) ACTION="" - USEBREW=true + + # Only use sudo if not running as root: + [ "$(id -u)" -ne 0 ] && SUDO=sudo || SUDO="" #-- Parse args while [[ $# -gt 0 ]]; do @@ -399,10 +409,9 @@ function main { warn "Enabling verbose tracing of all activity" set -x ;; - "--nobrew") - USEBREW=false; - warn "Disabling the use of 'brew' for MacOS packages" - log "Note: Ensure you are consistent with this option when installing / updating / uninstalling" + "--force" | "-f") + FORCE=true + warn "Forcing updates for all dependencies and other settings" ;; "install") ACTION="install";; "uninstall") ACTION="uninstall";; @@ -422,7 +431,10 @@ function main { fi ;; *) - warn_unsupported + warn "Only MacOS and Linux systems are supported by this installer." + warn "For Windows, please follow manual installation instructions at:" + warn "${GIT_URL}" + error "Unsupported platform: ${PLATFORM}" ;; esac diff --git a/windows-installer/idt-win-installer.ps1 b/windows-installer/idt-win-installer.ps1 index a472f65..817787a 100644 --- a/windows-installer/idt-win-installer.ps1 +++ b/windows-installer/idt-win-installer.ps1 @@ -1,6 +1,14 @@ -# idt-win-installer -# Installs IBM Developer Bluemix CLI plugin and all dependencies. -# VERSION="0.8" +#------------------------------------------------------------------------------ +# Script: idt-win-installer +#------------------------------------------------------------------------------ +# IBM Cloud Developer Tools - CLI installer script for Windows 10 systems +#------------------------------------------------------------------------------ +# Copyright (c) 2018, International Business Machines. All Rights Reserved. +#------------------------------------------------------------------------------ +$VERSION="1.2.0" +$PROG="IBM Cloud Developer Tools - Installer for Windows" + +echo "--==[ $PROG, v$VERSION ]==--" # Check for Windows 10 if ([System.Environment]::OSVersion.Version.Major -ne 10) @@ -54,75 +62,77 @@ Foreach($i in $EXT_PROGS) { echo "Cannot determine tag" return } - $helm_download_url = "https://storage.googleapis.com/kubernetes-helm/helm-$TAG-windows-amd64.zip" - Invoke-WebRequest $helm_download_url -outfile "helm-$TAG-windows-amd64.zip" + $helm_file = "helm-$TAG-windows-amd64.tar.gz" + $helm_download_url = "https://storage.googleapis.com/kubernetes-helm/$helm_file" + Invoke-WebRequest $helm_download_url -outfile "$helm_file" mkdir "C:\Program Files\helm" - Expand-Archive helm-$TAG-windows-amd64.zip -DestinationPath "C:\Program Files\helm" + Expand-Archive $helm_file -DestinationPath "C:\Program Files\helm" + rm $helm_file # Directly edit the registery to add helm to PATH. Will require a restart to stick. $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" $value = (Get-ItemProperty $regPath -Name Path).Path $newValue = $value+";C:\Program Files\helm\windows-amd64" Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null - rm "helm-$TAG-windows-amd64.zip" } else { echo "$prog_bin install not implemented" } } } -# Install Bluemix CLI. +#-- Install Bluemix CLI. if( get-command bx -erroraction 'silentlycontinue') { echo "bx already installed" + C:\"Program Files"\IBM\Bluemix\bin\bx.exe --version } else { iex(New-Object Net.WebClient).DownloadString("https://clis.ng.bluemix.net/install/powershell") C:\"Program Files"\IBM\Bluemix\bin\bx.exe api api.ng.bluemix.net } -# Install Bluemix CLI Plugins. -$EXT_PLUGINS = "container-registry","container-service","dev","IBM-Containers","schematics" -$EXT_PLUGINS = New-Object System.Collections.ArrayList(,$EXT_PLUGINS) +#-- Install Bluemix CLI Plugins. +$EXT_PLUGINS = "Cloud-Functions","container-registry","container-service","dev","schematics","sdk-gen" $pluginlist = C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin list -# Parse bx plugin list to determine what plugins are installed already. -for ($i=2; $i -lt $pluginlist.length; $i++) { - $item = $pluginlist[$i].split(" ",2) - if($item[0] -match "\bdev\b") { - echo "dev is installed" - $EXT_PLUGINS.remove("dev") - } elseif ($item[0] -match "\bcontainer-registry\b") { - echo "constainer-registry is installed" - $EXT_PLUGINS.remove("container-registry") - } elseif ($item[0] -match "\bcontainer-service\b") { - echo "container-service is installed" - $EXT_PLUGINS.remove("container-service") - } elseif ($item[0] -match "\bIBM-Containers\b") { - echo "IBM-Containers is installed" - $EXT_PLUGINS.remove("IBM-Containers") - } elseif ($item[0] -match "\bschematics\b") { - echo "schematics is installed" - $EXT_PLUGINS.remove("schematics") +Foreach ($plugin in $EXT_PLUGIN) { + if($pluginlist -contains \b$plugin\b) { + echo "Updating plugin: $plugin" + C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install $plugin -r Bluemix + } else { + echo "Installing plugin: $plugin" + C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install $plugin -r Bluemix } } -# Install plugins. -if( $EXT_PLUGINS.contains("Cloud-Functions")) { - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install Cloud-Functions -r Bluemix -} -if( $EXT_PLUGINS.contains("container-registry")) { - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install container-registry -r Bluemix -} -if( $EXT_PLUGINS.contains("container-service")) { - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install container-service -r Bluemix -} -if( $EXT_PLUGINS.contains("schematics")) { - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install schematics -r Bluemix -} -if( $EXT_PLUGINS.contains("dev")) { - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install dev -r Bluemix -} -if( $EXT_PLUGINS.contains("sdk-gen")) { - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install sdk-gen -r Bluemix -} -# Request Restart to save changes to PATH. +#-- Create "idt" script to act as shortcut to "bx dev" +$idt_batch = @" + #----------------------------------------------------------- + # IBM Cloud Developer Tools (IDT), version $VERSION + # Wrapper for the 'bx dev' command, and external helpers. + #----------------------------------------------------------- + # Syntax: + # idt - Run 'bx dev ' + # idt update [--trace] [--force] - Update IDT and deps + # idt uninstall [--trace] - Uninstall IDT + #----------------------------------------------------------- + @ECHO OFF + IF "%1"=="update" ( + echo "Updating IBM Cloud Developer Tools (IDT) CLI..." + PowerShell.exe -ExecutionPolicy Unrestricted -Command "iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')" + ) ELSE IF "%1"=="uninstall" ( + echo "Uninstalling IBM Cloud Developer Tools (IDT) CLI..." + set /P AREYOUSURE=Are you sure you want to unbinstall IDT (Y/N)? + if /I %AREYOUSURE% EQ Y ( + for /d %f in (C:\"Program Files"\IBM\Bluemix*) do rmdir /s/q "%f" + ) + echo "IDT and IBM Cloud CLI have been removed." + ) ELSE ( + bx dev %* + ) + #----------------------------------------------------------- +"@ +echo "$idt_batch" > C:\"Program Files"\IBM\Bluemix\bin\idt.bat + +echo "--==[ Finished ]==--" + +#-- Request Restart to save changes to PATH. $restart = Read-Host "A system restart is required. Would you like to restart now (y/n)? (default is n)" if($restart -eq "y" -Or $restart -eq "yes") { Restart-Computer From a4de41cd4e4974c0e7454b2383e3dcde8677de17 Mon Sep 17 00:00:00 2001 From: Karl Bishop Date: Sat, 6 Jan 2018 13:22:27 -0500 Subject: [PATCH 02/11] cosmetic update to win header --- windows-installer/idt-win-installer.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/windows-installer/idt-win-installer.ps1 b/windows-installer/idt-win-installer.ps1 index 817787a..0611233 100644 --- a/windows-installer/idt-win-installer.ps1 +++ b/windows-installer/idt-win-installer.ps1 @@ -11,16 +11,16 @@ $PROG="IBM Cloud Developer Tools - Installer for Windows" echo "--==[ $PROG, v$VERSION ]==--" # Check for Windows 10 -if ([System.Environment]::OSVersion.Version.Major -ne 10) +if ([System.Environment]::OSVersion.Version.Major -lt 10) { - echo "This installer requires Windows 10." + echo "Error: This installer requires Windows 10 or higher." exit } # Check for 64-bit Platform - Dev and Helm do not have 32-bit versions. if ([Environment]::Is64BitProcess -ne [Environment]::Is64BitOperatingSystem) { - echo "This installer requires 64-bit Windows." + echo "Error: This installer requires 64-bit Windows." exit } @@ -59,7 +59,7 @@ Foreach($i in $EXT_PROGS) { $helm_url = "https://github.com/kubernetes/helm/releases/latest" $TAG = (((Invoke-WebRequest 'https://github.com/kubernetes/helm/releases/latest').Links.outerHTML | Where{$_ -match '/tag/'} | select -first 1).Split('"')[3]).Split("/")[$_.Length-1] if("x$TAG" -eq "x") { - echo "Cannot determine tag" + echo "Error: Cannot determine tag for helm installation" return } $helm_file = "helm-$TAG-windows-amd64.tar.gz" @@ -74,7 +74,7 @@ Foreach($i in $EXT_PROGS) { $newValue = $value+";C:\Program Files\helm\windows-amd64" Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null } else { - echo "$prog_bin install not implemented" + echo "Warning: $prog_bin install not implemented" } } } @@ -133,7 +133,7 @@ echo "$idt_batch" > C:\"Program Files"\IBM\Bluemix\bin\idt.bat echo "--==[ Finished ]==--" #-- Request Restart to save changes to PATH. -$restart = Read-Host "A system restart is required. Would you like to restart now (y/n)? (default is n)" +$restart = Read-Host "A system restart is required. Would you like to restart now (y/N)?" if($restart -eq "y" -Or $restart -eq "yes") { Restart-Computer } From cf6acb06c54223d494ed604c6d2e61514c268c58 Mon Sep 17 00:00:00 2001 From: Karl Bishop Date: Sun, 7 Jan 2018 10:15:19 -0500 Subject: [PATCH 03/11] cleanup for bat file --- windows-installer/idt-win-installer.ps1 | 145 ++++++++++++++---------- 1 file changed, 84 insertions(+), 61 deletions(-) diff --git a/windows-installer/idt-win-installer.ps1 b/windows-installer/idt-win-installer.ps1 index 0611233..91eacdd 100644 --- a/windows-installer/idt-win-installer.ps1 +++ b/windows-installer/idt-win-installer.ps1 @@ -8,46 +8,52 @@ $VERSION="1.2.0" $PROG="IBM Cloud Developer Tools - Installer for Windows" -echo "--==[ $PROG, v$VERSION ]==--" +Write-Output "--==[ $PROG, v$VERSION ]==--" # Check for Windows 10 if ([System.Environment]::OSVersion.Version.Major -lt 10) { - echo "Error: This installer requires Windows 10 or higher." + Write-Output "Error: This installer requires Windows 10 or higher." exit } # Check for 64-bit Platform - Dev and Helm do not have 32-bit versions. if ([Environment]::Is64BitProcess -ne [Environment]::Is64BitOperatingSystem) { - echo "Error: This installer requires 64-bit Windows." + Write-Output "Error: This installer requires 64-bit Windows." exit } # Running as admin defaults to system32 change to home directory. cd ~ + # Install dependencies - git, docker, kubectl, helm. -$EXT_PROGS = "git,https://git-scm.com","docker,https://docs.docker.com/engine/installation","kubectl,https://kubernetes.io/docs/tasks/tools/install-kubectl/","helm,https://github.com/kubernetes/helm/blob/master/docs/install.md" +$reboot = 0 +$EXT_PROGS = "git,https://git-scm.com", + "docker,https://docs.docker.com/engine/installation", + "kubectl,https://kubernetes.io/docs/tasks/tools/install-kubectl/", + "helm,https://github.com/kubernetes/helm/blob/master/docs/install.md" Foreach($i in $EXT_PROGS) { $prog_bin, $prog_url = $i.split(",") - echo "Checking for dependency $prog_bin" + Write-Output "Checking for dependency $prog_bin" if( get-command $prog_bin -erroraction 'silentlycontinue' ) { - echo "$prog_bin already installed" + Write-Output "$prog_bin already installed" } else { - echo "$prog_bin attempting to install..." + $reboot = 1 + Write-Output "$prog_bin attempting to install..." if ($prog_bin -eq "git") { - $gitVersion = (Invoke-WebRequest "https://git-scm.com/downloads/latest").Content - Invoke-WebRequest "https://github.com/git-for-windows/git/releases/download/v$gitVersion.windows.1/Git-$gitVersion-64-bit.exe" -outfile "git-installer.exe" + $gitVersion = (Invoke-WebRequest "https://git-scm.com/downloads/latest" -UseBasicParsing).Content + Invoke-WebRequest "https://github.com/git-for-windows/git/releases/download/v$gitVersion.windows.1/Git-$gitVersion-64-bit.exe" -UseBasicParsing -outfile "git-installer.exe" .\git-installer.exe /SILENT /PathOption="Cmd" | Out-Null rm "git-installer.exe" } elseif ($prog_bin -eq "docker") { - Invoke-WebRequest "https://download.docker.com/win/stable/InstallDocker.msi" -outfile "InstallDocker.msi" + Invoke-WebRequest "https://download.docker.com/win/stable/InstallDocker.msi" -UseBasicParsing -outfile "InstallDocker.msi" msiexec /i InstallDocker.msi /passive | Out-Null } elseif ($prog_bin -eq "kubectl") { - $kube_version = (Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/stable.txt").Content + $kube_version = (Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/stable.txt" -UseBasicParsing).Content $kube_version = $kube_version -replace "`n|`r" - Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/$kube_version/bin/windows/amd64/kubectl.exe" -outfile "kubectl.exe" + Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/$kube_version/bin/windows/amd64/kubectl.exe" -UseBasicParsing -outfile "kubectl.exe" mkdir "C:\Program Files\kubectl" Move-Item -Path "kubectl.exe" -Destination "C:\Program Files\kubectl" # Directly edit the registery to add kubectl to PATH. Will require a restart to stick. @@ -56,84 +62,101 @@ Foreach($i in $EXT_PROGS) { $newValue = $value+";C:\Program Files\kubectl" Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null } elseif ($prog_bin -eq "helm") { - $helm_url = "https://github.com/kubernetes/helm/releases/latest" - $TAG = (((Invoke-WebRequest 'https://github.com/kubernetes/helm/releases/latest').Links.outerHTML | Where{$_ -match '/tag/'} | select -first 1).Split('"')[3]).Split("/")[$_.Length-1] - if("x$TAG" -eq "x") { - echo "Error: Cannot determine tag for helm installation" - return + $helm_url = ((Invoke-WebRequest https://github.com/kubernetes/helm -UseBasicParsing).Links.OuterHTML | Where{$_ -match 'windows-amd64.tar.gz'} | select -first 1).Split('"')[1] + Write-Output "Helm URL : $helm_url" + $helm_file = $helm_url.Split("/")[$_.Length-1] + Write-Output "Helm File: $helm_file" + Invoke-WebRequest $helm_url -UseBasicParsing -outfile "$helm_file" + mkdir "C:\Program Files\helm" -ErrorAction SilentlyContinue + if (-not (Get-Command Expand-7Zip -ErrorAction Ignore)) { + Install-Package -Scope CurrentUser -Force 7Zip4PowerShell > $null } - $helm_file = "helm-$TAG-windows-amd64.tar.gz" - $helm_download_url = "https://storage.googleapis.com/kubernetes-helm/$helm_file" - Invoke-WebRequest $helm_download_url -outfile "$helm_file" - mkdir "C:\Program Files\helm" - Expand-Archive $helm_file -DestinationPath "C:\Program Files\helm" - rm $helm_file + Expand-7Zip $helm_file . + $tar = $helm_file.Replace('.gz','') + Expand-7Zip $tar "C:\Program Files\helm" + rm $helm_file $tar # Directly edit the registery to add helm to PATH. Will require a restart to stick. $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" $value = (Get-ItemProperty $regPath -Name Path).Path $newValue = $value+";C:\Program Files\helm\windows-amd64" Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null } else { - echo "Warning: $prog_bin install not implemented" + Write-Output "Warning: $prog_bin install not implemented" } } } #-- Install Bluemix CLI. +Write-Output "Installing IBM Cloud CLI..." if( get-command bx -erroraction 'silentlycontinue') { - echo "bx already installed" - C:\"Program Files"\IBM\Bluemix\bin\bx.exe --version + Write-Output "bx already installed" + C:\"Program Files"\IBM\Bluemix\bin\bx.exe update } else { iex(New-Object Net.WebClient).DownloadString("https://clis.ng.bluemix.net/install/powershell") C:\"Program Files"\IBM\Bluemix\bin\bx.exe api api.ng.bluemix.net + reboot = 1 } +Write-Output "IBM Cloud CLI version:" +C:\"Program Files"\IBM\Bluemix\bin\bx.exe --version #-- Install Bluemix CLI Plugins. -$EXT_PLUGINS = "Cloud-Functions","container-registry","container-service","dev","schematics","sdk-gen" +Write-Output "Installing/updating IBM Cloud CLI plugins used by IDT..." +$EXT_PLUGINS = "Cloud-Functions", + "container-registry", + "container-service", + "dev", + "schematics", + "sdk-gen" $pluginlist = C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin list -Foreach ($plugin in $EXT_PLUGIN) { - if($pluginlist -contains \b$plugin\b) { - echo "Updating plugin: $plugin" - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install $plugin -r Bluemix +Foreach ($plugin in $EXT_PLUGINS) { + if($pluginlist -match "\b$plugin\b") { + Write-Output "Updating plugin: $plugin" + C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin update $plugin -r Bluemix } else { - echo "Installing plugin: $plugin" + Write-Output "Installing plugin: $plugin" C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install $plugin -r Bluemix } } #-- Create "idt" script to act as shortcut to "bx dev" +Write-Output "Creating 'idt' script to act as shortcut to 'bx dev' command..." $idt_batch = @" - #----------------------------------------------------------- - # IBM Cloud Developer Tools (IDT), version $VERSION - # Wrapper for the 'bx dev' command, and external helpers. - #----------------------------------------------------------- - # Syntax: - # idt - Run 'bx dev ' - # idt update [--trace] [--force] - Update IDT and deps - # idt uninstall [--trace] - Uninstall IDT - #----------------------------------------------------------- - @ECHO OFF - IF "%1"=="update" ( - echo "Updating IBM Cloud Developer Tools (IDT) CLI..." - PowerShell.exe -ExecutionPolicy Unrestricted -Command "iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')" - ) ELSE IF "%1"=="uninstall" ( - echo "Uninstalling IBM Cloud Developer Tools (IDT) CLI..." - set /P AREYOUSURE=Are you sure you want to unbinstall IDT (Y/N)? - if /I %AREYOUSURE% EQ Y ( - for /d %f in (C:\"Program Files"\IBM\Bluemix*) do rmdir /s/q "%f" - ) - echo "IDT and IBM Cloud CLI have been removed." - ) ELSE ( - bx dev %* - ) - #----------------------------------------------------------- +@ECHO OFF +REM #----------------------------------------------------------- +REM # IBM Cloud Developer Tools (IDT), version 1.2.0 +REM # Wrapper for the 'bx dev' command, and external helpers. +REM #----------------------------------------------------------- +REM # Syntax: +REM # idt - Run 'bx dev ' +REM # idt update [--trace] [--force] - Update IDT and deps +REM # idt uninstall [--trace] - Uninstall IDT +REM #----------------------------------------------------------- +IF "%1"=="update" ( + echo Updating IBM Cloud Developer Tools CLI... +REM PowerShell.exe -ExecutionPolicy Unrestricted -Command "iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')" + powershell -noprofile -command "&{ start-process powershell -ArgumentList '-noprofile "iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')" -verb RunAs}" +) ELSE IF "%1"=="uninstall" ( + echo Uninstalling IBM Cloud Developer Tools CLI... +REM set /P AREYOUSURE=Are you sure you want to unbinstall IDT (Y/N)? +REM if /I %AREYOUSURE% EQ Y ( +REM for /d %f in (C:\"Program Files"\IBM\Bluemix*) do rmdir /s/q "%f" +REM ) + echo IDT and IBM Cloud CLI have been removed. +) ELSE ( + bx dev %* +) +REM #----------------------------------------------------------- "@ -echo "$idt_batch" > C:\"Program Files"\IBM\Bluemix\bin\idt.bat +#Write-Output $idt_batch > C:\"Program Files"\IBM\Bluemix\bin\idt.bat +#"bx dev %*" | Out-File -FilePath "C:\Program Files\IBM\Bluemix\bin\idt.bat" -Encoding ascii +Write-Output $idt_batch | Out-File -Encoding ascii "C:\Program Files\IBM\Bluemix\bin\idt.bat" -echo "--==[ Finished ]==--" +Write-Output "--==[ Finished ]==--" #-- Request Restart to save changes to PATH. -$restart = Read-Host "A system restart is required. Would you like to restart now (y/N)?" -if($restart -eq "y" -Or $restart -eq "yes") { - Restart-Computer +if ($reboot -eq 1 ) { + $restart = Read-Host "A system restart is required. Would you like to restart now (y/N)?" + if($restart -eq "y" -Or $restart -eq "yes") { + Restart-Computer + } } From 23b497fb68dd7d733f6db91f81fc068e2c267b25 Mon Sep 17 00:00:00 2001 From: Karl Bishop Date: Sun, 7 Jan 2018 10:18:38 -0500 Subject: [PATCH 04/11] syntax cleanup --- windows-installer/idt-win-installer.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/windows-installer/idt-win-installer.ps1 b/windows-installer/idt-win-installer.ps1 index 91eacdd..2977dc6 100644 --- a/windows-installer/idt-win-installer.ps1 +++ b/windows-installer/idt-win-installer.ps1 @@ -25,7 +25,7 @@ if ([Environment]::Is64BitProcess -ne [Environment]::Is64BitOperatingSystem) } # Running as admin defaults to system32 change to home directory. -cd ~ +Set-Location ~ # Install dependencies - git, docker, kubectl, helm. @@ -46,7 +46,7 @@ Foreach($i in $EXT_PROGS) { $gitVersion = (Invoke-WebRequest "https://git-scm.com/downloads/latest" -UseBasicParsing).Content Invoke-WebRequest "https://github.com/git-for-windows/git/releases/download/v$gitVersion.windows.1/Git-$gitVersion-64-bit.exe" -UseBasicParsing -outfile "git-installer.exe" .\git-installer.exe /SILENT /PathOption="Cmd" | Out-Null - rm "git-installer.exe" + Remove-Item "git-installer.exe" } elseif ($prog_bin -eq "docker") { Invoke-WebRequest "https://download.docker.com/win/stable/InstallDocker.msi" -UseBasicParsing -outfile "InstallDocker.msi" msiexec /i InstallDocker.msi /passive | Out-Null @@ -62,7 +62,7 @@ Foreach($i in $EXT_PROGS) { $newValue = $value+";C:\Program Files\kubectl" Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null } elseif ($prog_bin -eq "helm") { - $helm_url = ((Invoke-WebRequest https://github.com/kubernetes/helm -UseBasicParsing).Links.OuterHTML | Where{$_ -match 'windows-amd64.tar.gz'} | select -first 1).Split('"')[1] + $helm_url = ((Invoke-WebRequest https://github.com/kubernetes/helm -UseBasicParsing).Links.OuterHTML | Where-Object{$_ -match 'windows-amd64.tar.gz'} | Select-Object -first 1).Split('"')[1] Write-Output "Helm URL : $helm_url" $helm_file = $helm_url.Split("/")[$_.Length-1] Write-Output "Helm File: $helm_file" @@ -74,7 +74,7 @@ Foreach($i in $EXT_PROGS) { Expand-7Zip $helm_file . $tar = $helm_file.Replace('.gz','') Expand-7Zip $tar "C:\Program Files\helm" - rm $helm_file $tar + Remove-Item $helm_file $tar # Directly edit the registery to add helm to PATH. Will require a restart to stick. $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" $value = (Get-ItemProperty $regPath -Name Path).Path @@ -92,7 +92,7 @@ if( get-command bx -erroraction 'silentlycontinue') { Write-Output "bx already installed" C:\"Program Files"\IBM\Bluemix\bin\bx.exe update } else { - iex(New-Object Net.WebClient).DownloadString("https://clis.ng.bluemix.net/install/powershell") + Invoke-Expression(New-Object Net.WebClient).DownloadString("https://clis.ng.bluemix.net/install/powershell") C:\"Program Files"\IBM\Bluemix\bin\bx.exe api api.ng.bluemix.net reboot = 1 } @@ -143,7 +143,7 @@ REM for /d %f in (C:\"Program Files"\IBM\Bluemix*) do rmdir /s/q "%f" REM ) echo IDT and IBM Cloud CLI have been removed. ) ELSE ( - bx dev %* + C:\"Program Files"\IBM\Bluemix\bin\bx.exe dev %* ) REM #----------------------------------------------------------- "@ From a79b8f6cec9368fec19d284655a59b2cf33986b6 Mon Sep 17 00:00:00 2001 From: Karl Bishop Date: Sun, 7 Jan 2018 12:40:58 -0500 Subject: [PATCH 05/11] Lots of bat file changes for update/uninstall. needs testing --- linux-installer/README.md | 10 +- linux-installer/idt-installer | 21 +- windows-installer/README.md | 121 +++++++- windows-installer/idt-win-installer.ps1 | 385 +++++++++++++++++------- 4 files changed, 395 insertions(+), 142 deletions(-) diff --git a/linux-installer/README.md b/linux-installer/README.md index aa1166a..1671044 100644 --- a/linux-installer/README.md +++ b/linux-installer/README.md @@ -1,4 +1,4 @@ -# IBM Developer Tools CLI Installer (idt-installer) +# IBM Developer Tools CLI Installer (idt-installer) for Linux and MacOS [![](https://img.shields.io/badge/IBM%20Cloud-powered-blue.svg)](https://bluemix.net) ![Platform](https://img.shields.io/badge/platform-BASH-lightgrey.svg?style=flat) @@ -43,7 +43,7 @@ Once complete, there will be three added shortcuts defined to access the IDT: ### Debugging -If you have any issues with the instaler, try running with the `--trace` argument which will produce verbose output to assist us in diagnosing your problem: +If you have any issues with the installer, try running with the `--trace` argument which will produce verbose output to assist us in diagnosing your problem: ``` curl -sL https://ibm.biz/idt-installer | bash -s -- --trace @@ -57,7 +57,7 @@ idt update --trace ## Updating -If you wish to update the IBM Developer Tools CLI, run `idt update`. There is also a `--force` (or `-f`) argument that will force update to all dependencies too. +If you wish to update the IBM Developer Tools CLI, run `idt update`. There is also a `--force` argument that will force update to all dependencies too. This command is simply an alias defined during initial install that runs the installer shown here: @@ -70,7 +70,7 @@ $ curl -sL https://ibm.biz/idt-installer | bash -c -- [--force] If you wish to remove the IBM Developer Tools CLI, run `idt uninstall`. This command is simply an alias defined during install that runs the following: ``` -$ curl -sL https://ibm.biz/idt-installer | bash -s uninstall +$ curl -sL https://ibm.biz/idt-installer | bash -c -- uninstall ``` @@ -91,7 +91,7 @@ Where is: install [Default] Perform full install (or update) of all needed CLIs and Plugins uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins help | -h | -? Show this help - --force | -f Force updates of dependencies and other settings during update + --force Force updates of dependencies and other settings during update --trace Eanble verbose tracing of all activity diff --git a/linux-installer/idt-installer b/linux-installer/idt-installer index 19c3bb2..2c39a1a 100755 --- a/linux-installer/idt-installer +++ b/linux-installer/idt-installer @@ -8,7 +8,7 @@ #------------------------------------------------------------------------------ VERSION="1.2.0" -PROG="IBM Cloud Developer Tools - Installer" +PROG="IBM Cloud Developer Tools for Linux/MacOS - Installer" INSTALLER_URL="https://ibm.biz/idt-installer" GIT_URL="https://github.com/IBM-Cloud/ibm-cloud-developer-tools" SLACK_URL="https://slack-invite-ibm-cloud-tech.mybluemix.net/" @@ -20,14 +20,15 @@ IDT_INSTALL_BMX_REPO_URL="https://plugins.ng.bluemix.net" function help { cat <<-!!EOF - Usage: ${PROG} [] + ${PROG} + Usage: idt-installer [] Where is: - install [Default] Perform full install (or update) of all needed CLIs and Plugins - uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins - help | -h | -? Show this help - --force | -f Force updates of dependencies and other settings during update - --trace Eanble verbose tracing of all activity + install [Default] Perform full install (or update) of all needed CLIs and Plugins + uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins + help | -h | -? Show this help + --force Force updates of dependencies and other settings during update + --trace Eanble verbose tracing of all activity If "install" (or no action provided), a full CLI installation (or update) will occur: 1. Pre-req check for 'git', 'docker', 'kubectl', and 'helm' @@ -309,7 +310,7 @@ function install_plugins { "sdk-gen" ) - log "Installing / updating required plugins..." + log "Installing/updating IBM Cloud CLI plugins used by IDT..." for plugin in "${PLUGINS[@]}"; do log "Checking status of plugin: ${plugin}" read -r p ver <<< "$(bx plugin list | grep "^${plugin} ")" @@ -317,7 +318,7 @@ function install_plugins { log "Installing plugin '$plugin'" bx plugin install -r "${IDT_INSTALL_BMX_REPO_NAME}" "$plugin" else - log "Attempting to update plugin '$plugin' from version '$ver'" + log "Updating plugin '$plugin' from version '$ver'" bx plugin update -r "${IDT_INSTALL_BMX_REPO_NAME}" "$plugin" fi done @@ -409,7 +410,7 @@ function main { warn "Enabling verbose tracing of all activity" set -x ;; - "--force" | "-f") + "--force") FORCE=true warn "Forcing updates for all dependencies and other settings" ;; diff --git a/windows-installer/README.md b/windows-installer/README.md index 5a6f6b6..2b5d1b5 100644 --- a/windows-installer/README.md +++ b/windows-installer/README.md @@ -1,11 +1,30 @@ -# IBM Developer Windows Installer - -PowerShell script that downloads and installs the IBM Cloud Developer Tools (IDT) CLI Plugin and all of its dependencies on Windows 10 or newer systems. +# IBM Developer Tools CLI Installer (idt-installer) for Windows [![](https://img.shields.io/badge/IBM%20Cloud-powered-blue.svg)](https://bluemix.net) -![Platform](https://img.shields.io/badge/platform-PowerShell-lightgrey.svg?style=flat) +![Platform](https://img.shields.io/badge/platform-Powershell-lightgrey.svg?style=flat) + +### Table of Contents +* [Summary](#summary) +* [Install](#installation) +* [Updating](#updating) +* [Uninstall](#uninstall) +* [Pre-Requisites](#pre-requisites) +* [Usage](#usage) +* [Platform specific concerns](#platforms) + * [MacOS](#macos) + * [Linux](#linux) + * [Windows](#windows) +* [Internal IBM users](#internal-ibm-users) + + +## Summary + +PowerShell script that downloads and installs the IBM Cloud Developer Tools (IDT) CLI Plugin and all of its dependencies on Windows 10 or newer systems. The IDT consists of the 'dev' (and several other) plugins to the IBM Cloud CLI. Our general target environment is the IBM Cloud, including public, dedicated, and local hybrid. + -## Single-line Running +## Installation + +### Single-line Running 1. Open Windows PowerShell by right-clicking and select "Run as Administrator". 2. Run this command: @@ -13,19 +32,99 @@ PowerShell script that downloads and installs the IBM Cloud Developer Tools (IDT Set-ExecutionPolicy Unrestricted; iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer') ``` -## Running from Download +### Running from Download -1. Download or clone this repository. +1. Download the `idt-win-installer.ps1` file, or clone this repository. 2. Open Windows PowerShell by right-clicking and selecting "Run as administrator". -3. Change directory to wherever the `idt-win-installer.ps1` script is. -4. Run the command: +3. Change directory to wherever the `idt-win-installer.ps1` script is located. +4. Run the following commands: ``` Set-ExecutionPolicy Unrestricted +.\idt-win-installer.ps1 ``` -5. Run the command: + +Once completed, and you have rebooted your system (as needed), there will be three added shortcuts defined to access the IDT: +- `idt` : Main command line tool for IBM cloud native development (shortcut to 'bx dev' command) +- `idt update` : Update your IDT environment to the latest versions +- `idt uninstall` : Uninstall the IBM Developer Tools + + +### Debugging + +If you have any issues with the installer, try running with the `--trace` argument which will produce verbose output to assist us in diagnosing your problem: + ``` -.\idt-win-installer.ps1 +Set-ExecutionPolicy Unrestricted +.\idt-win-installer.ps1 --trace +``` + +If updating an existing IDT installation, you can run the following: +``` +idt update --trace +``` + + +## Updating + +If you wish to update the IBM Developer Tools CLI, run `idt update`. There is also a `--force` argument that will force update to all dependencies too. + +This command is simply an alias defined during initial install that runs the installer (in admin mode) as shown here: + +``` +PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted """"iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')"""" """"update"""" """"%2"""" ' -Verb RunAs}" +``` + +## Uninstall + +If you wish to remove the IBM Developer Tools CLI, run `idt uninstall`. This command is simply an alias defined during install that runs the following: + ``` +PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted """"iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')"""" """"uninstall"""" """"%2"""" ' -Verb RunAs}" +``` + + +## Pre-Requisites + +The script will check for the following prereqs, and attempt to install them if not found. +- Git command line +- Docker command line +- Kubernetes CLI (kubectl) +- Kubernetes helm + + +## Usage +``` +Usage: idt-win-installer [] + +Where is: + install [Default] Perform full install (or update) of all needed CLIs and Plugins + uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins + help | -h | -? Show this help + --force Force updates of dependencies and other settings during update + --trace Eanble verbose tracing of all activity + + +If "install" (or no action provided), a full CLI installation (or update) will occur: + 1. Pre-req check for 'git', 'docker', 'kubectl', and 'helm' + 2. Install latest IBM Cloud 'bx' CLI + 3. Install all required plugins + 4. Defines aliases to improve useability + - idt : Shortcut for normal "bx dev" command + - idt update : Runs this installer checking for and installing any updates + - idt uninstall : Uninstalls IDT, including the 'bx cli' and all plugins + +If "uninstall", the IBM Cloud CLI and plugins are removed from the system, including personal metadata. + Note: Pre-req CLIs listed above are NOT uninstalled. + +Chat with us on Slack: https://slack-invite-ibm-cloud-tech.mybluemix.net/ +Submit any issues to : https://github.com/IBM-Cloud/ibm-cloud-developer-tools/issues + +``` + + +## Internal IBM users + +IBM users can use pre-release versions of the IDT (bx and all plugins). The installer will check if you have the internal "stage1" plugin repo defined, and ask if you want to use it for updates. Note: Since during initial install of the bx CLI does not have extra plugin repos defined, it only applies during subsequent updates. ### MacOS & Linux Installation diff --git a/windows-installer/idt-win-installer.ps1 b/windows-installer/idt-win-installer.ps1 index 2977dc6..6ac6082 100644 --- a/windows-installer/idt-win-installer.ps1 +++ b/windows-installer/idt-win-installer.ps1 @@ -8,119 +8,224 @@ $VERSION="1.2.0" $PROG="IBM Cloud Developer Tools - Installer for Windows" -Write-Output "--==[ $PROG, v$VERSION ]==--" +$INSTALLER_URL="https://ibm.biz/idt-win-installer" +$GIT_URL="https://github.com/IBM-Cloud/ibm-cloud-developer-tools" +$SLACK_URL="https://slack-invite-ibm-cloud-tech.mybluemix.net/" +$IDT_INSTALL_BMX_URL="https://clis.ng.bluemix.net/install" +$IDT_INSTALL_BMX_REPO_NAME="Bluemix" +$IDT_INSTALL_BMX_REPO_URL="https://plugins.ng.bluemix.net" -# Check for Windows 10 -if ([System.Environment]::OSVersion.Version.Major -lt 10) -{ - Write-Output "Error: This installer requires Windows 10 or higher." - exit +$FORCE = 0 +$NEEDS_REBOOT = 0 + +#------------------------------------------------------------------------------ +function help { + Write-Output @" + + $PROG + Usage: idt-win-installer [] + + Where is: + install [Default] Perform full install (or update) of all needed CLIs and Plugins + uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins + help Show this help + --force | -f Force updates of dependencies and other settings during update + --trace Eanble verbose tracing of all activity + + If "install" (or no action provided), a full CLI installation (or update) will occur: + 1. Pre-req check for 'git', 'docker', 'kubectl', and 'helm' + 2. Install latest IBM Cloud 'bx' CLI + 3. Install all required plugins + 4. Defines 'idt' shortcut to improve useability. + - idt : Shortcut for normal "bx dev" command + - idt update : Runs this installer checking for and installing any updates + - idt uninstall : Uninstalls IDT, 'bx' cli, and all plugins + + Chat with us on Slack: ${SLACK_URL}, channel #developer-tools + Submit any issues to : ${GIT_URL}/issues + +"@ +} + + +#------------------------------------------------------------------------------ +function log() { + Write-Host "[" $((Get-PSCallStack)[1].Command) "]" -foreground cyan + Write-Host " " $args +} + +function warn() { + Write-Host "[" $((Get-PSCallStack)[1].Command) "]" -foreground cyan + Write-Host "WARN" -foreground yellow + Write-Host ": " $args } -# Check for 64-bit Platform - Dev and Helm do not have 32-bit versions. -if ([Environment]::Is64BitProcess -ne [Environment]::Is64BitOperatingSystem) -{ - Write-Output "Error: This installer requires 64-bit Windows." - exit +function error() { + Write-Host "[" $((Get-PSCallStack)[1].Command) "]" -foreground cyan + Write-Host "ERROR" -foreground red + Write-Host ": " $args + exit -1 +} + +#------------------------------------------------------------------------------ +function uninstall() { + warn "Starting Uninstall..." + +} + +#------------------------------------------------------------------------------ +function install() { + log "Starting Full Installation..." + + #-- Check if internal IBM setup + if( get-command bx -erroraction 'silentlycontinue' ) { + $pluginlist = C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin list + if($pluginlist -match "\bstage\b") { + Write-Output + $reply = Read-Host -Prompt "Use IBM internal repos for install/updates (Y/n)?" + Write-Output + if($reply -match "[Yy]*") { + $IDT_INSTALL_BMX_URL="https://clis.stage1.ng.bluemix.net/install" + $IDT_INSTALL_BMX_REPO_NAME="stage1" + $IDT_INSTALL_BMX_REPO_URL="https://plugins.stage1.ng.bluemix.net" + fi + fi + fi + + install_deps + install_bx + install_plugins + env_setup add + + log "Install finished." + + #-- Request Restart to save changes to PATH. + if ($NEEDS_REBOOT -eq 1 ) { + $restart = Read-Host "A system restart is required. Would you like to restart now (y/N)?" + if($restart -match "[Yy]*" ) { + Restart-Computer + } + } } -# Running as admin defaults to system32 change to home directory. -Set-Location ~ - - -# Install dependencies - git, docker, kubectl, helm. -$reboot = 0 -$EXT_PROGS = "git,https://git-scm.com", - "docker,https://docs.docker.com/engine/installation", - "kubectl,https://kubernetes.io/docs/tasks/tools/install-kubectl/", - "helm,https://github.com/kubernetes/helm/blob/master/docs/install.md" -Foreach($i in $EXT_PROGS) { - $prog_bin, $prog_url = $i.split(",") - Write-Output "Checking for dependency $prog_bin" - if( get-command $prog_bin -erroraction 'silentlycontinue' ) { - Write-Output "$prog_bin already installed" - } else { - $reboot = 1 - Write-Output "$prog_bin attempting to install..." - if ($prog_bin -eq "git") { - $gitVersion = (Invoke-WebRequest "https://git-scm.com/downloads/latest" -UseBasicParsing).Content - Invoke-WebRequest "https://github.com/git-for-windows/git/releases/download/v$gitVersion.windows.1/Git-$gitVersion-64-bit.exe" -UseBasicParsing -outfile "git-installer.exe" - .\git-installer.exe /SILENT /PathOption="Cmd" | Out-Null - Remove-Item "git-installer.exe" - } elseif ($prog_bin -eq "docker") { - Invoke-WebRequest "https://download.docker.com/win/stable/InstallDocker.msi" -UseBasicParsing -outfile "InstallDocker.msi" - msiexec /i InstallDocker.msi /passive | Out-Null - } elseif ($prog_bin -eq "kubectl") { - $kube_version = (Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/stable.txt" -UseBasicParsing).Content - $kube_version = $kube_version -replace "`n|`r" - Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/$kube_version/bin/windows/amd64/kubectl.exe" -UseBasicParsing -outfile "kubectl.exe" - mkdir "C:\Program Files\kubectl" - Move-Item -Path "kubectl.exe" -Destination "C:\Program Files\kubectl" - # Directly edit the registery to add kubectl to PATH. Will require a restart to stick. - $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" - $value = (Get-ItemProperty $regPath -Name Path).Path - $newValue = $value+";C:\Program Files\kubectl" - Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null - } elseif ($prog_bin -eq "helm") { - $helm_url = ((Invoke-WebRequest https://github.com/kubernetes/helm -UseBasicParsing).Links.OuterHTML | Where-Object{$_ -match 'windows-amd64.tar.gz'} | Select-Object -first 1).Split('"')[1] - Write-Output "Helm URL : $helm_url" - $helm_file = $helm_url.Split("/")[$_.Length-1] - Write-Output "Helm File: $helm_file" - Invoke-WebRequest $helm_url -UseBasicParsing -outfile "$helm_file" - mkdir "C:\Program Files\helm" -ErrorAction SilentlyContinue - if (-not (Get-Command Expand-7Zip -ErrorAction Ignore)) { - Install-Package -Scope CurrentUser -Force 7Zip4PowerShell > $null - } - Expand-7Zip $helm_file . - $tar = $helm_file.Replace('.gz','') - Expand-7Zip $tar "C:\Program Files\helm" - Remove-Item $helm_file $tar - # Directly edit the registery to add helm to PATH. Will require a restart to stick. - $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" - $value = (Get-ItemProperty $regPath -Name Path).Path - $newValue = $value+";C:\Program Files\helm\windows-amd64" - Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null - } else { - Write-Output "Warning: $prog_bin install not implemented" - } + +#------------------------------------------------------------------------------ +#-- Install dependencies - git, docker, kubectl, helm. +function install_deps() { + + #-- git + log "Checking for external dependency: git" + if( ! get-command git -erroraction 'silentlycontinue' -or $FORCE -eq 1) { + log "Installing/updating external dependency: git" + $gitVersion = (Invoke-WebRequest "https://git-scm.com/downloads/latest" -UseBasicParsing).Content + Invoke-WebRequest "https://github.com/git-for-windows/git/releases/download/v$gitVersion.windows.1/Git-$gitVersion-64-bit.exe" -UseBasicParsing -outfile "git-installer.exe" + .\git-installer.exe /SILENT /PathOption="Cmd" | Out-Null + Remove-Item "git-installer.exe" + $NEEDS_REBOOT = 1 + log "Install/update completed for: git" + } + + #-- docker + log "Checking for external dependency: docker" + if( ! get-command docker -erroraction 'silentlycontinue' -or $FORCE -eq 1) { + log "Installing/updating external dependency: docker" + Invoke-WebRequest "https://download.docker.com/win/stable/InstallDocker.msi" -UseBasicParsing -outfile "InstallDocker.msi" + msiexec /i InstallDocker.msi /passive | Out-Null + $NEEDS_REBOOT = 1 + log "Install/update completed for: docker" + } + + #-- kubectl + log "Checking for external dependency: kubectl" + if( ! get-command kubectl -erroraction 'silentlycontinue' -or $FORCE -eq 1) { + log "Installing/updating external dependency: kubectl" + $kube_version = (Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/stable.txt" -UseBasicParsing).Content + $kube_version = $kube_version -replace "`n|`r" + Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/$kube_version/bin/windows/amd64/kubectl.exe" -UseBasicParsing -outfile "kubectl.exe" + mkdir "C:\Program Files\kubectl" + Move-Item -Path "kubectl.exe" -Destination "C:\Program Files\kubectl" + # Directly edit the registery to add kubectl to PATH. Will require a restart to stick. + $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" + $value = (Get-ItemProperty $regPath -Name Path).Path + $newValue = $value+";C:\Program Files\kubectl" + Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null + $NEEDS_REBOOT = 1 + log "Install/update completed for: kubectl" + } + + #-- helm + log "Checking for external dependency: helm" + if( ! get-command helm -erroraction 'silentlycontinue' -or $FORCE -eq 1) { + log "Installing/updating external dependency: helm" + $helm_url = ((Invoke-WebRequest https://github.com/kubernetes/helm -UseBasicParsing).Links.OuterHTML | Where-Object{$_ -match 'windows-amd64.tar.gz'} | Select-Object -first 1).Split('"')[1] + Write-Output "Helm URL : $helm_url" + $helm_file = $helm_url.Split("/")[$_.Length-1] + Write-Output "Helm File: $helm_file" + Invoke-WebRequest $helm_url -UseBasicParsing -outfile "$helm_file" + mkdir "C:\Program Files\helm" -ErrorAction SilentlyContinue + if (-not (Get-Command Expand-7Zip -ErrorAction Ignore)) { + Install-Package -Scope CurrentUser -Force 7Zip4PowerShell > $null } + Expand-7Zip $helm_file . + $tar = $helm_file.Replace('.gz','') + Expand-7Zip $tar "C:\Program Files\helm" + Remove-Item $helm_file $tar + # Directly edit the registery to add helm to PATH. Will require a restart to stick. + $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" + $value = (Get-ItemProperty $regPath -Name Path).Path + $newValue = $value+";C:\Program Files\helm\windows-amd64" + Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null + $NEEDS_REBOOT = 1 + log "Install/update completed for: helm" + } } +#------------------------------------------------------------------------------ #-- Install Bluemix CLI. -Write-Output "Installing IBM Cloud CLI..." -if( get-command bx -erroraction 'silentlycontinue') { - Write-Output "bx already installed" - C:\"Program Files"\IBM\Bluemix\bin\bx.exe update -} else { - Invoke-Expression(New-Object Net.WebClient).DownloadString("https://clis.ng.bluemix.net/install/powershell") +function install_bx() { + if( get-command bx -erroraction 'silentlycontinue') { + Write-Output "bx already installed" + bx update + } else { + log "Installing IBM Cloud 'bx' CLI for Windows..." + $url = $IDT_INSTALL_BMX_URL + "/powershell" + log "Downloading and installing IBM Cloud 'bx' CLI from: $url" + Invoke-Expression(New-Object Net.WebClient).DownloadString( $url ) C:\"Program Files"\IBM\Bluemix\bin\bx.exe api api.ng.bluemix.net - reboot = 1 + $NEEDS_REBOOT = 1 + } + log "IBM Cloud CLI version:" + C:\"Program Files"\IBM\Bluemix\bin\bx.exe --version } -Write-Output "IBM Cloud CLI version:" -C:\"Program Files"\IBM\Bluemix\bin\bx.exe --version +#------------------------------------------------------------------------------ #-- Install Bluemix CLI Plugins. -Write-Output "Installing/updating IBM Cloud CLI plugins used by IDT..." -$EXT_PLUGINS = "Cloud-Functions", - "container-registry", - "container-service", - "dev", - "schematics", - "sdk-gen" -$pluginlist = C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin list -Foreach ($plugin in $EXT_PLUGINS) { - if($pluginlist -match "\b$plugin\b") { - Write-Output "Updating plugin: $plugin" - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin update $plugin -r Bluemix - } else { - Write-Output "Installing plugin: $plugin" - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install $plugin -r Bluemix - } +function install_plugins { + log "Installing/updating IBM Cloud CLI plugins used by IDT..." + $EXT_PLUGINS = "Cloud-Functions", + "container-registry", + "container-service", + "dev", + "schematics", + "sdk-gen" + $pluginlist = C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin list + Foreach ($plugin in $EXT_PLUGINS) { + log "Checking status of plugin: $plugin" + if($pluginlist -match "\b$plugin\b") { + log "Updating plugin '$plugin'" + C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin update -r $IDT_INSTALL_BMX_REPO_NAME $plugin + } else { + log "Installing plugin '$plugin'" + C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install -r $IDT_INSTALL_BMX_REPO_NAME $plugin + } + } } +#------------------------------------------------------------------------------ #-- Create "idt" script to act as shortcut to "bx dev" -Write-Output "Creating 'idt' script to act as shortcut to 'bx dev' command..." -$idt_batch = @" +function env_setup() { + Write-Output "Creating 'idt' script to act as shortcut to 'bx dev' command..." + $idt_batch = @" @ECHO OFF REM #----------------------------------------------------------- REM # IBM Cloud Developer Tools (IDT), version 1.2.0 @@ -132,31 +237,79 @@ REM # idt update [--trace] [--force] - Update IDT and deps REM # idt uninstall [--trace] - Uninstall IDT REM #----------------------------------------------------------- IF "%1"=="update" ( - echo Updating IBM Cloud Developer Tools CLI... -REM PowerShell.exe -ExecutionPolicy Unrestricted -Command "iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')" - powershell -noprofile -command "&{ start-process powershell -ArgumentList '-noprofile "iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')" -verb RunAs}" + echo Updating IBM Cloud Developer Tools CLI... + PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted """"iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')"""" """"update"""" """"%2"""" ' -Verb RunAs}" ) ELSE IF "%1"=="uninstall" ( - echo Uninstalling IBM Cloud Developer Tools CLI... -REM set /P AREYOUSURE=Are you sure you want to unbinstall IDT (Y/N)? -REM if /I %AREYOUSURE% EQ Y ( -REM for /d %f in (C:\"Program Files"\IBM\Bluemix*) do rmdir /s/q "%f" -REM ) - echo IDT and IBM Cloud CLI have been removed. + echo Uninstalling IBM Cloud Developer Tools CLI... + PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted """"iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')"""" """"uninstall"""" """"%2"""" ' -Verb RunAs}" + echo IDT and IBM Cloud CLI have been removed. ) ELSE ( - C:\"Program Files"\IBM\Bluemix\bin\bx.exe dev %* + C:\"Program Files"\IBM\Bluemix\bin\bx.exe dev %* ) REM #----------------------------------------------------------- "@ -#Write-Output $idt_batch > C:\"Program Files"\IBM\Bluemix\bin\idt.bat -#"bx dev %*" | Out-File -FilePath "C:\Program Files\IBM\Bluemix\bin\idt.bat" -Encoding ascii -Write-Output $idt_batch | Out-File -Encoding ascii "C:\Program Files\IBM\Bluemix\bin\idt.bat" + Write-Output $idt_batch | Out-File -Encoding ascii "C:\Program Files\IBM\Bluemix\bin\idt.bat" +} -Write-Output "--==[ Finished ]==--" +#------------------------------------------------------------------------------ +# MAIN +#------------------------------------------------------------------------------ +function main { + log "--==[ $PROG, v$VERSION ]==--" + $secs = (Get-Date) -#-- Request Restart to save changes to PATH. -if ($reboot -eq 1 ) { - $restart = Read-Host "A system restart is required. Would you like to restart now (y/N)?" - if($restart -eq "y" -Or $restart -eq "yes") { - Restart-Computer + #-- Check for Windows 10 + if ([System.Environment]::OSVersion.Version.Major -lt 10) { + error "This installer requires Windows 10 or higher." + } + + #-- Check for 64-bit Platform - Dev and Helm do not have 32-bit versions. + if ([Environment]::Is64BitProcess -ne [Environment]::Is64BitOperatingSystem) { + error "This installer requires 64-bit Windows." + } + + If(-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` + [Security.Principal.WindowsBuiltInRole] "Administrator")) { + error "This script must be run as Administrator. Re-run this script as an Administrator!" + } + + #-- Running as admin defaults to system32 change to home directory. + Set-Location ~ + + $ACTION="install" + + #-- Parse args + foreach ($arg in $args) { + switch -exact ($arg) { + "--trace" { + warn "Enabling verbose tracing of all activity" + Set-PSDebug -Trace 1 + } + "--force" { + $FORCE=1 + warn "Forcing updates for all dependencies and other settings" + } + "install" { $ACTION = "install" } + "uninstall" { $ACTION = "uninstall" } + default { $ACTION = "help" } } + } + + switch -exact ($ACTION) { + "install" { install } + "uninstall" { uninstall } + default { help } + } + + $secs = (Get-Date)-$secs + log "--==[ Finished. Total time: $secs seconds ]==--" } + +#------------------------------------------------------------------------------ +#-- Kick things off +#------------------------------------------------------------------------------ +main $args + +#------------------------------------------------------------------------------ +# EOF +#------------------------------------------------------------------------------ From cd749a2d64bde25926722bcad9f5c4eab0f3a157 Mon Sep 17 00:00:00 2001 From: Karl Bishop Date: Sun, 7 Jan 2018 17:35:32 -0500 Subject: [PATCH 06/11] fixed update/uninstall from bat --- windows-installer/idt-win-installer.ps1 | 55 ++++++++++++++----------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/windows-installer/idt-win-installer.ps1 b/windows-installer/idt-win-installer.ps1 index 6ac6082..c56f65f 100644 --- a/windows-installer/idt-win-installer.ps1 +++ b/windows-installer/idt-win-installer.ps1 @@ -50,21 +50,30 @@ function help { #------------------------------------------------------------------------------ function log() { - Write-Host "[" $((Get-PSCallStack)[1].Command) "]" -foreground cyan - Write-Host " " $args + Write-Host "[$((Get-PSCallStack)[1].Command)] " -foreground cyan -nonewline + Write-Host $args } function warn() { - Write-Host "[" $((Get-PSCallStack)[1].Command) "]" -foreground cyan - Write-Host "WARN" -foreground yellow - Write-Host ": " $args + Write-Host "[$((Get-PSCallStack)[1].Command)] " -foreground cyan -nonewline + Write-Host "WARN" -foreground yellow -nonewline + Write-Host ": $args" } function error() { - Write-Host "[" $((Get-PSCallStack)[1].Command) "]" -foreground cyan - Write-Host "ERROR" -foreground red - Write-Host ": " $args - exit -1 + Write-Host "[$((Get-PSCallStack)[1].Command)] " -foreground cyan -nonewline + Write-Host "ERROR" -foreground red -nonewline + Write-Host ": $args" + quit +} + +function quit() { + # If running in the console, wait for input before closing. + if ($Host.Name -eq "ConsoleHost") { + Write-Host "Press any key to continue..." + $Host.UI.RawUI.FlushInputBuffer() # Make sure buffered input doesn't "press a key" and skip the ReadKey(). + $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null + } } #------------------------------------------------------------------------------ @@ -75,7 +84,7 @@ function uninstall() { #------------------------------------------------------------------------------ function install() { - log "Starting Full Installation..." + log "Starting Installation/Update..." #-- Check if internal IBM setup if( get-command bx -erroraction 'silentlycontinue' ) { @@ -88,9 +97,9 @@ function install() { $IDT_INSTALL_BMX_URL="https://clis.stage1.ng.bluemix.net/install" $IDT_INSTALL_BMX_REPO_NAME="stage1" $IDT_INSTALL_BMX_REPO_URL="https://plugins.stage1.ng.bluemix.net" - fi - fi - fi + } + } + } install_deps install_bx @@ -115,7 +124,7 @@ function install_deps() { #-- git log "Checking for external dependency: git" - if( ! get-command git -erroraction 'silentlycontinue' -or $FORCE -eq 1) { + if( -not (get-command git -erroraction 'silentlycontinue') -or $FORCE -eq 1) { log "Installing/updating external dependency: git" $gitVersion = (Invoke-WebRequest "https://git-scm.com/downloads/latest" -UseBasicParsing).Content Invoke-WebRequest "https://github.com/git-for-windows/git/releases/download/v$gitVersion.windows.1/Git-$gitVersion-64-bit.exe" -UseBasicParsing -outfile "git-installer.exe" @@ -127,7 +136,7 @@ function install_deps() { #-- docker log "Checking for external dependency: docker" - if( ! get-command docker -erroraction 'silentlycontinue' -or $FORCE -eq 1) { + if( -not(get-command docker -erroraction 'silentlycontinue') -or $FORCE -eq 1) { log "Installing/updating external dependency: docker" Invoke-WebRequest "https://download.docker.com/win/stable/InstallDocker.msi" -UseBasicParsing -outfile "InstallDocker.msi" msiexec /i InstallDocker.msi /passive | Out-Null @@ -137,7 +146,7 @@ function install_deps() { #-- kubectl log "Checking for external dependency: kubectl" - if( ! get-command kubectl -erroraction 'silentlycontinue' -or $FORCE -eq 1) { + if( -not( get-command kubectl -erroraction 'silentlycontinue') -or $FORCE -eq 1) { log "Installing/updating external dependency: kubectl" $kube_version = (Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/stable.txt" -UseBasicParsing).Content $kube_version = $kube_version -replace "`n|`r" @@ -155,7 +164,7 @@ function install_deps() { #-- helm log "Checking for external dependency: helm" - if( ! get-command helm -erroraction 'silentlycontinue' -or $FORCE -eq 1) { + if( -not (get-command helm -erroraction 'silentlycontinue') -or $FORCE -eq 1) { log "Installing/updating external dependency: helm" $helm_url = ((Invoke-WebRequest https://github.com/kubernetes/helm -UseBasicParsing).Links.OuterHTML | Where-Object{$_ -match 'windows-amd64.tar.gz'} | Select-Object -first 1).Split('"')[1] Write-Output "Helm URL : $helm_url" @@ -238,13 +247,13 @@ REM # idt uninstall [--trace] - Uninstall IDT REM #----------------------------------------------------------- IF "%1"=="update" ( echo Updating IBM Cloud Developer Tools CLI... - PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted """"iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')"""" """"update"""" """"%2"""" ' -Verb RunAs}" + PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted ""iex(New-Object Net.WebClient).DownloadString(""""http://ibm.biz/idt-win-installer"""")"" ""%2"" ""%3"" ' -Verb RunAs}" ) ELSE IF "%1"=="uninstall" ( echo Uninstalling IBM Cloud Developer Tools CLI... - PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted """"iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')"""" """"uninstall"""" """"%2"""" ' -Verb RunAs}" + PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted ""iex(New-Object Net.WebClient).DownloadString(""""http://ibm.biz/idt-win-installer"""")"" ""uninstall"" ""%2"" ' -Verb RunAs}" echo IDT and IBM Cloud CLI have been removed. ) ELSE ( - C:\"Program Files"\IBM\Bluemix\bin\bx.exe dev %* + bx dev %* ) REM #----------------------------------------------------------- "@ @@ -289,9 +298,7 @@ function main { $FORCE=1 warn "Forcing updates for all dependencies and other settings" } - "install" { $ACTION = "install" } "uninstall" { $ACTION = "uninstall" } - default { $ACTION = "help" } } } @@ -302,7 +309,9 @@ function main { } $secs = (Get-Date)-$secs - log "--==[ Finished. Total time: $secs seconds ]==--" + log "--==[ Finished. Total time: $($secs.ToString("hh\:mm\:ss")) seconds ]==--" + + quit } #------------------------------------------------------------------------------ From cead6c6ed1bd3780f1835d1101183d0dfc2ccf0b Mon Sep 17 00:00:00 2001 From: Karl Bishop Date: Mon, 8 Jan 2018 12:22:00 -0500 Subject: [PATCH 07/11] doc cleanup --- windows-installer/README.md | 45 ++++++++++++++----------- windows-installer/idt-win-installer.ps1 | 28 +++++++++++---- 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/windows-installer/README.md b/windows-installer/README.md index 2b5d1b5..b2781ec 100644 --- a/windows-installer/README.md +++ b/windows-installer/README.md @@ -10,10 +10,6 @@ * [Uninstall](#uninstall) * [Pre-Requisites](#pre-requisites) * [Usage](#usage) -* [Platform specific concerns](#platforms) - * [MacOS](#macos) - * [Linux](#linux) - * [Windows](#windows) * [Internal IBM users](#internal-ibm-users) @@ -25,6 +21,7 @@ PowerShell script that downloads and installs the IBM Cloud Developer Tools (IDT ## Installation ### Single-line Running +This action will install (or update) the IBM Cloud Developer Toolsto your windows system in a single command. 1. Open Windows PowerShell by right-clicking and select "Run as Administrator". 2. Run this command: @@ -32,7 +29,14 @@ PowerShell script that downloads and installs the IBM Cloud Developer Tools (IDT Set-ExecutionPolicy Unrestricted; iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer') ``` +Once the installation has completed, and you have rebooted your system (as needed), there will be three added shortcuts defined to access the IDT: +- `idt` : Main command line tool for IBM cloud native development (shortcut to 'bx dev' command) +- `idt update` : Update your IDT environment to the latest versions +- `idt uninstall` : Uninstall the IBM Developer Tools + + ### Running from Download +Alternatively, you can use the following approach to perform an installation. This will give you an opportunity to better inspect the activities performed, especially if you are having any issues during installation (shown below). 1. Download the `idt-win-installer.ps1` file, or clone this repository. 2. Open Windows PowerShell by right-clicking and selecting "Run as administrator". @@ -43,12 +47,6 @@ Set-ExecutionPolicy Unrestricted .\idt-win-installer.ps1 ``` -Once completed, and you have rebooted your system (as needed), there will be three added shortcuts defined to access the IDT: -- `idt` : Main command line tool for IBM cloud native development (shortcut to 'bx dev' command) -- `idt update` : Update your IDT environment to the latest versions -- `idt uninstall` : Uninstall the IBM Developer Tools - - ### Debugging If you have any issues with the installer, try running with the `--trace` argument which will produce verbose output to assist us in diagnosing your problem: @@ -66,20 +64,32 @@ idt update --trace ## Updating -If you wish to update the IBM Developer Tools CLI, run `idt update`. There is also a `--force` argument that will force update to all dependencies too. +If you wish to update the IBM Developer Tools CLI, run: -This command is simply an alias defined during initial install that runs the installer (in admin mode) as shown here: +``` +idt update [--force] [--trace] +``` + +The `--force` argument that will force update to all dependencies too. + +This command is simply a shortcut defined during initial install that runs (in admin mode) the installer as shown here: ``` -PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted """"iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')"""" """"update"""" """"%2"""" ' -Verb RunAs}" +PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted ""iex(New-Object Net.WebClient).DownloadString(""""http://ibm.biz/idt-win-installer"""")"" ""%2"" ""%3"" ' -Verb RunAs}" ``` ## Uninstall -If you wish to remove the IBM Developer Tools CLI, run `idt uninstall`. This command is simply an alias defined during install that runs the following: +If you wish to remove the IBM Developer Tools CLI, run: ``` -PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted """"iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')"""" """"uninstall"""" """"%2"""" ' -Verb RunAs}" +idt uninstall [--trace] +``` + +This command is simply a shortcut defined during install that runs (in admin mode) the installer's uninstall action as shown here: + +``` +PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted ""iex(New-Object Net.WebClient).DownloadString(""""http://ibm.biz/idt-win-installer"""")"" ""uninstall"" ""%2"" ' -Verb RunAs}" ``` @@ -97,7 +107,7 @@ The script will check for the following prereqs, and attempt to install them if Usage: idt-win-installer [] Where is: - install [Default] Perform full install (or update) of all needed CLIs and Plugins + install | unpdate [Default] Perform full install (or update) of all needed CLIs and Plugins uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins help | -h | -? Show this help --force Force updates of dependencies and other settings during update @@ -127,6 +137,3 @@ Submit any issues to : https://github.com/IBM-Cloud/ibm-cloud-developer-tools/is IBM users can use pre-release versions of the IDT (bx and all plugins). The installer will check if you have the internal "stage1" plugin repo defined, and ask if you want to use it for updates. Note: Since during initial install of the bx CLI does not have extra plugin repos defined, it only applies during subsequent updates. -### MacOS & Linux Installation - -**WARNING**: MacOS and Linux are not supported by this installer. See the [MacOS & Linux installation](../linux-installer/README.md) for additional information. diff --git a/windows-installer/idt-win-installer.ps1 b/windows-installer/idt-win-installer.ps1 index c56f65f..8c6edc4 100644 --- a/windows-installer/idt-win-installer.ps1 +++ b/windows-installer/idt-win-installer.ps1 @@ -26,13 +26,13 @@ function help { Usage: idt-win-installer [] Where is: - install [Default] Perform full install (or update) of all needed CLIs and Plugins - uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins - help Show this help - --force | -f Force updates of dependencies and other settings during update - --trace Eanble verbose tracing of all activity + install | update [Default] Perform install (or update) of all needed CLIs and Plugins + uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins + help Show this help + --force | -f Force updates of dependencies and other settings during update + --trace Eanble verbose tracing of all activity - If "install" (or no action provided), a full CLI installation (or update) will occur: + If "install", "update", or no action, a full CLI installation (or update) will occur: 1. Pre-req check for 'git', 'docker', 'kubectl', and 'helm' 2. Install latest IBM Cloud 'bx' CLI 3. Install all required plugins @@ -79,7 +79,18 @@ function quit() { #------------------------------------------------------------------------------ function uninstall() { warn "Starting Uninstall..." - + Write-Output + $reply = Read-Host -Prompt "Are you sure you want to remove IDT and IBM Cloud CLI (Y/n)?" + Write-Output + if($reply -match "[Yy]*") { + log "Deleting: C:\Program Files\IBM\Bluemix" + Remove-Item -Recurse -Force "C:\Program Files\IBM\Bluemix" + log "Deleting: ~/.bluemix" + Remove-Item -Recurse -Force ~/.bluemix + log "Uninstall complete." + } else { + log "Uninstall cancelled at user request" + } } #------------------------------------------------------------------------------ @@ -298,7 +309,10 @@ function main { $FORCE=1 warn "Forcing updates for all dependencies and other settings" } + "update" { $ACTION = "install" } + "install" { $ACTION = "install" } "uninstall" { $ACTION = "uninstall" } + default { $ACTION = "help" } } } From ee6061acb100dfd2ac1e57b322879ee79ac3329e Mon Sep 17 00:00:00 2001 From: kfbishop Date: Tue, 9 Jan 2018 09:37:21 -0500 Subject: [PATCH 08/11] minor doc typos --- linux-installer/README.md | 2 +- windows-installer/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-installer/README.md b/linux-installer/README.md index 1671044..13cfc64 100644 --- a/linux-installer/README.md +++ b/linux-installer/README.md @@ -88,7 +88,7 @@ The script will check for the following prereqs, and attempt to install them if Usage: idt-installer [] Where is: - install [Default] Perform full install (or update) of all needed CLIs and Plugins + install | update [Default] Perform full install (or update) of all needed CLIs and Plugins uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins help | -h | -? Show this help --force Force updates of dependencies and other settings during update diff --git a/windows-installer/README.md b/windows-installer/README.md index b2781ec..4ee2d55 100644 --- a/windows-installer/README.md +++ b/windows-installer/README.md @@ -107,7 +107,7 @@ The script will check for the following prereqs, and attempt to install them if Usage: idt-win-installer [] Where is: - install | unpdate [Default] Perform full install (or update) of all needed CLIs and Plugins + install | update [Default] Perform full install (or update) of all needed CLIs and Plugins uninstall Uninstall full IBM Cloud CLI env, including 'bx', and plugins help | -h | -? Show this help --force Force updates of dependencies and other settings during update From dec2b941dd7a695cac5d53a34a65b1969c71688a Mon Sep 17 00:00:00 2001 From: Karl Bishop Date: Tue, 9 Jan 2018 13:49:22 -0500 Subject: [PATCH 09/11] fixing regressions during testing --- windows-installer/idt-win-installer.ps1 | 122 ++++++++++++++---------- 1 file changed, 69 insertions(+), 53 deletions(-) diff --git a/windows-installer/idt-win-installer.ps1 b/windows-installer/idt-win-installer.ps1 index 8c6edc4..c0d0ea6 100644 --- a/windows-installer/idt-win-installer.ps1 +++ b/windows-installer/idt-win-installer.ps1 @@ -15,8 +15,9 @@ $IDT_INSTALL_BMX_URL="https://clis.ng.bluemix.net/install" $IDT_INSTALL_BMX_REPO_NAME="Bluemix" $IDT_INSTALL_BMX_REPO_URL="https://plugins.ng.bluemix.net" -$FORCE = 0 -$NEEDS_REBOOT = 0 +$Global:FORCE = $false +$Global:NEEDS_REBOOT = $false +$Global:SECS = 0 #------------------------------------------------------------------------------ function help { @@ -67,26 +68,45 @@ function error() { quit } +#------------------------------------------------------------------------------ function quit() { - # If running in the console, wait for input before closing. - if ($Host.Name -eq "ConsoleHost") { - Write-Host "Press any key to continue..." - $Host.UI.RawUI.FlushInputBuffer() # Make sure buffered input doesn't "press a key" and skip the ReadKey(). - $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null + $Global:SECS = (Get-Date)-$Global:SECS + log "--==[ Finished. Total time: $($Global:SECS.ToString("hh\:mm\:ss")) seconds ]==--" + Write-Host "" + + #-- Request Restart to save changes to PATH. + if ( $Global:NEEDS_REBOOT ) { + $restart = Read-Host -Prompt "A system restart is required. Would you like to restart now (y/N)?" + if($restart -match "[Yy]" ) { + Restart-Computer + } else { + Write-Host "Note: Reboot still needed to load env variables." + } + } else { + # If running in the console, wait for input before closing. + if ($Host.Name -eq "ConsoleHost") { + Write-Host "Press any key to continue..." + $Host.UI.RawUI.FlushInputBuffer() # Make sure buffered input doesn't "press a key" and skip the ReadKey(). + $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null + + #-- turn opff trace + Set-PSDebug -Trace 0 + } } } #------------------------------------------------------------------------------ function uninstall() { warn "Starting Uninstall..." - Write-Output - $reply = Read-Host -Prompt "Are you sure you want to remove IDT and IBM Cloud CLI (Y/n)?" - Write-Output - if($reply -match "[Yy]*") { + Write-Output "" + $reply = Read-Host -Prompt "Are you sure you want to remove IDT and IBM Cloud CLI (y/N)?" + Write-Output "" + if($reply -match "[Yy]") { + log "Uninstalling IDT..." log "Deleting: C:\Program Files\IBM\Bluemix" - Remove-Item -Recurse -Force "C:\Program Files\IBM\Bluemix" + Remove-Item -Recurse -Force "C:\Program Files\IBM\Bluemix" -erroraction 'silentlycontinue' log "Deleting: ~/.bluemix" - Remove-Item -Recurse -Force ~/.bluemix + Remove-Item -Recurse -Force ~/.bluemix -erroraction 'silentlycontinue' log "Uninstall complete." } else { log "Uninstall cancelled at user request" @@ -119,13 +139,6 @@ function install() { log "Install finished." - #-- Request Restart to save changes to PATH. - if ($NEEDS_REBOOT -eq 1 ) { - $restart = Read-Host "A system restart is required. Would you like to restart now (y/N)?" - if($restart -match "[Yy]*" ) { - Restart-Computer - } - } } @@ -135,71 +148,78 @@ function install_deps() { #-- git log "Checking for external dependency: git" - if( -not (get-command git -erroraction 'silentlycontinue') -or $FORCE -eq 1) { + if( -not (get-command git -erroraction 'silentlycontinue') -or $Global:FORC) { log "Installing/updating external dependency: git" $gitVersion = (Invoke-WebRequest "https://git-scm.com/downloads/latest" -UseBasicParsing).Content Invoke-WebRequest "https://github.com/git-for-windows/git/releases/download/v$gitVersion.windows.1/Git-$gitVersion-64-bit.exe" -UseBasicParsing -outfile "git-installer.exe" .\git-installer.exe /SILENT /PathOption="Cmd" | Out-Null Remove-Item "git-installer.exe" - $NEEDS_REBOOT = 1 + $Global:NEEDS_REBOOT = $true log "Install/update completed for: git" } #-- docker log "Checking for external dependency: docker" - if( -not(get-command docker -erroraction 'silentlycontinue') -or $FORCE -eq 1) { + if( -not(get-command docker -erroraction 'silentlycontinue') -or $Global:FORC) { log "Installing/updating external dependency: docker" Invoke-WebRequest "https://download.docker.com/win/stable/InstallDocker.msi" -UseBasicParsing -outfile "InstallDocker.msi" msiexec /i InstallDocker.msi /passive | Out-Null - $NEEDS_REBOOT = 1 + $Global:NEEDS_REBOOT = $true log "Install/update completed for: docker" } #-- kubectl log "Checking for external dependency: kubectl" - if( -not( get-command kubectl -erroraction 'silentlycontinue') -or $FORCE -eq 1) { + if( -not( get-command kubectl -erroraction 'silentlycontinue') -or $Global:FORC) { log "Installing/updating external dependency: kubectl" $kube_version = (Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/stable.txt" -UseBasicParsing).Content $kube_version = $kube_version -replace "`n|`r" Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/$kube_version/bin/windows/amd64/kubectl.exe" -UseBasicParsing -outfile "kubectl.exe" - mkdir "C:\Program Files\kubectl" - Move-Item -Path "kubectl.exe" -Destination "C:\Program Files\kubectl" - # Directly edit the registery to add kubectl to PATH. Will require a restart to stick. - $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" - $value = (Get-ItemProperty $regPath -Name Path).Path - $newValue = $value+";C:\Program Files\kubectl" - Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null - $NEEDS_REBOOT = 1 + mkdir "C:\Program Files\kubectl" -erroraction 'silentlycontinue' + Move-Item -Path "kubectl.exe" -Destination "C:\Program Files\kubectl" -force + add_to_path("C:\Program Files\kubectl") + $Global:NEEDS_REBOOT = $true log "Install/update completed for: kubectl" } #-- helm log "Checking for external dependency: helm" - if( -not (get-command helm -erroraction 'silentlycontinue') -or $FORCE -eq 1) { + if( -not (get-command helm -erroraction 'silentlycontinue') -or $Global:FORC) { log "Installing/updating external dependency: helm" $helm_url = ((Invoke-WebRequest https://github.com/kubernetes/helm -UseBasicParsing).Links.OuterHTML | Where-Object{$_ -match 'windows-amd64.tar.gz'} | Select-Object -first 1).Split('"')[1] - Write-Output "Helm URL : $helm_url" - $helm_file = $helm_url.Split("/")[$_.Length-1] - Write-Output "Helm File: $helm_file" + log "Helm URL : $helm_url" + $helm_file = $helm_url.Split("/")[-1] + log "Helm File: $helm_file" Invoke-WebRequest $helm_url -UseBasicParsing -outfile "$helm_file" mkdir "C:\Program Files\helm" -ErrorAction SilentlyContinue if (-not (Get-Command Expand-7Zip -ErrorAction Ignore)) { Install-Package -Scope CurrentUser -Force 7Zip4PowerShell > $null } Expand-7Zip $helm_file . - $tar = $helm_file.Replace('.gz','') - Expand-7Zip $tar "C:\Program Files\helm" - Remove-Item $helm_file $tar - # Directly edit the registery to add helm to PATH. Will require a restart to stick. - $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" - $value = (Get-ItemProperty $regPath -Name Path).Path - $newValue = $value+";C:\Program Files\helm\windows-amd64" - Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null - $NEEDS_REBOOT = 1 + $tar_file = $helm_file.Replace('.gz','') + Expand-7Zip $tar_file "C:\Program Files\helm" + Remove-Item $helm_file -erroraction 'silentlycontinue' + Remove-Item $tar_file -erroraction 'silentlycontinue' + add_to_path("C:\Program Files\helm\windows-amd64") + $Global:NEEDS_REBOOT = $true log "Install/update completed for: helm" } } +#------------------------------------------------------------------------------ +#-- Add a dir to the system path +function add_to_path { + Param($path) + # Directly edit the registery to add kubectl to PATH. Will require a restart to stick. + $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" + $value = (Get-ItemProperty $regPath -Name Path).Path + if ( -not ($value -match [Regex]::Escape("$path") )) { + log "Adding $path to PATH" + $newValue = "$value;$path" + Set-ItemProperty -Path $regPath -Name Path -Value $newValue | Out-Null + } +} + #------------------------------------------------------------------------------ #-- Install Bluemix CLI. function install_bx() { @@ -211,8 +231,7 @@ function install_bx() { $url = $IDT_INSTALL_BMX_URL + "/powershell" log "Downloading and installing IBM Cloud 'bx' CLI from: $url" Invoke-Expression(New-Object Net.WebClient).DownloadString( $url ) - C:\"Program Files"\IBM\Bluemix\bin\bx.exe api api.ng.bluemix.net - $NEEDS_REBOOT = 1 + $Global:NEEDS_REBOOT = $true } log "IBM Cloud CLI version:" C:\"Program Files"\IBM\Bluemix\bin\bx.exe --version @@ -276,7 +295,7 @@ REM #----------------------------------------------------------- #------------------------------------------------------------------------------ function main { log "--==[ $PROG, v$VERSION ]==--" - $secs = (Get-Date) + $Global:SECS = (Get-Date) #-- Check for Windows 10 if ([System.Environment]::OSVersion.Version.Major -lt 10) { @@ -306,7 +325,7 @@ function main { Set-PSDebug -Trace 1 } "--force" { - $FORCE=1 + $Global:FORC=$true warn "Forcing updates for all dependencies and other settings" } "update" { $ACTION = "install" } @@ -322,9 +341,6 @@ function main { default { help } } - $secs = (Get-Date)-$secs - log "--==[ Finished. Total time: $($secs.ToString("hh\:mm\:ss")) seconds ]==--" - quit } From fdc4538b27236b690fb05fcbddaf5cc80dee3fd6 Mon Sep 17 00:00:00 2001 From: kfbishop Date: Wed, 10 Jan 2018 07:42:26 -0500 Subject: [PATCH 10/11] win globals fixes --- windows-installer/idt-win-installer.ps1 | 76 +++++++++++++------------ 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/windows-installer/idt-win-installer.ps1 b/windows-installer/idt-win-installer.ps1 index c0d0ea6..aef0fe3 100644 --- a/windows-installer/idt-win-installer.ps1 +++ b/windows-installer/idt-win-installer.ps1 @@ -5,15 +5,15 @@ #------------------------------------------------------------------------------ # Copyright (c) 2018, International Business Machines. All Rights Reserved. #------------------------------------------------------------------------------ -$VERSION="1.2.0" -$PROG="IBM Cloud Developer Tools - Installer for Windows" +$Global:VERSION="1.2.0" +$Global:PROG="IBM Cloud Developer Tools - Installer for Windows" -$INSTALLER_URL="https://ibm.biz/idt-win-installer" -$GIT_URL="https://github.com/IBM-Cloud/ibm-cloud-developer-tools" -$SLACK_URL="https://slack-invite-ibm-cloud-tech.mybluemix.net/" -$IDT_INSTALL_BMX_URL="https://clis.ng.bluemix.net/install" -$IDT_INSTALL_BMX_REPO_NAME="Bluemix" -$IDT_INSTALL_BMX_REPO_URL="https://plugins.ng.bluemix.net" +$Global:INSTALLER_URL="https://ibm.biz/idt-win-installer" +$Global:GIT_URL="https://github.com/IBM-Cloud/ibm-cloud-developer-tools" +$Global:SLACK_URL="https://slack-invite-ibm-cloud-tech.mybluemix.net/" +$Global:IDT_INSTALL_BMX_URL="https://clis.ng.bluemix.net/install" +$Global:IDT_INSTALL_BMX_REPO_NAME="Bluemix" +$Global:IDT_INSTALL_BMX_REPO_URL="https://plugins.ng.bluemix.net" $Global:FORCE = $false $Global:NEEDS_REBOOT = $false @@ -23,7 +23,7 @@ $Global:SECS = 0 function help { Write-Output @" - $PROG + $Global:PROG Usage: idt-win-installer [] Where is: @@ -42,8 +42,8 @@ function help { - idt update : Runs this installer checking for and installing any updates - idt uninstall : Uninstalls IDT, 'bx' cli, and all plugins - Chat with us on Slack: ${SLACK_URL}, channel #developer-tools - Submit any issues to : ${GIT_URL}/issues + Chat with us on Slack: $Global:SLACK_URL, channel #developer-tools + Submit any issues to : $Global:GIT_URL/issues "@ } @@ -125,9 +125,9 @@ function install() { $reply = Read-Host -Prompt "Use IBM internal repos for install/updates (Y/n)?" Write-Output if($reply -match "[Yy]*") { - $IDT_INSTALL_BMX_URL="https://clis.stage1.ng.bluemix.net/install" - $IDT_INSTALL_BMX_REPO_NAME="stage1" - $IDT_INSTALL_BMX_REPO_URL="https://plugins.stage1.ng.bluemix.net" + $Global:IDT_INSTALL_BMX_URL="https://clis.stage1.ng.bluemix.net/install" + $Global:IDT_INSTALL_BMX_REPO_NAME="stage1" + $Global:IDT_INSTALL_BMX_REPO_URL="https://plugins.stage1.ng.bluemix.net" } } } @@ -148,7 +148,7 @@ function install_deps() { #-- git log "Checking for external dependency: git" - if( -not (get-command git -erroraction 'silentlycontinue') -or $Global:FORC) { + if( -not (get-command git -erroraction 'silentlycontinue') -or $Global:FORCE) { log "Installing/updating external dependency: git" $gitVersion = (Invoke-WebRequest "https://git-scm.com/downloads/latest" -UseBasicParsing).Content Invoke-WebRequest "https://github.com/git-for-windows/git/releases/download/v$gitVersion.windows.1/Git-$gitVersion-64-bit.exe" -UseBasicParsing -outfile "git-installer.exe" @@ -160,7 +160,7 @@ function install_deps() { #-- docker log "Checking for external dependency: docker" - if( -not(get-command docker -erroraction 'silentlycontinue') -or $Global:FORC) { + if( -not(get-command docker -erroraction 'silentlycontinue') -or $Global:FORCE) { log "Installing/updating external dependency: docker" Invoke-WebRequest "https://download.docker.com/win/stable/InstallDocker.msi" -UseBasicParsing -outfile "InstallDocker.msi" msiexec /i InstallDocker.msi /passive | Out-Null @@ -170,7 +170,7 @@ function install_deps() { #-- kubectl log "Checking for external dependency: kubectl" - if( -not( get-command kubectl -erroraction 'silentlycontinue') -or $Global:FORC) { + if( -not( get-command kubectl -erroraction 'silentlycontinue') -or $Global:FORCE) { log "Installing/updating external dependency: kubectl" $kube_version = (Invoke-WebRequest "https://storage.googleapis.com/kubernetes-release/release/stable.txt" -UseBasicParsing).Content $kube_version = $kube_version -replace "`n|`r" @@ -184,7 +184,7 @@ function install_deps() { #-- helm log "Checking for external dependency: helm" - if( -not (get-command helm -erroraction 'silentlycontinue') -or $Global:FORC) { + if( -not (get-command helm -erroraction 'silentlycontinue') -or $Global:FORCE) { log "Installing/updating external dependency: helm" $helm_url = ((Invoke-WebRequest https://github.com/kubernetes/helm -UseBasicParsing).Links.OuterHTML | Where-Object{$_ -match 'windows-amd64.tar.gz'} | Select-Object -first 1).Split('"')[1] log "Helm URL : $helm_url" @@ -228,7 +228,7 @@ function install_bx() { bx update } else { log "Installing IBM Cloud 'bx' CLI for Windows..." - $url = $IDT_INSTALL_BMX_URL + "/powershell" + $url = $Global:IDT_INSTALL_BMX_URL + "/powershell" log "Downloading and installing IBM Cloud 'bx' CLI from: $url" Invoke-Expression(New-Object Net.WebClient).DownloadString( $url ) $Global:NEEDS_REBOOT = $true @@ -241,23 +241,26 @@ function install_bx() { #-- Install Bluemix CLI Plugins. function install_plugins { log "Installing/updating IBM Cloud CLI plugins used by IDT..." - $EXT_PLUGINS = "Cloud-Functions", - "container-registry", - "container-service", - "dev", - "schematics", - "sdk-gen" + $plugins = "Cloud-Functions", + "container-registry", + "container-service", + "dev", + "schematics", + "sdk-gen" $pluginlist = C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin list - Foreach ($plugin in $EXT_PLUGINS) { - log "Checking status of plugin: $plugin" - if($pluginlist -match "\b$plugin\b") { - log "Updating plugin '$plugin'" - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin update -r $IDT_INSTALL_BMX_REPO_NAME $plugin - } else { - log "Installing plugin '$plugin'" - C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install -r $IDT_INSTALL_BMX_REPO_NAME $plugin - } + Foreach ($plugin in $plugins) { + log "Checking status of plugin: $plugin" + if($pluginlist -match "\b$plugin\b") { + log "Updating plugin '$plugin'" + C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin update -r $Global:IDT_INSTALL_BMX_REPO_NAME $plugin + } else { + log "Installing plugin '$plugin'" + C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin install -r $Global:IDT_INSTALL_BMX_REPO_NAME $plugin + } } + log "Running 'bx plugin list'..." + C:\"Program Files"\IBM\Bluemix\bin\bx.exe plugin list + log "Finished installing/updating plugins" } #------------------------------------------------------------------------------ @@ -294,7 +297,7 @@ REM #----------------------------------------------------------- # MAIN #------------------------------------------------------------------------------ function main { - log "--==[ $PROG, v$VERSION ]==--" + log "--==[ $Global:PROG, v$Global:VERSION ]==--" $Global:SECS = (Get-Date) #-- Check for Windows 10 @@ -325,12 +328,13 @@ function main { Set-PSDebug -Trace 1 } "--force" { - $Global:FORC=$true + $Global:FORCE=$true warn "Forcing updates for all dependencies and other settings" } "update" { $ACTION = "install" } "install" { $ACTION = "install" } "uninstall" { $ACTION = "uninstall" } + "help" { $ACTION = "help" } default { $ACTION = "help" } } } From 8752160733ada6e576d97c423569b340894faa2e Mon Sep 17 00:00:00 2001 From: kfbishop Date: Wed, 10 Jan 2018 15:03:31 -0500 Subject: [PATCH 11/11] fixed stage1 check --- linux-installer/idt-installer | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-installer/idt-installer b/linux-installer/idt-installer index 2c39a1a..449276e 100755 --- a/linux-installer/idt-installer +++ b/linux-installer/idt-installer @@ -136,7 +136,7 @@ function install { echo prompt "Use IBM internal '$repo' repos for install/updates (Y/n)?" echo - if [[ "$REPLY" == [Yy]* ]]; then + if [[ "$REPLY" != [Nn]* ]]; then IDT_INSTALL_BMX_URL="https://clis.stage1.ng.bluemix.net/install" IDT_INSTALL_BMX_REPO_NAME="${repo}" IDT_INSTALL_BMX_REPO_URL="${url}" @@ -171,8 +171,8 @@ function install_deps { #-- Xcode and Cocoapods log "Checking if Xcode is installed" - if [[ -z "$(ls -d /Applications/Xcode*.zpp)" ]]; then - log "Xcode does not appear to be installed on this system." + if [[ -z "$(ls -d /Applications/Xcode*.zpp 2>/dev/null)" ]]; then + warn "Xcode does not appear to be installed on this system." fi log "Installing/updating external dependency: cocoapods" if [[ -z "$(gem list --local | grep "^cocoapods ")" || "$FORCE" == true ]]; then