/
manage.sh
107 lines (84 loc) · 1.89 KB
/
manage.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
#!/usr/bin/env bash
###
# Generalized Scripts for Python setup
# @author: Alvin Wan
# @site: alvinwan.com
###
function gs_install {
if [[ $CONDA == "false" ]];
then
# install virtualenv
check=`virtualenv --version`
[ $? != 0 ] && sudo pip3 install virtualenv
# create env
virtualenv -p python3 env;
# activate virtualenv
source env/bin/activate
else
# check for env
conda create -n piipod python=3.4
# activate env
source activate piipod;
fi
# install
pip install --upgrade pip
pip install -r requirements.txt
pip install git+https://github.com/python-constraint/python-constraint.git
# add configuration file if does not exist
if [ ! -f "configvars.py" ];
then cp sampleconfigvars.py configvars.py
fi
echo "---
[OK] Installation complete.
Use 'make db' to create the database. Use 'make refresh' to DELETE the old
database and recreate one using the new schema.
"
}
function gs_check {
echo '3 checks:'
exit=`python3 --version`
if [ $? != 0 ];
then echo '[Error] Python3 not found';
else echo '[OK] Python3 found'
fi
exit=`mysql --version`
if [ $? != 0 ];
then echo '[Error] MySQL not found';
else echo '[OK] MySQL found'
fi
exit=`conda --version`
if [ $? != 0 ];
then echo '[Error] (Optional) Anaconda not found';
else echo '[OK] Anaconda found'
fi
}
function gs_activate {
if [[ $CONDA == "true" ]];
then
# check for virtualenv
if [ -d "env" ];
then python3 -m venv env
fi
# activate virtualenv
source env/bin/activate
else
# activate env
source activate piipod;
fi
echo "---
[OK] Virtualenv activated.
"
}
###
# Commands
# source manage.sh [command]
###
if [[ $1 == "activate" ]];
then gs_activate
fi
if [[ $1 == "check" ]];
then gs_check
fi
if [[ $1 == "install" ]];
then gs_install
fi