-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathinstall.sh
executable file
·97 lines (75 loc) · 2.85 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
#!/bin/bash -e
# NodeJS Settings
NODE_VERSION=7.6.0
# Database Settings
PSQL_VERSION=9.6
PSQL_USERNAME=yara_guardian
PSQL_PASSWORD=yara_guardian_password
PSQL_DATABASE=yara_guardian
PSQL_HOST=127.0.0.1
PSQL_PORT=5432
if [ "$1" = "vagrant" ]; then
INSTALL_DIR="/vagrant"
HOME_PROFILE="/home/ubuntu/.profile"
# Set environment variables
echo "export DEBUG=True" >> ${HOME_PROFILE}
echo "export SECRET_KEY=DEVELOPMENT_MODE" >> ${HOME_PROFILE}
echo "export DATABASE_NAME=${PSQL_DATABASE}" >> ${HOME_PROFILE}
echo "export DATABASE_USER=${PSQL_USERNAME}" >> ${HOME_PROFILE}
echo "export DATABASE_PASS=${PSQL_PASSWORD}" >> ${HOME_PROFILE}
echo "export DATABASE_HOST=${PSQL_HOST}" >> ${HOME_PROFILE}
echo "export DATABASE_PORT=${PSQL_PORT}" >> ${HOME_PROFILE}
echo "export GUEST_REGISTRATION=INVITE" >> ${HOME_PROFILE}
else
INSTALL_DIR=${PWD}
fi
apt-get update
apt-get -y upgrade
####################################
### Install Python3 dependencies ###
####################################
echo "Installing Python 3 and other system dependencies"
apt-get install -y python3-all-dev libpq-dev python3-pip
#####################################
### Add PostgreSQL Apt Repository ###
#####################################
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > \
/etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
sudo apt-get update
#################################################
### Install and configure PostgreSQL database ###
#################################################
echo "Installing Postgresql Database ${PSQL_VERSION}"
apt-get install -y postgresql-${PSQL_VERSION} postgresql-server-dev-${PSQL_VERSION}
echo "Starting Postgresql Server"
systemctl start postgresql
echo "Configuring Postgresql Database"
sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS hstore"
sudo -u postgres psql -c "CREATE DATABASE ${PSQL_DATABASE}"
sudo -u postgres psql -c "CREATE USER ${PSQL_USERNAME} WITH PASSWORD '${PSQL_PASSWORD}' CREATEDB"
###################################################
### Install and configure Yarn package manager ###
###################################################
echo "Installing and Configuring yarn"
apt-get install -y git npm
# Get Specified Version of Node
npm cache clean -f
npm install -g n
n ${NODE_VERSION}
ln -sf /usr/local/n/versions/node/${NODE_VERSION}/bin/node /usr/bin/node
#################################################
### Install Python and front-end dependencies ###
#################################################
cd ${INSTALL_DIR}
echo "Installing Python dependencies"
export PIPENV_VENV_IN_PROJECT=true
pip3 install pipenv
pipenv install --deploy
# Install dependencies
echo "Installing front-end dependencies"
npm install
npm install yarn -g
yarn
yarn webpack