More Vagrant stuff.
parent
27b08c76b8
commit
b09c753b9d
87
Makefile
87
Makefile
|
@ -1,3 +1,8 @@
|
|||
pm = /var/www/.virtualenvs/snipt/bin/python /var/www/snipt/manage.py
|
||||
ssh-server-deploy = ssh deploy@snipt.net
|
||||
ssh-server-root = ssh root@snipt.net
|
||||
ssh-vagrant = ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key
|
||||
|
||||
assets:
|
||||
@cat media/css/bootstrap.min.css \
|
||||
media/css/blog-themes/pro-adams/style.css \
|
||||
|
@ -63,14 +68,14 @@ assets:
|
|||
|
||||
db:
|
||||
@echo Creating database user snipt:
|
||||
@sudo -H -u postgres bash -c 'createuser snipt -P'
|
||||
@sudo -H -u postgres bash -c 'createdb snipt -O snipt'
|
||||
@sudo -u postgres bash -c 'createuser snipt -P'
|
||||
@sudo -u postgres bash -c 'createdb snipt -O snipt'
|
||||
|
||||
deploy:
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; git pull;'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; make assets;'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; /var/www/.virtualenvs/snipt/bin/python manage.py migrate'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo supervisorctl restart snipt'
|
||||
@$(ssh-server) 'cd /var/www/snipt; git pull;'
|
||||
@$(ssh-server) 'cd /var/www/snipt; make assets;'
|
||||
@$(ssh-server) '$(pm) migrate'
|
||||
@$(ssh-server) 'sudo supervisorctl restart snipt'
|
||||
|
||||
deploy-heroku:
|
||||
@git push heroku
|
||||
|
@ -78,67 +83,41 @@ deploy-heroku:
|
|||
server-settings:
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r settings_local_server.py vagrant@localhost:settings_local.py
|
||||
|
||||
salt-server:
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./salt/ vagrant@localhost:salt
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./pillar/ vagrant@localhost:pillar
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r settings_local_server.py vagrant@localhost:settings_local.py
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo rm -rf /srv'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mkdir /srv'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/salt /srv/salt'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/pillar /srv/pillar'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo salt-call --local state.highstate'
|
||||
|
||||
salt-vagrant:
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./salt/ vagrant@localhost:salt
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./pillar/ vagrant@localhost:pillar
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo rm -rf /srv'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mkdir /srv'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/salt /srv/salt'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/pillar /srv/pillar'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo salt-call --local state.highstate'
|
||||
|
||||
server:
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get update'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get install -y software-properties-common python-software-properties'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo add-apt-repository -y ppa:saltstack/salt'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get update'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get install -y salt-minion'
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./salt/ vagrant@localhost:salt
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./pillar/ vagrant@localhost:pillar
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo rm -rf /srv'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mkdir /srv'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/salt /srv/salt'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/pillar /srv/pillar'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo salt-call --local state.highstate'
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r settings_local_server.py vagrant@localhost:/var/www/snipt/settings_local.py
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; make db'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; /var/www/.virtualenvs/snipt/bin/python manage.py syncdb'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; /var/www/.virtualenvs/snipt/bin/python manage.py migrate'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; /var/www/.virtualenvs/snipt/bin/python manage.py backfill_api_keys'
|
||||
@$(ssh-vagrant) 'sudo rm -rf /srv'
|
||||
@$(ssh-vagrant) 'sudo mkdir /srv'
|
||||
@$(ssh-vagrant) 'sudo mv ~/salt /srv/salt'
|
||||
@$(ssh-vagrant) 'sudo mv ~/pillar /srv/pillar'
|
||||
@$(ssh-vagrant) 'sudo salt-call --local state.highstate'
|
||||
|
||||
vagrant:
|
||||
@vagrant up --provider=vmware_fusion
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get update'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get install -y software-properties-common python-software-properties'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo add-apt-repository -y ppa:saltstack/salt'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get update'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo apt-get install -y salt-minion'
|
||||
@$(ssh-vagrant) 'sudo apt-get update'
|
||||
@$(ssh-vagrant) 'sudo apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade'
|
||||
@$(ssh-vagrant) 'sudo apt-get install -y software-properties-common python-software-properties'
|
||||
@$(ssh-vagrant) 'sudo add-apt-repository -y ppa:saltstack/salt'
|
||||
@$(ssh-vagrant) 'sudo apt-get update'
|
||||
@$(ssh-vagrant) 'sudo apt-get install -y salt-minion'
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./salt/ vagrant@localhost:salt
|
||||
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./pillar/ vagrant@localhost:pillar
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo rm -rf /srv'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mkdir /srv'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/salt /srv/salt'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo mv ~/pillar /srv/pillar'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'sudo salt-call --local state.highstate'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; make db'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; /var/www/.virtualenvs/snipt/bin/python manage.py syncdb'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; /var/www/.virtualenvs/snipt/bin/python manage.py migrate'
|
||||
@ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key 'cd /var/www/snipt; /var/www/.virtualenvs/snipt/bin/python manage.py backfill_api_keys'
|
||||
@$(ssh-vagrant) 'sudo rm -rf /srv'
|
||||
@$(ssh-vagrant) 'sudo mkdir /srv'
|
||||
@$(ssh-vagrant) 'sudo mv ~/salt /srv/salt'
|
||||
@$(ssh-vagrant) 'sudo mv ~/pillar /srv/pillar'
|
||||
@$(ssh-vagrant) 'sudo salt-call --local state.highstate'
|
||||
@$(ssh-vagrant) 'cd /var/www/snipt; make db;'
|
||||
@vagrant ssh -c '$(pm) syncdb;'
|
||||
@$(ssh-vagrant) '$(pm) migrate;'
|
||||
@$(ssh-vagrant) '$(pm) backfill_api_keys'
|
||||
|
||||
.PHONY: assets, \
|
||||
db, \
|
||||
deploy, \
|
||||
deploy-heroku, \
|
||||
provision-server, \
|
||||
provision-vagrant, \
|
||||
salt-server, \
|
||||
salt-vagrant, \
|
||||
server-settings, \
|
||||
|
|
|
@ -2,5 +2,5 @@ Vagrant.configure("2") do |config|
|
|||
config.vm.box = "puphpet/ubuntu1404-x64"
|
||||
config.vm.hostname = "local.snipt.net"
|
||||
config.vm.synced_folder ".", "/var/www/snipt/"
|
||||
config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
config.vm.network "forwarded_port", guest: 80, host: 80
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[program:snipt]
|
||||
directory=/var/www/snipt
|
||||
user={{ pillar.deploy_user }}
|
||||
command=/var/www/.virtualenvs/snipt/bin/python manage.py run_gunicorn -c /var/www/snipt/gunicorn.conf.py
|
||||
command={% if pillar.env_name != 'vagrant' %}/var/www/.virtualenvs/snipt/bin/python manage.py run_gunicorn -c /var/www/snipt/gunicorn.conf.py{% else %}/var/www/.virtualenvs/snipt/bin/python manage.py runserver{% endif %}
|
||||
autostart=true
|
||||
autorestart=true
|
||||
environment=NODE_ENV=production
|
||||
|
|
|
@ -22,5 +22,3 @@ system:
|
|||
- mercurial
|
||||
- python-dev
|
||||
- tree
|
||||
cmd.run:
|
||||
- name: apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
|
||||
|
|
|
@ -15,7 +15,7 @@ from pygments.formatters import HtmlFormatter
|
|||
|
||||
from snipts.utils import slugify_uniquely
|
||||
|
||||
import datetime, md5, random, re
|
||||
import datetime, hashlib, random, re
|
||||
|
||||
|
||||
class Snipt(models.Model):
|
||||
|
@ -52,7 +52,7 @@ class Snipt(models.Model):
|
|||
self.slug = slugify_uniquely(self.title, Snipt)
|
||||
|
||||
if not self.key:
|
||||
self.key = md5.new(self.slug + str(datetime.datetime.now()) + str(random.random())).hexdigest()
|
||||
self.key = hashlib.md5(self.slug + str(datetime.datetime.now()) + str(random.random())).hexdigest()
|
||||
|
||||
if self.lexer == 'markdown':
|
||||
self.stylized = markdown(self.code, 'default')
|
||||
|
|
Loading…
Reference in New Issue