Skip to content

Instantly share code, notes, and snippets.

@javierwilson
Last active December 11, 2016 06:58
Show Gist options
  • Save javierwilson/a35d25d67f718faf4891e6de56b8863f to your computer and use it in GitHub Desktop.
Save javierwilson/a35d25d67f718faf4891e6de56b8863f to your computer and use it in GitHub Desktop.
deploy matos
#!/bin/bash
USER=matos
APP=$USER
DIR=/var/www/$APP
REPO=https://github.com/javierwilson/$APP
mkdir $DIR
find $DIR -name "*.pyc"|xargs rm
git clone $REPO $DIR
(cd $DIR; git pull)
cp matos_supervisor.ini /etc/supervisord.d/
cp matos_nginx.conf /etc/nginx/conf.d/
cp pg_hba.conf /var/lib/pgsql/
services_reload="nginx postgresql"
for i in $services_reload; do
systemctl reload $i
done
# deploy
virtualenv --system-site-packages $DIR/env
source $DIR/env/bin/activate
pip install -r $DIR/requirements/production.txt
chown -R $USER:$USER $DIR
$DIR/manage.py migrate
$DIR/manage.py collectstatic --no-input
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '[email protected]', 'secret')" | $DIR/manage.py shell
supervisor_jobs="matos"
supervisorctl reread
supervisorctl update
supervisorctl restart $supervisor_jobs
#!/bin/bash
cat matos_rpm_requirements.txt |grep -v "#"|xargs dnf -y install
services="nginx postgresql supervisord"
postgresql-setup initdb
for i in $services; do
systemctl start $i
done
users="matos"
for i in $users; do
useradd -d /var/www/$i $i
chown -R $i:$i /var/www/$i
done
runuser postgres -c "createuser matos"
runuser postgres -c "createdb -O matos matos"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment