This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
install.sh
executable file
·108 lines (86 loc) · 3.14 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
{ # evaluate this block in a stream
info() { echo "👉 $@"; }
warn() { echo "🚨 $@"; }
die() {
echo "💣💥 $@"
echo ""
echo "Please check ros-install.log for more details."
exit 1
}
user_id=$(id -u)
if [ "${user_id}" = "0" ]; then
warn "Attempting to install as root, which is usually unnecessary. For security reasons, it is not recommended to install or run Realm Object Server as root."
if [ "${SKIP_PROMPT}" = "" ]; then
read -p "Are you sure you would like to continue as root? (y/N): " -n 1 -r
echo ""
case "${REPLY}" in
y|Y ) warn "Installing Realm Object Server as root...";;
n|N ) exit 1;;
* ) exit 1;;
esac
# #echo # (optional) move to a new line
# if [ $REPLY =~ ^[Yy]$ ]; then
# exit 1
# fi
fi
export NPM_CONFIG_UNSAFE_PERM=true
else
info "Installing Realm Object Server..."
fi
# TODO: check architecture and other prerequisites here.
platform=$(uname)
if [ "${platform}" = "Linux" ]; then
arch=$(uname -p)
if [ "${arch}" != "x86_64" ]; then
die "Detected unsupported CPU architecture: ${arch}. Only x86_64 is supported on Linux."
fi
fi
if [ "$NVM_DIR" = "" ]; then
nvm_url="https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh"
warn "NVM was not found. Installing from ${nvm_url}..."
(curl -s -o- "${nvm_url}" | bash) > ros-install.log 2>&1 || die "Could not install nvm."
export NVM_DIR="$HOME/.nvm"
nvm_installed=1
fi
if [ -s "$NVM_DIR/nvm.sh" ]; then
nvm_sh="$NVM_DIR/nvm.sh" # This loads nvm
elif [ "${platform}" = "Darwin" ]; then
# there is a possibility that NVM was installed by homebrew...
brew_prefix=$(brew --prefix nvm 2>/dev/null || true)
if [ "${brew_prefix}" != "" ]; then
nvm_sh="${brew_prefix}/nvm.sh"
fi
fi
[ -s "${nvm_sh}" ] || die "You have $NVM_DIR defined, but I could not find nvm.sh!"
. "${nvm_sh}" || die "Could not load nvm!" # This loads nvm
info "Installing/Using NodeJS LTS..."
nvm install lts/* > ros-install.log 2>&1 || die "Could not install NodeJS."
node_version=$(nvm current)
info "Using Node.js ${node_version}"
info "Upgrading npm..."
npm install -g npm > ros-install.log 2>&1 || die "Could not upgrade npm."
PACKAGE=${PACKAGE:-realm-object-server}
info "Installing ${PACKAGE}..."
npm install -g "${PACKAGE}" > ros-install.log 2>&1 || die "Could not install ${PACKAGE}."
cat - <<-EOD
🎉 Realm Object Server is now installed!
When using Realm Object Server, remember to load the proper Node.js version
into your shell:
nvm use ${node_version}
Here are some quick-start commands:
ros start # Start ROS with defaults
ros init my-ros # Initialize a new custom ROS project
ros help # Print usage information
EOD
if [ "${nvm_installed}" = "1" ]; then
cat - <<-EOD
!!!! NOTICE !!!!
We have installed NVM, The NodeJS Version Manager for you. In order to continue, you will
need to inject NVM into your current shell. You do do so by running:
export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh" # This loads nvm
Enjoy!
EOD
fi
}