Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Commit

Permalink
build command now creates and places the scripts for deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsackett committed Jul 16, 2009
1 parent 1b49bf7 commit a9fef58
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 18 deletions.
2 changes: 1 addition & 1 deletion templates/scripts/setup_directories.sh.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

echo "creating necessary folders for deployment..."
for dir in {{ site_folders }}
for dir in /home/websites/lighttpd/{{PROJECT}}/ /home/websites/lighttpd/{{PROJECT}}/ /home/websites/lighttpd/{{PROJECT}}/cache /home/websites/{{PROJECT}}/ /home/websites/{{PROJECT}}/logs/ /home/websites/{{PROJECT}}/logs/apache/ /home/websites/lighttpd/{{PROJECT}}/logs/
do
if [[ -d $dir ]]; then
echo $dir "already exists."
Expand Down
23 changes: 11 additions & 12 deletions templates/scripts/setup_syslinks.sh.tmpl
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
#!/bin/bash
cd /home/websites/lighttpd/fab/site_media/
if [[ -d /home/websites/lighttpd/site_media/css ]]; then
cd /home/websites/lighttpd/{{PROJECT}}/
if [[ -d /home/websites/lighttpd/{{PROJECT}}]]/site_media/ ]]; then
echo "Media links exist."
else
ln -s /home/websites/fab/fabsite/site_media/* .
ln -s /usr/lib/python2.5/site-packages/django/contrib/admin/media ./admin_media
ln -s /home/websites/{{PROJECT}}/{{CODE}}/site_media .
fi

cd /home/websites/fab
if [[ -d /home/websites/fab/cache ]]; then
cd /home/websites/{{PROJECT}}
if [[ -d /home/websites/{{PROJECT}}/cache ]]; then
echo "Cache link exists."
else
ln -s /home/websites/lighttpd/fab/lighttpdcache ./cache
ln -s /home/websites/lighttpd/{{PROJECT}}/cache ./cache
fi

if [[ -d /home/websites/fab/media ]]; then
if [[ -d /home/websites/{{PROJECT}}/media ]]; then
echo "Second media link exists."
else
ln -s /home/websites/lighttpd/fab/site_media ./media
ln -s /home/websites/lighttpd/{{PROJECT}}/site_media ./media
fi

cd /home/websites/fab/logs
if [[ -d /home/websites/fab/logs/lighttpd ]]; then
cd /home/websites/{{PROJECT}}/logs
if [[ -d /home/websites/{{PROJECT}}/logs/lighttpd ]]; then
echo "Log links exist."
else
ln -s /var/log/lighttpd/fab ./lighttpd
ln -s /home/websites/lighttpd/{{PROJECT}}/logs ./lighttpd
fi
5 changes: 2 additions & 3 deletions templates/settings.py.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PROJECT_NAME = ''
PROJECT_HOME = ''
CODE_HOME = ''
PROJECT_HOME = '' #the name of the directory the project will be hosted under
CODE_HOME = '' #the name of the directory the code will be hosted in

REPO_TYPE = '' #one of git, hg, or svn
REPO = ''
Expand Down
32 changes: 30 additions & 2 deletions weaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
import sys
import os
import shutil
from jinja2 import Environment, FileSystemLoader

WEAVER_DIR = os.path.dirname(os.path.abspath(__file__))
env = Environment(loader=FileSystemLoader(os.path.join(WEAVER_DIR, 'templates')))

class WeaverConfig(object):
'''This is just a container class to hold procesing data'''
pass

config = WeaverConfig()

def init(args):
target_dir = args[0]
Expand All @@ -14,13 +22,33 @@ def init(args):
sys.exit(1)
else:
shutil.copy(
os.path.join(WEAVER_DIR, 'settings.py.tmpl'),
os.path.join(WEAVER_DIR, 'templates', 'settings.py.tmpl'),
os.path.join(target_dir, 'settings.py')
)

def build(args):
pass
scripts(working_dir)
conf(working_dir)

def load_settings(working_dir):
working_dir = os.getcwd()
sys.path += [working_dir]
import settings

config.project = getattr(settings, 'PROJECT_HOME')
config.code = getattr(settings, 'CODE_HOME')

def scripts(working_dir):
os.mkdir('scripts')

template = env.get_template('scripts/setup_directories.sh.tmpl')
content = template.render(PROJECT=config.project)
file(os.path.join(working_dir, 'scripts', 'setup_directories.sh'), 'w').write(content)

template = env.get_template('scripts/setup_syslinks.sh.tmpl')
content = template.render(PROJECT=config.project, CODE=config.code)
file(os.path.join(working_dir, 'scripts', 'setup_syslinks.sh'), 'w').write(content)

commands = {
'init':init,
'build':build
Expand Down

0 comments on commit a9fef58

Please sign in to comment.