-
Notifications
You must be signed in to change notification settings - Fork 689
/
setup.sh
74 lines (60 loc) · 1.99 KB
/
setup.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
#! /usr/bin/env bash
set -e
# Set up arguments
while test $# -gt 0
do
case "$1" in
-h|--help)
echo -e "\033[1;32m* \033[0mKnowledge Repo"
echo
echo "USAGE: ./setup.sh [OPTIONS]"
echo
echo "OPTIONS"
echo -e " -h or --help\t\tdisplay this help message"
exit 0
;;
esac
shift
done
echo
echo -e "\033[1;34m* \033[0mEnv Preparation"
sudo apt-get update -y1
sudo apt install software-properties-common -y1
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9 -y1
sudo apt-get install python3.9-venv -y1
PYTHON_VERSION=$(python3 -V | awk '{print $2}')
echo
echo -e "\033[1;34m* \033[0mDownload knowledge-repo"
git clone https://github.com/airbnb/knowledge-repo.git
echo
echo -e "\033[1;34m* \033[0mDownload default config"
wget -O config.py https://raw.githubusercontent.com/airbnb/knowledge-repo/master/knowledge_repo/app/config_defaults.py
echo
echo -e "\033[1;34m* \033[0mSetup Default Postgresql"
sudo apt install postgresql -y1
sudo su postgres <<EOF
psql -U postgres -c "CREATE ROLE knowledge_repo;"
psql -U postgres -c "ALTER ROLE knowledge_repo WITH LOGIN;"
psql -U postgres -c "ALTER USER knowledge_repo CREATEDB;"
psql -U postgres -c "ALTER USER knowledge_repo WITH PASSWORD 'password';"
psql -U postgres -c "CREATE DATABASE knowledge_repo;"
psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE knowledge_repo TO knowledge_repo;"
EOF
echo
echo -e "\033[1;35m* \033[0mCreating venv virtual environment in ./venv"
cd knowledge-repo
python3.9 -m venv venv
echo
echo -e "\033[1;35m* \033[0mActivating the venv"
source ./venv/bin/activate
echo
echo -e "\033[1;35m* \033[0mInstalling dependencies"
pip install --upgrade pip
pip install -r requirements.txt
echo
echo -e "\033[1;35m* \033[0mCreast Test Repo from Local File"
scripts/knowledge_repo --repo ../test_repo init
echo
echo -e "\033[1;35m* \033[0mStart Test Server"
scripts/knowledge_repo --repo ../test_repo runserver --port 7001