icp/dev/run-internal.sh

62 lines
1.8 KiB
Bash
Raw Normal View History

2018-05-05 20:56:32 +00:00
#!/bin/bash -e
2018-05-06 12:11:47 +00:00
#adduser --system --no-create-home --home /data --uid 1000 www-user
#sed -i "s/APACHE_RUN_USER=www-data/APACHE_RUN_USER=www-user/" /etc/apache2/envvars
2018-05-05 22:18:02 +00:00
sed -i "s#data_directory = '.*'#data_directory = '/data/run/postgres'#" /etc/postgresql/10/main/postgresql.conf
2018-05-06 14:17:41 +00:00
# for deploy mode with SSL:
if [[ -e /data/ssl/fullchain1.pem ]] ; then
a2enmod ssl || true
rm /etc/apache2/sites-enabled/apache-local.conf
ln -s /data/dev/apache-deploy.conf /etc/apache2/sites-enabled/
fi
2018-05-05 22:18:02 +00:00
2018-05-05 20:41:55 +00:00
/etc/init.d/apache2 start
tail -f /var/log/apache2/error.log &
2018-05-05 20:56:32 +00:00
2018-05-05 22:18:02 +00:00
export OER_SRC_DIR=/data/oer
export PLATFORM_PATH=/data/src
2018-05-06 14:17:41 +00:00
/etc/init.d/docker start
2018-05-05 20:56:32 +00:00
V="/data/run/virtualenv"
if [[ ! -e $V ]] ; then
2018-05-06 14:17:41 +00:00
mkdir -p /data/run/postgres
chown postgres /data/run/postgres
rm -rf /var/lib/postgresql/10/main/
sudo -u postgres /usr/lib/postgresql/10/bin/initdb -D /data/run/postgres
/etc/init.d/postgresql restart
2018-05-06 10:41:40 +00:00
sudo -u postgres psql -c "CREATE USER hoou WITH PASSWORD 'hoohoohoo123';"
sudo -u postgres psql -c "CREATE DATABASE hoou;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE hoou to hoou;"
# psql -h localhost -U hoou hoou # should work
2018-05-05 20:56:32 +00:00
mkdir -p $V
virtualenv -p python3 $V
cd $V
source $V/bin/activate
pip3 install -U -r /data/dev/requirements.txt
2018-05-06 08:18:42 +00:00
pip3 install --ignore-installed python-social-auth
2018-05-06 14:17:41 +00:00
cd /data/src
sed -i "s/'generated_exercises',/#'generated_exercises',/" main/settings.py
2018-05-05 22:18:02 +00:00
python3 ./manage.py migrate
2018-05-06 14:19:28 +00:00
sed -i "s/#'generated_exercises',/'generated_exercises',/" main/settings.py
2018-05-06 14:17:41 +00:00
mkdir /data/run/jobs/
chown www-data /data/run/jobs/
2018-05-06 12:11:47 +00:00
# prepare docker image for worker
docker build -t kunkel/oer-worker /data/dev/worker
2018-05-06 14:17:41 +00:00
else
/etc/init.d/postgresql restart
source $V/bin/activate
2018-05-05 20:56:32 +00:00
fi
2018-05-05 22:18:02 +00:00
2018-05-06 14:17:41 +00:00
/data/scripts/update-courses.sh
# hardening...
2018-05-05 20:56:32 +00:00
2018-05-05 20:41:55 +00:00
/bin/bash