install 1.82 KB
Newer Older
1 2 3 4
#!/bin/bash

######################################################################
#
Aral Balkan's avatar
Aral Balkan committed
5
# Site.js v12.10.5 Installer for Linux (x86 and armv7l) and macOS.
6 7 8 9 10
#
# To use:
#
# wget -qO- https://sitejs.org/install | bash
#
11 12 13 14
# Copyright (c) 2019 Aral Balkan.
# Released under the AGPL version 3.0 or later license.
# Made with ♥ by Small Technology Foundation (https://small-tech.org)
# Like this? Fund us! (https://small-tech.org/fund-us)
15 16 17 18 19
#
######################################################################

set -e
echo
Aral Balkan's avatar
Aral Balkan committed
20
echo " 📡 Downloading Site.js v12.10.5…"
21 22 23 24 25 26 27 28 29 30 31

function cleanUp {
  popd > /dev/null
  rm -rf /tmp/sitejs.org
}

# Setup
rm -rf /tmp/sitejs.org
mkdir -p /tmp/sitejs.org
pushd /tmp/sitejs.org > /dev/null

32
if [[ "$OSTYPE" == "linux-gnu" || "$OSTYPE" == "linux-gnueabihf" ]]; then
33
  cpuArchitecture=`uname -m`
34
  if [[ "$cpuArchitecture" == "x86_64" ]]; then
35
    # Linux on x64.
Aral Balkan's avatar
Aral Balkan committed
36
    wget -q https://sitejs.org/releases/linux/12.10.5.tar.gz
37 38
  elif [[ "$cpuArchitecture" == "armv7l" || "$cpuArchitecture" == "armv6l" ]]; then
    # Linux on ARM. Tested on Raspberry Pi Zero W (armv6l), 3B+ and 4B (both reporting armv7l).
Aral Balkan's avatar
Aral Balkan committed
39
    wget -q https://sitejs.org/releases/linux-arm/12.10.5.tar.gz
40 41
  else
    # Unsupported
42
    echo "\n ❌ Error: this architecture is not supported on Linux (only x86_64, armv6l, and armv7l are).\n"
43 44 45
    cleanUp
    exit 1
  fi
46 47
elif [[ "$OSTYPE" == "darwin"* ]]; then
  # macOS
Aral Balkan's avatar
Aral Balkan committed
48
  curl -Os https://sitejs.org/releases/macos/12.10.5.tar.gz
49 50 51 52 53 54 55 56
else
  # Unsupported
  echo "\n ❌ Error: this operating system is not supported.\n"
  cleanUp
  exit 1
fi

echo " 📦 Installing…"
Aral Balkan's avatar
Aral Balkan committed
57 58
gzip -d 12.10.5.tar.gz
tar -xf 12.10.5.tar
59 60 61 62 63

# Ensure that the /usr/local/bin directory exists (it does not by default on macOS)
sudo mkdir -p /usr/local/bin/

# Move the site binary there.
64 65 66 67 68 69
sudo mv site /usr/local/bin/

cleanUp

echo " 🎉 Done!"
echo