install 3.43 KB
Newer Older
1
2
#!/bin/bash

3
##########################################################################################
4
#
5
# Site.js version 00000000000000/00.00.00 Installer for Linux (x86 and ARM) and macOS.
6
7
8
9
10
#
# To use:
#
# wget -qO- https://sitejs.org/install | bash
#
11
# Copyright (c) 2019-2020 Aral Balkan.
Aral Balkan's avatar
Aral Balkan committed
12
13
14
# 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
20
echo " 📡 Downloading Site.js version 00000000000000/00.00.00…"
21
22
23
24
25
26

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

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
releaseType=$1

if [[ "$releaseType" == "alpha" ]]; then
  # Writes ALPHA in large red block letters.
  echo -e '\033[31m'
  echo '     █████  ██      ██████  ██   ██  █████'
  echo '    ██   ██ ██      ██   ██ ██   ██ ██   ██ '
  echo '    ███████ ██      ██████  ███████ ███████ '
  echo '    ██   ██ ██      ██      ██   ██ ██   ██ '
  echo '    ██   ██ ███████ ██      ██   ██ ██   ██'
  echo -e '\033[0m'
elif [[ "$releaseType" == "beta" ]]; then
  # Writes BETA in large yellow block letters.
  echo -e '\033[33m'
  echo '    ██████  ███████ ████████  █████ '
  echo '    ██   ██ ██         ██    ██   ██ '
  echo '    ██████  █████      ██    ███████ '
  echo '    ██   ██ ██         ██    ██   ██ '
  echo '    ██████  ███████    ██    ██   ██'
  echo -e '\033[0m'
else
  # Ignore any other type and default to the release version.
49
  releaseType='release'
50
51
fi

52
53
54
55
56
# Setup
rm -rf /tmp/sitejs.org
mkdir -p /tmp/sitejs.org
pushd /tmp/sitejs.org > /dev/null

57
if [[ "$OSTYPE" == "linux-gnu" || "$OSTYPE" == "linux-gnueabihf" ]]; then
58
  cpuArchitecture=`uname -m`
59
  if [[ "$cpuArchitecture" == "x86_64" ]]; then
60
    # Linux on x64.
61
    wget -q "https://sitejs.org/binaries/${releaseType}/linux/00000000000000.tar.gz"
62
63
  elif [[ "$cpuArchitecture" == "armv7l" || "$cpuArchitecture" == "armv6l" ]]; then
    # Linux on ARM. Tested on Raspberry Pi Zero W (armv6l), 3B+ and 4B (both reporting armv7l).
64
    wget -q "https://sitejs.org/binaries/${releaseType}/linux-arm/00000000000000.tar.gz"
65
66
  else
    # Unsupported
67
68
69
    echo
    echo " ❌ Error: this architecture is not supported on Linux (only x86_64, armv6l, and armv7l are)."
    echo
70
71
72
    cleanUp
    exit 1
  fi
73
74
elif [[ "$OSTYPE" == "darwin"* ]]; then
  # macOS
75
  curl -Os "https://sitejs.org/binaries/${releaseType}/macos/00000000000000.tar.gz"
76
77
else
  # Unsupported
78
79
80
  echo
  echo " ❌ Error: this operating system is not supported."
  echo
81
82
83
84
85
  cleanUp
  exit 1
fi

echo " 📦 Installing…"
86
87
gzip -d 00000000000000.tar.gz
tar -xf 00000000000000.tar
88
89
90
91
92

# 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.
93
94
95
96
97
98
sudo mv site /usr/local/bin/

cleanUp

echo " 🎉 Done!"
echo