Skip to content

Instantly share code, notes, and snippets.

@rvagg
Last active April 2, 2024 16:51
Show Gist options
  • Save rvagg/742f811be491a49ba0b9 to your computer and use it in GitHub Desktop.
Save rvagg/742f811be491a49ba0b9 to your computer and use it in GitHub Desktop.

Revisions

  1. rvagg revised this gist Feb 6, 2020. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions install-node.sh
    Original file line number Diff line number Diff line change
    @@ -60,11 +60,12 @@ while true; do
    url="https://${domain}/download/${type}/$latest/node-${latest}-${os}-${arch}.tar"
    if [ "X${hasxz}" == "X" ]; then
    url="${url}.gz"
    pipecmd="| tar -zvx ${tarargs}"
    pipecmd="| tar -zx ${tarargs}"
    else
    url="${url}.xz"
    pipecmd="| xzcat | tar -vx ${tarargs}"
    pipecmd="| xzcat | tar -x ${tarargs}"
    fi
    echo "Downloading and unpacking ${url} to ${targetdir}..."
    bash -c "curl -sL '${url}' ${pipecmd}"
    break
    fi
  2. rvagg revised this gist Feb 6, 2020. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions install-node.sh
    Original file line number Diff line number Diff line change
    @@ -7,10 +7,12 @@ hasxz=$(which xzcat)
    os=$(uname | tr '[A-Z]' '[a-z]')
    arch=$(uname -m)
    targetdir="/usr/local/"
    domain=nodejs.org
    tarargs=" --strip-components=1 --exclude ./CHANGELOG.md --exclude ./README.md --exclude ./LICENSE -C ${targetdir}"

    [[ "$arch" == "x86_64" ]] && arch=x64
    [[ "$arch" == "x686" ]] && arch=x32
    [[ "$arch" == "x686" ]] && arch=x86
    [[ "$arch" == "x86" ]] && domain=unofficial-builds.nodejs.org

    type=release
    line=""
    @@ -47,15 +49,15 @@ case $key in
    esac
    done

    latest=$(curl -sL https://nodejs.org/download/${type}/index.tab | grep "^v${line}" | awk '/^v[0-9]/{ print $1; exit }')
    latest=$(curl -sL https://${domain}/download/${type}/index.tab | grep "^v${line}" | awk '/^v[0-9]/{ print $1; exit }')

    while true; do
    if [ "X${yorn}" == "Xn" ]; then
    break
    fi

    if [ "X${yorn}" == "Xy" ]; then
    url="https://nodejs.org/download/${type}/$latest/node-${latest}-${os}-${arch}.tar"
    url="https://${domain}/download/${type}/$latest/node-${latest}-${os}-${arch}.tar"
    if [ "X${hasxz}" == "X" ]; then
    url="${url}.gz"
    pipecmd="| tar -zvx ${tarargs}"
    @@ -64,7 +66,6 @@ while true; do
    pipecmd="| xzcat | tar -vx ${tarargs}"
    fi
    bash -c "curl -sL '${url}' ${pipecmd}"
    rm -f ${targetdir}CHANGELOG.md ${targetdir}LICENSE ${targetdir}README.md
    break
    fi

  3. rvagg revised this gist Feb 6, 2020. 1 changed file with 4 additions and 7 deletions.
    11 changes: 4 additions & 7 deletions install-node.sh
    Original file line number Diff line number Diff line change
    @@ -7,13 +7,10 @@ hasxz=$(which xzcat)
    os=$(uname | tr '[A-Z]' '[a-z]')
    arch=$(uname -m)
    targetdir="/usr/local/"
    tarargs=" --strip-components=1 -C ${targetdir}"
    domain=nodejs.org
    tarargs=" --strip-components=1 --exclude ./CHANGELOG.md --exclude ./README.md --exclude ./LICENSE -C ${targetdir}"

    [[ "$arch" == "x86_64" ]] && arch=x64
    [[ "$arch" == "x686" ]] && arch=x86

    [[ "$arch" == "x86" ]] && domain=unofficial-builds.nodejs.org
    [[ "$arch" == "x686" ]] && arch=x32

    type=release
    line=""
    @@ -50,15 +47,15 @@ case $key in
    esac
    done

    latest=$(curl -sL https://${domain}/download/${type}/index.tab | grep "^v${line}" | awk '/^v[0-9]/{ print $1; exit }')
    latest=$(curl -sL https://nodejs.org/download/${type}/index.tab | grep "^v${line}" | awk '/^v[0-9]/{ print $1; exit }')

    while true; do
    if [ "X${yorn}" == "Xn" ]; then
    break
    fi

    if [ "X${yorn}" == "Xy" ]; then
    url="https://${domain}/download/${type}/$latest/node-${latest}-${os}-${arch}.tar"
    url="https://nodejs.org/download/${type}/$latest/node-${latest}-${os}-${arch}.tar"
    if [ "X${hasxz}" == "X" ]; then
    url="${url}.gz"
    pipecmd="| tar -zvx ${tarargs}"
  4. rvagg revised this gist Jul 17, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions install-node.sh
    Original file line number Diff line number Diff line change
    @@ -66,8 +66,8 @@ while true; do
    url="${url}.xz"
    pipecmd="| xzcat | tar -vx ${tarargs}"
    fi
    echo bash -c "curl -sL '${url}' ${pipecmd}"
    echo rm -f ${targetdir}CHANGELOG.md ${targetdir}LICENSE ${targetdir}README.md
    bash -c "curl -sL '${url}' ${pipecmd}"
    rm -f ${targetdir}CHANGELOG.md ${targetdir}LICENSE ${targetdir}README.md
    break
    fi

  5. rvagg revised this gist Jul 17, 2019. 1 changed file with 8 additions and 5 deletions.
    13 changes: 8 additions & 5 deletions install-node.sh
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,12 @@ os=$(uname | tr '[A-Z]' '[a-z]')
    arch=$(uname -m)
    targetdir="/usr/local/"
    tarargs=" --strip-components=1 -C ${targetdir}"
    domain=nodejs.org

    [[ "$arch" == "x86_64" ]] && arch=x64
    [[ "$arch" == "x686" ]] && arch=x32
    [[ "$arch" == "x686" ]] && arch=x86

    [[ "$arch" == "x86" ]] && domain=unofficial-builds.nodejs.org

    type=release
    line=""
    @@ -47,24 +50,24 @@ case $key in
    esac
    done

    latest=$(curl -sL https://nodejs.org/download/${type}/index.tab | grep "^v${line}" | awk '/^v[0-9]/{ print $1; exit }')
    latest=$(curl -sL https://${domain}/download/${type}/index.tab | grep "^v${line}" | awk '/^v[0-9]/{ print $1; exit }')

    while true; do
    if [ "X${yorn}" == "Xn" ]; then
    break
    fi

    if [ "X${yorn}" == "Xy" ]; then
    url="https://nodejs.org/download/${type}/$latest/node-${latest}-${os}-${arch}.tar"
    url="https://${domain}/download/${type}/$latest/node-${latest}-${os}-${arch}.tar"
    if [ "X${hasxz}" == "X" ]; then
    url="${url}.gz"
    pipecmd="| tar -zvx ${tarargs}"
    else
    url="${url}.xz"
    pipecmd="| xzcat | tar -vx ${tarargs}"
    fi
    bash -c "curl -sL '${url}' ${pipecmd}"
    rm -f ${targetdir}CHANGELOG.md ${targetdir}LICENSE ${targetdir}README.md
    echo bash -c "curl -sL '${url}' ${pipecmd}"
    echo rm -f ${targetdir}CHANGELOG.md ${targetdir}LICENSE ${targetdir}README.md
    break
    fi

  6. rvagg revised this gist Oct 26, 2018. 1 changed file with 46 additions and 13 deletions.
    59 changes: 46 additions & 13 deletions install-node.sh
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,55 @@
    #!/bin/bash

    # Usage:
    # ./install-node.sh
    # or for nightly:
    # ./install-node.sh --nightly
    # Note your /usr/local will need to be writable by the user running it,
    # alternatively run it with `sudo`

    hasxz=$(which xzcat)
    os=$(uname | tr '[A-Z]' '[a-z]')
    arch=$(uname -m)
    targetdir="/usr/local/"
    tarargs=" --strip-components=1 -C ${targetdir}"

    [[ "$arch" == "x86_64" ]] && arch=x64
    [[ "$arch" == "x686" ]] && arch=x32

    type=release
    [[ "X$1" == "X--nightly" ]] && type=nightly
    line=""
    yorn=""

    latest=$(curl -sL https://nodejs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }')
    while [[ $# -gt 0 ]]
    do
    key="$1"
    case $key in
    -h|--help)
    echo "Usage: install-node.sh [-h|--nightly] [-l|--line <release line>] [-y|--yes]"
    echo " Where:"
    echo " --nightly will fetch the latest nightly version instead of the latest release version"
    echo " --line <release line> will let you select a major version, e.g. --line 10"
    echo " (note --line will match as much of the version as you want, e.g. --line 10.12 or --line 10.12.0)"
    echo " --yes will not promot you for confirmation before installing"
    exit 1
    ;;
    -n|--nightly)
    shift
    ;;
    -y|--yes)
    yorn="y"
    shift
    ;;
    -l|--line)
    line="$2"
    shift
    shift
    ;;
    *)
    shift
    ;;
    esac
    done

    while true; do
    echo -n "Download and install Node.js ${latest} (${os}/${arch})? [y/n] "
    yorn=""
    read yorn
    latest=$(curl -sL https://nodejs.org/download/${type}/index.tab | grep "^v${line}" | awk '/^v[0-9]/{ print $1; exit }')

    while true; do
    if [ "X${yorn}" == "Xn" ]; then
    break
    fi
    @@ -30,12 +58,17 @@ while true; do
    url="https://nodejs.org/download/${type}/$latest/node-${latest}-${os}-${arch}.tar"
    if [ "X${hasxz}" == "X" ]; then
    url="${url}.gz"
    pipecmd="| tar -zvx --strip-components=1 -C /usr/local/"
    pipecmd="| tar -zvx ${tarargs}"
    else
    url="${url}.xz"
    pipecmd="| xzcat | tar -vx --strip-components=1 -C /usr/local/"
    pipecmd="| xzcat | tar -vx ${tarargs}"
    fi
    bash -c "curl -sL '${url}' ${pipecmd}"
    rm -f ${targetdir}CHANGELOG.md ${targetdir}LICENSE ${targetdir}README.md
    break
    fi
    done

    echo -n "Download and install Node.js ${latest} (${os}/${arch})? [y/n] "
    yorn=""
    read yorn
    done
  7. rvagg revised this gist Jun 29, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-node.sh
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ while true; do
    url="${url}.xz"
    pipecmd="| xzcat | tar -vx --strip-components=1 -C /usr/local/"
    fi
    bash -c "curl -sL '${auth}' '${url}' ${pipecmd}"
    bash -c "curl -sL '${url}' ${pipecmd}"
    break
    fi
    done
  8. rvagg revised this gist Jun 29, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-node.sh
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ while true; do
    fi

    if [ "X${yorn}" == "Xy" ]; then
    url="https://nodejs.org/download/${type}/$latest/node-${latest}-${os}-x64.tar"
    url="https://nodejs.org/download/${type}/$latest/node-${latest}-${os}-${arch}.tar"
    if [ "X${hasxz}" == "X" ]; then
    url="${url}.gz"
    pipecmd="| tar -zvx --strip-components=1 -C /usr/local/"
  9. rvagg renamed this gist Jan 21, 2016. 1 changed file with 7 additions and 13 deletions.
    20 changes: 7 additions & 13 deletions install-iojs.sh → install-node.sh
    Original file line number Diff line number Diff line change
    @@ -1,30 +1,24 @@
    #!/bin/bash

    # Usage:
    # ./install-iojs.sh
    # ./install-node.sh
    # or for nightly:
    # ./install-iojs.sh --nightly
    # or for next-nightly:
    # ./install-iojs.sh --next-nightly
    # or for RC:
    # ./install-iojs.sh --rc
    # ./install-node.sh --nightly

    hasxz=$(which xzcat)
    os=$(uname | tr '[A-Z]' '[a-z]')

    arch=$(uname -m)

    [[ "$arch" == "x86_64" ]] && arch=x64
    [[ "$arch" == "x686" ]] && arch=x32

    type=release
    [[ "X$1" == "X--nightly" ]] && type=nightly
    [[ "X$1" == "X--next-nightly" ]] && type=next-nightly
    [[ "X$1" == "X--rc" ]] && type=rc

    latest=$(curl -sL https://iojs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }')
    latest=$(curl -sL https://nodejs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }')

    while true; do
    echo -n "Download and install io.js ${latest} (${os}/${arch})? [y/n] "
    echo -n "Download and install Node.js ${latest} (${os}/${arch})? [y/n] "
    yorn=""
    read yorn

    @@ -33,7 +27,7 @@ while true; do
    fi

    if [ "X${yorn}" == "Xy" ]; then
    url="https://iojs.org/download/${type}/$latest/iojs-${latest}-${os}-${arch}.tar"
    url="https://nodejs.org/download/${type}/$latest/node-${latest}-${os}-x64.tar"
    if [ "X${hasxz}" == "X" ]; then
    url="${url}.gz"
    pipecmd="| tar -zvx --strip-components=1 -C /usr/local/"
    @@ -44,4 +38,4 @@ while true; do
    bash -c "curl -sL '${auth}' '${url}' ${pipecmd}"
    break
    fi
    done
    done
  10. rvagg revised this gist Jul 12, 2015. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion install-iojs.sh
    Original file line number Diff line number Diff line change
    @@ -6,17 +6,20 @@
    # ./install-iojs.sh --nightly
    # or for next-nightly:
    # ./install-iojs.sh --next-nightly
    # or for RC:
    # ./install-iojs.sh --rc

    hasxz=$(which xzcat)
    os=$(uname | tr '[A-Z]' '[a-z]')
    arch=$(uname -m)

    arch=$(uname -m)
    [[ "$arch" == "x86_64" ]] && arch=x64
    [[ "$arch" == "x686" ]] && arch=x32

    type=release
    [[ "X$1" == "X--nightly" ]] && type=nightly
    [[ "X$1" == "X--next-nightly" ]] && type=next-nightly
    [[ "X$1" == "X--rc" ]] && type=rc

    latest=$(curl -sL https://iojs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }')

  11. rvagg revised this gist Jul 12, 2015. 3 changed files with 44 additions and 36 deletions.
    18 changes: 0 additions & 18 deletions install-iojs-nightly-linux.sh
    Original file line number Diff line number Diff line change
    @@ -1,18 +0,0 @@
    #!/bin/bash

    # Usage:
    # sudo ./install-iojs-nightly.sh
    # or for next-nightly:
    # sudo ./install-iojs-nightly.sh next

    type=nightly
    if [ "X$1" == "Xnext" ]; then
    type=next-nightly
    fi

    latest=$(curl -sL https://iojs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }')
    url="https://iojs.org/download/${type}/$latest/iojs-${latest}-linux-x64.tar.xz"

    echo "Downloading ${url}..."

    curl -sL $url | xzcat | tar -vx --strip-components=1 -C /usr/local/
    18 changes: 0 additions & 18 deletions install-iojs-nightly-osx.sh
    Original file line number Diff line number Diff line change
    @@ -1,18 +0,0 @@
    #!/bin/bash

    # Usage:
    # sudo ./install-iojs-nightly.sh
    # or for next-nightly:
    # sudo ./install-iojs-nightly.sh next

    type=nightly
    if [ "X$1" == "Xnext" ]; then
    type=next-nightly
    fi

    latest=$(curl -sL https://iojs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }')
    url="https://iojs.org/download/${type}/$latest/iojs-${latest}-darwin-x64.tar.gz"

    echo "Downloading ${url}..."

    curl -sL $url | tar -vzx --strip-components=1 -C /usr/local/
    44 changes: 44 additions & 0 deletions install-iojs.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #!/bin/bash

    # Usage:
    # ./install-iojs.sh
    # or for nightly:
    # ./install-iojs.sh --nightly
    # or for next-nightly:
    # ./install-iojs.sh --next-nightly

    hasxz=$(which xzcat)
    os=$(uname | tr '[A-Z]' '[a-z]')
    arch=$(uname -m)

    [[ "$arch" == "x86_64" ]] && arch=x64
    [[ "$arch" == "x686" ]] && arch=x32

    type=release
    [[ "X$1" == "X--nightly" ]] && type=nightly
    [[ "X$1" == "X--next-nightly" ]] && type=next-nightly

    latest=$(curl -sL https://iojs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }')

    while true; do
    echo -n "Download and install io.js ${latest} (${os}/${arch})? [y/n] "
    yorn=""
    read yorn

    if [ "X${yorn}" == "Xn" ]; then
    break
    fi

    if [ "X${yorn}" == "Xy" ]; then
    url="https://iojs.org/download/${type}/$latest/iojs-${latest}-${os}-${arch}.tar"
    if [ "X${hasxz}" == "X" ]; then
    url="${url}.gz"
    pipecmd="| tar -zvx --strip-components=1 -C /usr/local/"
    else
    url="${url}.xz"
    pipecmd="| xzcat | tar -vx --strip-components=1 -C /usr/local/"
    fi
    bash -c "curl -sL '${auth}' '${url}' ${pipecmd}"
    break
    fi
    done
  12. rvagg revised this gist Apr 14, 2015. 2 changed files with 18 additions and 0 deletions.
    File renamed without changes.
    18 changes: 18 additions & 0 deletions install-iojs-nightly-osx.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash

    # Usage:
    # sudo ./install-iojs-nightly.sh
    # or for next-nightly:
    # sudo ./install-iojs-nightly.sh next

    type=nightly
    if [ "X$1" == "Xnext" ]; then
    type=next-nightly
    fi

    latest=$(curl -sL https://iojs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }')
    url="https://iojs.org/download/${type}/$latest/iojs-${latest}-darwin-x64.tar.gz"

    echo "Downloading ${url}..."

    curl -sL $url | tar -vzx --strip-components=1 -C /usr/local/
  13. rvagg created this gist Apr 12, 2015.
    18 changes: 18 additions & 0 deletions install-iojs-nightly.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash

    # Usage:
    # sudo ./install-iojs-nightly.sh
    # or for next-nightly:
    # sudo ./install-iojs-nightly.sh next

    type=nightly
    if [ "X$1" == "Xnext" ]; then
    type=next-nightly
    fi

    latest=$(curl -sL https://iojs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }')
    url="https://iojs.org/download/${type}/$latest/iojs-${latest}-linux-x64.tar.xz"

    echo "Downloading ${url}..."

    curl -sL $url | xzcat | tar -vx --strip-components=1 -C /usr/local/