This repository was archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·43 lines (38 loc) · 1.56 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# A script to download and install the latest version
OS=$(uname)
if [[ "$OS" == "Linux" || "$OS" == "Darwin" ]]; then
case "$OS" in
'Linux')
PLATFORM="linux-x64"
if [ -z "$1" ]; then
VERSION=$(curl --silent "https://api.github.com/repos/stencila/nixta/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
else
VERSION=$1
fi
INSTALL_PATH="$HOME/.local/bin"
;;
'Darwin')
PLATFORM="macos-x64"
if [ -z "$1" ]; then
VERSION=$(curl --silent "https://api.github.com/repos/stencila/nixta/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
else
VERSION=$1
fi
INSTALL_PATH="/usr/local/bin"
;;
esac
echo "Downloading Nixta $VERSION"
curl -Lo /tmp/nixta.tar.gz https://github.com/stencila/nixta/releases/download/$VERSION/nixta-$PLATFORM.tar.gz
tar xvf /tmp/nixta.tar.gz
rm -f /tmp/nixta.tar.gz
echo "Installing nixta to $INSTALL_PATH/nixta-$VERSION/nixta"
mkdir -p $INSTALL_PATH/nixta-$VERSION
mv -f nixta $INSTALL_PATH/nixta-$VERSION
# Unpack `node_modules` etc into the $INSTALL_PATH/nixta-$VERSION
$INSTALL_PATH/nixta-$VERSION/nixta --version
echo "Pointing nixta to $INSTALL_PATH/nixta-$VERSION/nixta"
ln -sf nixta-$VERSION/nixta $INSTALL_PATH/nixta
else
echo "Sorry, I don't know how to install on this OS, please see https://github.com/stencila/nixta#install"
fi