forked from cytoscape/appstore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
186 lines (135 loc) · 6.47 KB
/
bootstrap.sh
File metadata and controls
186 lines (135 loc) · 6.47 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env bash
# update apt database
dnf update
# install base packages
dnf install -y epel-release setroubleshoot wget httpd httpd-devel lsof unzip mariadb-server mod_ssl python3-mod_wsgi openssl-devel bzip2-devel libffi-devel zlib-devel make libjpeg-turbo-devel gcc
dnf install -y certbot python3-certbot-apache
# install miniconda 3 with python 3.11
# to try newer versions just pick newer version of miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-py311_24.5.0-0-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/httpd/conf.d/wsgi.conf"
SITE_PKG=`find /opt/miniconda3 -regex "/opt/miniconda3/lib/python.*/site-packages$" -type d 2> /dev/null`
echo "<IfModule !wsgi_module>" > $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/httpd/conf.modules.d/10-wsgi-python3.conf
# 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
# Enable and start mysql database
systemctl enable mariadb
systemctl start mariadb
# 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/media/pending_releases
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/media(/.*)?"
restorecon -rv /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 apache:apache /var/www
find /var/www -type d -exec chmod 2750 {} \+
find /var/www -type f -exec chmod 640 {} \+
# Replace default site configuration
mkdir /etc/httpd/includes
cp /vagrant/appstore.include.conf /etc/httpd/includes/.
cp /vagrant/appstore.http.conf /etc/httpd/conf.d/appstore.conf
# update port to 8080 which needs to match forwarded port in Vagrantfile
sed -i "s/@@PORT@@/8080/g" /etc/httpd/conf.d/appstore.conf
# update ssl protocol
sed -i "s/@@SSLPROTOCOL@@/All -SSLv2 -SSLv3/g" /etc/httpd/conf.d/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/httpd/conf.d/appstore.conf
#
#sed -i "s/^.*SSLCertificateFile.*$/SSLCertificateFile \/etc\/ssl\/certs\/ssl-cert-snakeoil.pem/g" /etc/httpd/conf.d/appstore.conf
#sed -i "s/^.*SSLCertificateKeyFile.*$/SSLCertificateKeyFile \/etc\/ssl\/private\/ssl-cert-snakeoil.key/g" /etc/httpd/conf.d/appstore.conf
#sed -i "s/^.*SSLCertificateChainFile.*$//g" /etc/httpd/conf.d/appstore.conf
echo "Listen 8080" > /etc/httpd/conf.d/ports.conf
setsebool -P httpd_can_network_connect 1
semanage fcontext -a -t httpd_sys_content_t '/var/www/appstore/wsgi.py'
semanage fcontext -a -t httpd_sys_content_t '/var/www/appstore/'
restorecon -Rv /var/www/appstore/
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/appstore/logs'
restorecon -v /var/www/appstore/logs
setsebool -P httpd_unified 1
# need to set a name for the server
echo "ServerName 127.0.0.1" >> /etc/httpd/conf/httpd.conf
# Reload apache
systemctl stop httpd
systemctl start httpd
echo ""
echo "Visit http://localhost:8080"
echo ""
echo "or to test vagrant ssh ; cd /var/www/$APPSTORE ; coverage run --source '.' manage.py test"
echo ""