Skip to content

Instantly share code, notes, and snippets.

@ashthespy
Last active May 23, 2020 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashthespy/5b86da9f0144ffa4af7efe94ec1884cd to your computer and use it in GitHub Desktop.
Save ashthespy/5b86da9f0144ffa4af7efe94ec1884cd to your computer and use it in GitHub Desktop.
#!/bin/bash
# Setup nodejs on armv6l Volumio Buster images
set -eo pipefail
source /etc/os-release
echo "Running Volumio Buster ${VOLUMIO_VERSION} patch script"
[ "${VERSION_CODENAME}" == 'buster' ] || { echo "OS isn't buster, nothing to do"; exit 0; }
# grep -q 'buster' /etc/os-release || { echo "OS isn't buster, nothing to do"; exit 0; }
NODE_VERSION=14
DOMAIN="unofficial-builds.nodejs.org"
INSTAL_DIR="/usr"
TAR_ARGS=("--strip-components=1" "--exclude" "**/*.md" "--exclude" "**/LICENSE" "-C" "${INSTAL_DIR}")
echo "Check for pi0/pi1"
arch=$(lscpu | awk 'FNR == 1 {print $2}')
arch=armv6l
if [ "$arch" == 'armv6l' ]; then
if dpkg -s nodejs &> /dev/null; then
echo "Removing previous nodejs installation from $(command -v node)"
echo Node "$(node --version)" arm_version: "$(node <<< 'console.log(process.config.variables.arm_version)')"
sudo apt-get -y purge nodejs
fi
echo "Proceeding fetchiing node for ${arch}"
latest=$(curl -sL https://${DOMAIN}/download/release/index.tab | grep "^v${NODE_VERSION}" | awk '/^v[0-9]/{ print $1; exit }')
url="https://${DOMAIN}/download/release/$latest/node-${latest}-linux-${arch}.tar.gz"
echo "Installing Node ${latest}-linuex-${arch}"
echo "Downloading from ${url}"
curl -L "${url}" -o "node-${latest}-linux-${arch}.tar.gz"
sudo tar -xf node-"${latest}"-linux-${arch}.tar.gz "${TAR_ARGS[@]}"
rm node-"${latest}"-linux-${arch}.tar.gz
else
echo "Nothing to do for ${arch}" && exit 0
fi
echo "Installed nodejs at $(command -v node)"
echo Node "$(node --version)" arm_version: "$(node <<< 'console.log(process.config.variables.arm_version)')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment