forked from nbproject/nbproject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
178 lines (144 loc) · 7.25 KB
/
Makefile
File metadata and controls
178 lines (144 loc) · 7.25 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
#use the following to configure the 'nb3' server:
SRCDIR = apps
PREREQS = postgresql imagemagick
PWD = $(shell pwd)
PREFIXDIR = $(PWD)
WSGIDIR = $(SRCDIR)/apache
WSGIFILE = $(WSGIDIR)/django.wsgi
WSGISKEL = $(WSGIFILE).skel
APACHEFILE = conf/nb_apache
APACHESKEL = $(APACHEFILE).skel
CRONFILE = conf/nb_crontab
CRONSKEL = conf/crontab.skel
MIGRATEDBFILE = conf/migratedb.sh
MIGRATEDBSKEL = conf/migratedb.sh.skel
OLD_DB = notabene
NEW_DB = nb3
SETTINGSFILE = $(SRCDIR)/settings.py
DBNAME = $(shell python -c 'from $(SRCDIR).settings import DATABASES;print DATABASES["default"]["NAME"]')
DBUSER = $(shell python -c 'from $(SRCDIR).settings import DATABASES;print DATABASES["default"]["USER"]')
DBPASS = $(shell python -c 'from $(SRCDIR).settings import DATABASES;print DATABASES["default"]["PASSWORD"]')
DBHOST = $(shell python -c 'from $(SRCDIR).settings import DATABASES;a=DATABASES["default"]["HOST"];a="localhost" if a=="" else a;print a')
CRON_EMAIL = $(shell python -c 'from $(SRCDIR).settings import CRON_EMAIL;print CRON_EMAIL')
CONTENTDIR = $(PWD)/content
HTTPD_MEDIA_DIR = $(shell python -c 'from $(SRCDIR).settings import HTTPD_MEDIA;print HTTPD_MEDIA')
HTTPD_PDF_DIR = $(HTTPD_MEDIA_DIR)/pdf
HTTPD_REP_DIR = $(HTTPD_PDF_DIR)/repository
HTTPD_ANNOTATED_DIR = $(HTTPD_PDF_DIR)/annotated
HTTPD_RESTRICTED_REP_DIR = $(HTTPD_PDF_DIR)/restricted_repository
HTTPD_CACHE_DIR = $(HTTPD_PDF_DIR)/cache2
SERVER_USERNAME = $(shell python -c 'from $(SRCDIR).settings import SERVER_USERNAME;print SERVER_USERNAME')
NB_SERVERNAME = $(shell python -c 'from $(SRCDIR).settings import NB_SERVERNAME;print NB_SERVERNAME')
NB_HTTP_PORT = $(shell python -c 'from $(SRCDIR).settings import NB_HTTP_PORT;print NB_HTTP_PORT')
HOST_PROD = sacha.csail.mit.edu
ROOT_PROD = /sachacsail
NB = nb
NB_ARCHIVE = nb.tgz
NB_ARCHIVE = nb_stats_`date`_.tgz
HOME_PROD = $(ROOT_PROD)/var/local/home/sacha
CONFDIR_PROD = $(HOME_PROD)/$(NB)/conf
DEFAULT_FILE = defaults.json
DEFAULT_PROD = defaults.json.prod
COMPILED_DIR = content/compiled
API_ROOT = content/modules
API_DEST = $(COMPILED_DIR)/api.js
#API_FILES = Module.js NB.js auth.js dom.js rpc.js observer.js mvc.js dev/models.js
API_FILES = Module.js NB.js auth.js dom.js mvc.js dev/models.js
APIDEV_ROOT = content/modules
APIDEV_DEST = $(COMPILED_DIR)/apidev.js
APIDEV_FILES = Module.js NB.js auth.js dom.js mvc.js dev/models2.js
compat: api
(rm content/compat/*; cd src; python compat.py dir ../ ../templates/web ../content/compat/)
check_settings:
echo ''
echo '********************************************************************************************'
echo '* Please edit your DB connections parameters in $(SRCDIR)/settings_credentials.py, if needed *'
echo '********************************************************************************************'
echo ''
$(shell python -c 'import $(SRCDIR).settings')
.SILENT:
create_dirs:
echo 'attempting to create Media dir: ' $(HTTPD_MEDIA_DIR)
# if test -d $(HTTPD_MEDIA_DIR) ; then echo 'HTTP DIR OK'; else mkdir -p $(HTTPD_MEDIA_DIR); fi
echo 'attempting to create Repository dir: ' $(HTTPD_REP_DIR)
- mkdir -p $(HTTPD_REP_DIR)
echo 'attempting to create Annotated dir: ' $(HTTPD_ANNOTATED_DIR)
- mkdir -p $(HTTPD_ANNOTATED_DIR)
echo 'attempting to create Restricted Repository dir: ' $(HTTPD_RESTRICTED_REP_DIR)
- mkdir -p $(HTTPD_RESTRICTED_REP_DIR)
echo 'attempting to create Cache dir: ' $(HTTPD_CACHE_DIR)
- mkdir -p $(HTTPD_CACHE_DIR)
echo 'attempting to chown Media dir: ' $(HTTPD_MEDIA_DIR)
- chown -R $(SERVER_USERNAME):$(SERVER_USERNAME) $(HTTPD_MEDIA_DIR)
create_db:
if psql -h $(DBHOST) -U $(DBUSER) -d $(DBNAME) -c 'select 0;' > /dev/null ; then echo 'DB OK ! '; else echo 'DB TEST CONNECTION FAILED using parameters: user=$(DBUSER) host=$(DBHOST) database=$(DBNAME)\nMake sure you have created a database compatible with the params defined in $(SETTINGSFILE)\nFor more info, read the INSTALL file '; fi
all:
echo $(DBNAME)
django: check_settings
sed 's|@@SRC_DIR@@|$(PREFIXDIR)/$(SRCDIR)|g' $(WSGISKEL) > $(WSGIFILE)
sed -e 's|@@NB_DIR@@|$(PWD)|g' -e 's|@@SRCDIR@@|$(SRCDIR)|g' -e 's|@@NB_CRON_EMAIL@@|$(CRON_EMAIL)|g' $(CRONSKEL) > $(CRONFILE)
sed -e 's|NB_CONTENTDIR|$(CONTENTDIR)|g' -e 's|NB_WSGIDIR|$(PWD)/$(WSGIDIR)|g' -e 's|NB_SERVERNAME|$(NB_SERVERNAME)|g' -e 's|NB_HTTP_PORT|$(NB_HTTP_PORT)|g' $(APACHESKEL) > $(APACHEFILE)
echo ''
echo '--------- Apache configuration file ------------'
echo 'Copy the file $(APACHEFILE) into your apache configuration. Typically this can be done with the following sequence:'
echo 'sudo cp conf/nb_apache /etc/apache2/sites-available/'
echo 'cd /etc/apache2/sites-enabled'
echo 'sudo ln -s ../sites-available/nb_apache .'
echo ''
echo '--------- Crontab file -------------------------'
echo 'If you have not done it already, please update your crontab file with the contents of:'
echo '$(CRONFILE)'
echo ''
echo '--------- End of make messages -----------------'
echo ''
migratedb:
sed -e 's|@@OLD_DB@@|$(OLD_DB)|g' -e 's|@@NEW_DB@@|$(NEW_DB)|g' $(MIGRATEDBSKEL) > $(MIGRATEDBFILE)
chmod u+x $(MIGRATEDBFILE)
newstats:
./stats nb2_notes
unison -batch -ui text nb_stats2
clean:
- find . -name '*~' | xargs rm
- find . -name '*.pyc' | xargs rm
tgz:
(cd ~ ; tar cz $(NB) > $(NB_ARCHIVE) )
prod: tgz
if test -e $(HOME_PROD); then (echo '$(HOME_PROD) mounted, continuing...') ;else (echo 'mounting $(ROOT_PROD)';sshfs $(HOST_PROD):/ $(ROOT_PROD)) fi
if test -e $(HOME_PROD); then (echo 'copying...';cp ~/$(NB_ARCHIVE) $(HOME_PROD);echo 'done !') ;else echo 'ERROR: $(HOME_PROD) not mounted'; fi
ssh $(HOST_PROD) 'tar zxf $(NB_ARCHIVE)'
echo "You can kill the current daemon and run a new one now: sudo nohup ./runserver "
api:
mkdir -p $(COMPILED_DIR)
echo '' > $(API_DEST)
for i in $(API_FILES); do cat $(API_ROOT)/$$i >> $(API_DEST) ; done
apidev:
mkdir -p $(COMPILED_DIR)
touch content/ui/admin/conf_local.js
echo '' > $(APIDEV_DEST)
for i in $(APIDEV_FILES); do cat $(APIDEV_ROOT)/$$i >> $(APIDEV_DEST) ; done
#for some reason, the following doesn't perform Ok when in makefile, but OK when executed from shell...
check_prereqs:
for l in $(PREREQS); do \
if [ $$l != `dpkg -l $$l | grep '^ii' | sed 's|^ii \(\S*\).*|\1|'` ] ; then echo "$$l seems to be missing"; exit 1; else echo "$$l OK..."; fi; \
done
prereqs_common:
apt-get install python postgresql imagemagick pdfedit postgresql-plpython-8.4 python-pypdf context
prereqs_django:
apt-get install apache2 python-psycopg2 libapache2-mod-wsgi
prereqs_twisted:
apt-get install python-twisted python-pygresql
startapp: #reminder for what links to create when creating a new django app
echo 'ln -s ../../src/annotations3.py annotations.py'
echo 'ln -s ../../src/utils_response.py .'
echo 'ln -s ../../src/utils_format.py .'
echo 'ln -s ../../src/constants.py .'
echo 'ln -s ../../src/utils_auth.py .'
echo 'ln -s ../../src/db_django.py db.py'
echo 'ln -s ../../src/registry.py .'
echo ''
echo ''
static2template: #reminder for how to change a static page into a template.
sed -i 's|href="../|href="/content/|' your_file
sed -i 's|src="../|src="/content/|' your_file
echo 'change manually other links to abolute links typicall pers???.css and pers???.js need to be replaced by /content/ui/classic/pers???...'
echo 'close script tags with a </script> instead of />'