forked from cytoscape/appstore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
171 lines (128 loc) · 5.98 KB
/
bootstrap.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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env bash
# update apt database
apt-get update
# install base packages
apt-get -y install apache2 apache2-dev apache2-utils ssl-cert wget unzip
apt-get -y install libapache2-mod-wsgi-py3 gcc g++
apt-get -y install mysql-server
apt-get -y install libjpeg8-dev
# not sure if this is needed anymore
apt-get -y install geoip-database
# install miniconda 3 with python 3.7
# to try newer versions just pick newer version of miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-Linux-x86_64.sh
chmod a+x Miniconda*sh
./Miniconda*.sh -p /opt/miniconda3 -b
# set path to miniconda -- should really add to /etc/profile.d so everyone gets it
export PATH=/opt/miniconda3/bin:$PATH
echo "export PATH=/opt/miniconda3/bin:$PATH" >> /root/.bash_profile
echo "export PATH=/opt/miniconda3/bin:$PATH" >> /root/.bashrc
sudo -u vagrant echo "export PATH=/opt/miniconda3/bin:$PATH" >> /home/vagrant/.bash_profile
# install mysqlclient
conda install -y mysqlclient
# install mod_wsgi
pip install mod_wsgi
# following mod_wsgi instructions found here:
# https://ostrokach.gitlab.io/post/apache-django-anaconda/
#
# update wsgi.conf configuration
WSGI_CONF="/etc/apache2/mods-available/wsgi.conf"
SITE_PKG=`find /opt/miniconda3 -regex "/opt/miniconda3/lib/python.*/site-packages$" -type d 2> /dev/null`
echo "<IfModule mod_wsgi.c>" > $WSGI_CONF
echo " WSGIPythonHome /opt/miniconda3" >> $WSGI_CONF
echo " WSGIPythonPath $SITE_PKG" >> $WSGI_CONF
echo "</IfModule>" >> $WSGI_CONF
# update wsgi.load file
mod_wsgi-express install-module | egrep "^LoadModule" > /etc/apache2/mods-available/wsgi.load
# enable wsgi
a2enmod wsgi
# updates shared library cache
ldconfig
pip install -r /vagrant/requirements.txt
# Ran into error when trying to call python manage.py scripts on 7-23-2021
#
# File "/opt/miniconda3/lib/python3.9/site-packages/social_django/models.py", line 11, in <module>
# from .storage import DjangoUserMixin, DjangoAssociationMixin, \
# File "/opt/miniconda3/lib/python3.9/site-packages/social_django/storage.py", line 9, in <module>
# from social_core.storage import UserMixin, AssociationMixin, NonceMixin, \
# File "/opt/miniconda3/lib/python3.9/site-packages/social_core/storage.py", line 9, in <module>
# from openid.association import Association as OpenIdAssociation
# File "/opt/miniconda3/lib/python3.9/site-packages/openid/__init__.py", line 52, in <module>
# if len(version_info) != 3:
# TypeError: object of type 'map' has no len()
#
# Found fix was to remove python-openid and python3-openid and install python3-openid again
#
pip uninstall python-openid -y
pip uninstall python3-openid -y
pip install python3-openid
# for code coverage
pip install coverage
# create database
mysqladmin create AppStore
dbpass=`uuidgen`
echo ""
echo "The database password will be set to: $dbpass"
echo "In case its need look at /tmp/createdb.sql"
echo ""
cat /vagrant/createdb.sql | sed "s/@@PASSWORD@@/$dbpass/g" > /tmp/createdb.sql
mysql -u root < /tmp/createdb.sql
APPSTORE="appstore"
cd /var/www
mkdir $APPSTORE
cd $APPSTORE
cp -a /vagrant/* .
mkdir logs
mkdir /var/www/html/media
mkdir /var/www/html/misc
cp /vagrant/favicon.ico /var/www/html/misc/.
cp /vagrant/google_oauth2_logo.png /var/www/html/misc/.
# update the database password
sed -i "s/@@PASSWORD@@/$dbpass/g" /var/www/$APPSTORE/settings/vagrant.py
# update wsgi
sed -i "s/settings.local/settings.vagrant/g" /var/www/$APPSTORE/wsgi.py
# update manage.py
sed -i "s/settings.local/settings.vagrant/g" /var/www/$APPSTORE/manage.py
rm /var/www/$APPSTORE/appstore.http.conf
rm /var/www/$APPSTORE/appstore.include.conf
cd /var/www/$APPSTORE
python manage.py makemigrations apps --noinput
python manage.py makemigrations backend --noinput
python manage.py makemigrations download --noinput
python manage.py makemigrations help --noinput
python manage.py makemigrations search --noinput
python manage.py makemigrations submit_app --noinput
python manage.py makemigrations users --noinput
python manage.py makemigrations --noinput
python manage.py migrate --noinput
python manage.py rebuild_index --noinput
python manage.py collectstatic --noinput
# fix permissions
chown -R www-data:www-data /var/www
find /var/www -type d -exec chmod 2750 {} \+
find /var/www -type f -exec chmod 640 {} \+
# Replace default site configuration
mkdir /etc/apache2/includes
cp /vagrant/appstore.include.conf /etc/apache2/includes/.
cp /vagrant/appstore.http.conf /etc/apache2/sites-available/appstore.conf
# update port to 8080 which needs to match forwarded port in Vagrantfile
sed -i "s/@@PORT@@/8080/g" /etc/apache2/sites-available/appstore.conf
# update ssl protocol
sed -i "s/@@SSLPROTOCOL@@/All -SSLv2 -SSLv3/g" /etc/apache2/sites-available/appstore.conf
# update ciphersuite
sed -i "s/@@SSLCIPHERSUITE@@/ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK/g" /etc/apache2/sites-available/appstore.conf
#
sed -i "s/^.*SSLCertificateFile.*$/SSLCertificateFile \/etc\/ssl\/certs\/ssl-cert-snakeoil.pem/g" /etc/apache2/sites-available/appstore.conf
sed -i "s/^.*SSLCertificateKeyFile.*$/SSLCertificateKeyFile \/etc\/ssl\/private\/ssl-cert-snakeoil.key/g" /etc/apache2/sites-available/appstore.conf
sed -i "s/^.*SSLCertificateChainFile.*$//g" /etc/apache2/sites-available/appstore.conf
echo "Listen 8080" >> /etc/apache2/ports.conf
a2enmod ssl
a2dissite 000-default.conf
a2ensite appstore.conf
# Reload apache
systemctl reload apache2
echo ""
echo "Visit http://localhost:8080 or https://localhost:8443"
echo ""
echo "or to test vagrant ssh ; cd /var/www/$APPSTORE ; coverage run --source '.' manage.py test"
echo ""