forked from tom-gall/android-report
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeploy-with-python2.sh
executable file
·114 lines (99 loc) · 4.16 KB
/
deploy-with-python2.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
109
110
111
112
113
114
#!/bin/bash -ex
if [ "/*" = "$0" ]; then
echo "Please run this script with absolute path"
exit 1
fi
if [ -n "$1" ]; then
work_root=$1
fi
if [ -d "${work_root}" ]; then
work_root=$(cd ${work_root}; pwd)
elif [ -d /sata250/django_instances ]; then
work_root="/sata250/django_instances"
elif [ -d /SATA3/django_instances ]; then
work_root="/SATA3/django_instances"
elif [ -d /home/yongqin.liu/django_instance ]; then
work_root="/home/yongqin.liu/django_instance"
else
echo "Please set the path for work_root"
exit 1
fi
instance_name="lcr-report"
instance_report_app="report"
instance_dir="${work_root}/${instance_name}"
virenv_dir="${work_root}/workspace"
mkdir -p ${virenv_dir}
cd ${virenv_dir}
# https://pip.pypa.io/en/latest/installing/#installing-with-get-pip-py
if [ ! -f get-pip.py ]; then
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
fi
sudo python get-pip.py
sudo apt-get update
#sudo apt-get install python-django-auth-ldap
## dependency for python-ldap
sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
#sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev tcl8.6-dev tk8.6-dev python-tk
# https://virtualenv.pypa.io/en/stable/
sudo pip install virtualenv
virtualenv ${virenv_dir}
source ${virenv_dir}/bin/activate
#(ENV)$ deactivate
#$ rm -r /path/to/ENV
#https://docs.djangoproject.com/en/1.11/topics/install/#installing-official-release
pip install Django==1.11.8
pip install pyaml
pip install lava-tool
pip install django-crispy-forms=1.8.1
#pip install psycopg2
pip install psycopg2-binary
pip install python-ldap # will install the 3.0 version
# https://django-auth-ldap.readthedocs.io/en/latest/install.html
pip install django-auth-ldap # needs python-ldap >= 3.0
#pip install bugzilla
pip install requests
pip install reportlab
## pip install Pillow
## pip install rst2pdf
# https://docs.djangoproject.com/en/1.11/intro/tutorial01/
python -m django --version
#python manage.py startapp ${instance_report_app}
# django-admin startproject ${instance_name}
cd ${work_root}
if [ -d lcr-report ]; then
cd lcr-report && git pull && cd -
else
git clone https://github.com/liuyq/android-report.git lcr-report
fi
cd lcr-report
mkdir -p datafiles/logfiles/
sudo chown -R :www-data datafiles
rm -fr db.sqlite3
python manage.py migrate
python manage.py createsuperuser
echo "Please access the site via http://127.0.0.1:9000/lkft"
echo "And you still need to update the bugzilla, qa-report tokens to resubmit job or create bugs"
python manage.py runserver 9000
# By running makemigrations, you’re telling Django that you’ve made some changes to your models (in this case,
# you’ve made new ones) and that you’d like the changes to be stored as a migration.
# python manage.py makemigrations report
# The migrate command looks at the INSTALLED_APPS setting and creates any necessary database tables according to the database settings
# in your mysite/settings.py file and the database migrations shipped with the app (we’ll cover those later)
# Need to run after makemigrations so that the tables for report could be created
# python manage.py migrate
# There’s a command that will run the migrations for you and manage your database schema automatically - that’s called migrate,
# and we’ll come to it in a moment - but first, let’s see what SQL that migration would run.
# The sqlmigrate command takes migration names and returns their SQL:
# Only shows the sql script, not creation
# python manage.py sqlmigrate report 0002
# cp db.sqlite3 db.sqlite3.bak.$(date +%Y%m%d-%H%M%S)
# scp android:/android/django_instances/lcr-report/db.sqlite3 ./
# cat jobs.txt |awk '{print $2}' >job-ids.txt
# sqlite3 db.sqlite3 "select * from report_testcase where job_id = 99965 ORDER BY name;"
# sqlite3 db.sqlite3 "delete from report_testcase where job_id = 99859;"
## with new db.sqlite3 file
## 1. remove the reference for the app in the lcr/urls.py
## 2. run python manage.py migrate to generate a new database
## 3. python manage.py createsuperuser to create a new user
## 4. setup build configs, lava uses from the admin ui
## 5. restartwith python manage.py runserver 0.0.0.0:9000