forked from ggeop/Python-ai-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·148 lines (120 loc) · 4.03 KB
/
setup.sh
File metadata and controls
executable file
·148 lines (120 loc) · 4.03 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env bash
# -----------------------------------
# Initialization
# -----------------------------------
JARVIS_DIR=$(pwd)
VIRTUAL_ENV="jarvis_virtualenv"
green=`tput setaf 2`
red=`tput setaf 1`
reset=`tput sgr0`
# -----------------------------------
# Python version compatibility check
# -----------------------------------
version=$(python3 -V 2>&1 | grep -Po '(?<=Python )(.+)')
if [[ -z "$version" ]]
then
echo "${red} No Python 3.x.x in your system! Install Python and try again! ${reset}"
exit 1
else
PYTHON_PATH=$(which python3)
fi
#-----------------------------------
# System dependencies installation
#-----------------------------------
sudo apt-get update && /
sudo apt-get install python-dev && /
sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio && /
sudo apt-get install libasound2-plugins libsox-fmt-all libsox-dev sox ffmpeg && /
sudo apt-get install espeak && /
sudo apt-get install python3-pip && /
sudo apt-get install python3-setuptools
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "${green} System dependencies installation succeeded! ${reset}"
else
echo "${red} System dependencies installation failed ${reset}"
exit 1
fi
#-----------------------------------
# Install virtualenv
#-----------------------------------
pip3 install virtualenv
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "${green} Install virtualenv succeeded! ${reset}"
else
echo "${red} Install virtualenv failed ${reset}"
exit 1
fi
#-----------------------------------
# Create Jarvis virtual env
#-----------------------------------
virtualenv -p $PYTHON_PATH $JARVIS_DIR/$VIRTUAL_ENV
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "${green} Jarvis virtual env creation succeeded! ${reset}"
else
echo "${red} Jarvis virtual env creation failed ${reset}"
exit 1
fi
#-----------------------------------
# Install Python dependencies
#-----------------------------------
source $JARVIS_DIR/$VIRTUAL_ENV/bin/activate
# Install pip in virtualenv
sudo apt-get install python3-pip
# Install python requirements
pip3 install -r $JARVIS_DIR/requirements.txt
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "${green} Install Python dependencies succeeded! ${reset}"
else
echo "${red} Install Python dependencies failed ${reset}"
exit 1
fi
#-----------------------------------
# Install nltk dependencies
#-----------------------------------
python3 -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "${green} Install nltk dependencies succeeded! ${reset}"
else
echo "${red} Install nltk dependencies failed ${reset}"
exit 1
fi
#-----------------------------------
# Create log access
#-----------------------------------
sudo touch /var/log/jarvis.log && \
sudo chmod 777 /var/log/jarvis.log
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "${green} Create log access succeeded! ${reset}"
else
echo "${red}Create log access failed ${reset}"
exit 1
fi
#-----------------------------------
# Deactivate virtualenv
#-----------------------------------
deactivate
#-----------------------------------
# Install MongoDB Server
#-----------------------------------
# Install process: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
# Install gnupg
sudo apt-get install gnupg
# MongoDB public GPG Key
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
# Create the /etc/apt/sources.list.d/mongodb-org-4.2.list file for Ubuntu 16.04 (Xenial):
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
# Reload local package database
sudo apt-get update
# Install a specific release of MongoDB
sudo apt-get install -y mongodb-org=4.2.5 mongodb-org-server=4.2.5 mongodb-org-shell=4.2.5 mongodb-org-mongos=4.2.5 mongodb-org-tools=4.2.5
#-----------------------------------
# Finished
#-----------------------------------
echo "${green} Jarvis setup succeed! ${reset}"
echo "Start Jarvis: bash run_jarvis.sh"