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

3
######################################################################
4
#
5
# Site.js installer for Linux (x86 and ARM) and macOS.
6
#
7
# Usage:
8
9
10
#
# wget -qO- https://sitejs.org/install | bash
#
11
12
13
14
15
16
17
# Or:
#
# curl -s https://sitejs.org/install | bash
#
# For alpha, replace bash with bash -s -- alpha
# For beta, replace bash with bash -s -- beta
#
18
# Copyright (c) 2019-2020 Aral Balkan.
Aral Balkan's avatar
Aral Balkan committed
19
20
# Released under the AGPL version 3.0 or later license.
# Made with ♥ by Small Technology Foundation (https://small-tech.org)
21
#
Aral Balkan's avatar
Aral Balkan committed
22
# Like this? Fund us! (https://small-tech.org/fund-us)
23
#
24
######################################################################
25

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Use either wget or curl to download the Site.js binary,
# whichever exists on the system (favour wget).
which wget > /dev/null
if [ $? -eq 0 ]
then
  # wget exists, we’ll use that.
  download="wget -q"
else
  which curl > /dev/null
  if [ $? -eq 0 ]
  then
    # curl exists, we’ll use that.
    download="curl -Os"
  else
    echo
    echo " ❌ The installation script needs either wget or curl installed to continue."
    echo
    exit 1
  fi
fi

47
48
49
50
51
52
53
set -e

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

54
releaseChannel=$1
55

56
# Release is the default release type (others are alpha and beta).
57
58
if [[ "$releaseChannel" == "" ]]; then
  releaseChannel='release'
59
60
fi

Aral Balkan's avatar
Aral Balkan committed
61
62
63
alphaBinaryVersion=20200823174121
alphaPackageVersion=14.3.0
alphaSourceVersion=90f059c
64

65
66
67
betaBinaryVersion=20200710135219
betaPackageVersion=14.1.1
betaSourceVersion=afde7bd
68

69
70
71
releaseBinaryVersion=20210427154519
releasePackageVersion=17.0.1
releaseSourceVersion=ce0e969
72

73
74
75
binaryVersionVariableName="${releaseChannel}BinaryVersion"
packageVersionVariableName="${releaseChannel}PackageVersion"
sourceVersionVariableName="${releaseChannel}SourceVersion"
76
77

binaryVersion=${!binaryVersionVariableName}
78
packageVersion=${!packageVersionVariableName}
79
80
81
sourceVersion=${!sourceVersionVariableName}

if [[ "$binaryVersion" == "00000000000000" ]]; then
82
  echo " ❌ Sorry, no Site.js ${releaseChannel} binaries have been released yet."
83
84
85
86
87
  cleanUp
  exit 1
fi

echo
88
echo " 📡 Downloading Site.js version ${binaryVersion} (${packageVersion}/${sourceVersion})…"
89
90

# Mark alpha and beta releases prominently.
91
if [[ "$releaseChannel" == "alpha" ]]; then
92

93
94
95
96
97
98
99
100
  # Writes ALPHA in large red block letters.
  echo -e '\033[31m'
  echo '     █████  ██      ██████  ██   ██  █████'
  echo '    ██   ██ ██      ██   ██ ██   ██ ██   ██ '
  echo '    ███████ ██      ██████  ███████ ███████ '
  echo '    ██   ██ ██      ██      ██   ██ ██   ██ '
  echo '    ██   ██ ███████ ██      ██   ██ ██   ██'
  echo -e '\033[0m'
101

102
elif [[ "$releaseChannel" == "beta" ]]; then
103

104
105
106
107
108
109
110
111
  # Writes BETA in large yellow block letters.
  echo -e '\033[33m'
  echo '    ██████  ███████ ████████  █████ '
  echo '    ██   ██ ██         ██    ██   ██ '
  echo '    ██████  █████      ██    ███████ '
  echo '    ██   ██ ██         ██    ██   ██ '
  echo '    ██████  ███████    ██    ██   ██'
  echo -e '\033[0m'
112

113
114
fi

115
# Setup.
116
117
118
119
rm -rf /tmp/sitejs.org
mkdir -p /tmp/sitejs.org
pushd /tmp/sitejs.org > /dev/null

120
# Download the release.
121
if [[ "$OSTYPE" == "linux-gnu" || "$OSTYPE" == "linux-gnueabihf" ]]; then
122
  cpuArchitecture=`uname -m`
123
  if [[ "$cpuArchitecture" == "x86_64" ]]; then
124
    # Linux on x64.
125
    $download "https://sitejs.org/binaries/${releaseChannel}/linux/${binaryVersion}.tar.gz"
126
127
  elif [[ "$cpuArchitecture" == "armv7l" || "$cpuArchitecture" == "armv6l" ]]; then
    # Linux on ARM. Tested on Raspberry Pi Zero W (armv6l), 3B+ and 4B (both reporting armv7l).
128
    $download "https://sitejs.org/binaries/${releaseChannel}/linux-arm/${binaryVersion}.tar.gz"
129
130
  elif [[ "$cpuArchitecture" == "aarch64" ]]; then
    # Linux on ARM64. Tested with Pinebook Pro.
131
    $download "https://sitejs.org/binaries/${releaseChannel}/linux-arm64/${binaryVersion}.tar.gz"
132
  else
133
    # Error: unsupported architecture.
134
135
136
    echo
    echo " ❌ Error: this architecture is not supported on Linux (only x86_64, armv6l, and armv7l are)."
    echo
137
138
139
    cleanUp
    exit 1
  fi
140
141
elif [[ "$OSTYPE" == "darwin"* ]]; then
  # macOS
142
  $download "https://sitejs.org/binaries/${releaseChannel}/macos/${binaryVersion}.tar.gz"
143
else
144
  # Error: Unsupported operating system.
145
146
147
  echo
  echo " ❌ Error: this operating system is not supported."
  echo
148
149
150
151
  cleanUp
  exit 1
fi

152
# Install.
153
echo " 📦 Installing…"
154
155
gzip -d "${binaryVersion}.tar.gz"
tar -xf "${binaryVersion}.tar"
156

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

160
# Install the Site.js binary.
161
162
163
164
165
166
sudo mv site /usr/local/bin/

cleanUp

echo " 🎉 Done!"
echo