ba1f5cd1725852a89e610a1fcc399f275f61a890
[freeside.git] / Makefile
1 #!/usr/bin/make
2
3 DATASOURCE = DBI:Pg:dbname=freeside
4 #DATASOURCE=DBI:mysql:freeside
5
6 DB_USER = freeside
7 DB_PASSWORD=
8
9 #TEMPLATE = asp
10 TEMPLATE = mason
11
12 ASP_GLOBAL = /usr/local/etc/freeside/asp-global
13 MASON_HANDLER = /usr/local/etc/freeside/handler.pl
14 MASONDATA = /usr/local/etc/freeside/masondata
15
16 #deb
17 FREESIDE_DOCUMENT_ROOT = /var/www/freeside
18 #redhat, mandrake
19 #FREESIDE_DOCUMENT_ROOT = /var/www/html/freeside
20 #freebsd
21 #FREESIDE_DOCUMENT_ROOT = /usr/local/www/data/freeside
22 #openbsd
23 #FREESIDE_DOCUMENT_ROOT = /var/www/htdocs/freeside
24 #suse
25 #FREESIDE_DOCUMENT_ROOT = /srv/www/htdocs/freeside
26
27 #deb, redhat, mandrake, suse, others?
28 INIT_FILE = /etc/init.d/freeside
29 #freebsd
30 #INIT_FILE = /usr/local/etc/rc.d/011.freeside.sh
31
32 #deb, suse
33 HTTPD_RESTART = /etc/init.d/apache restart
34 #redhat, mandrake
35 #HTTPD_RESTART = /etc/init.d/httpd restart
36 #freebsd
37 #HTTPD_RESTART = /usr/local/etc/rc.d/apache.sh stop; sleep 1; /usr/local/etc/rc.d/apache.sh start
38 #openbsd
39 #HTTPD_RESTART = kill -TERM `cat /var/www/logs/httpd.pid`; sleep 1; /usr/sbin/httpd -u -DSSL
40
41 FREESIDE_RESTART = ${INIT_FILE} restart
42
43 #deb, redhat, mandrake, suse, others?
44 INSTALLGROUP = root
45 #freebsd, openbsd
46 #INSTALLGROUP = wheel
47
48 #edit the stuff below to have the daemons start
49
50 QUEUED_USER=fs_queue
51
52 #eventually this shouldn't be needed
53 FREESIDE_PATH = `pwd`
54
55 SELFSERVICE_USER = fs_selfservice
56 SELFSERVICE_MACHINES = localhost
57 # SELFSERVICE_MACHINES = web1.example.com web2.example.com
58
59 #---
60
61 #not changable yet
62 FREESIDE_CONF = /usr/local/etc/freeside
63
64 VERSION=1.5.0pre4
65 TAG=freeside_1_5_0pre4
66
67 help:
68         @echo "supported targets: aspdocs masondocs alldocs docs install-docs"
69         @echo "                   htmlman"
70         @echo "                   perl-modules install-perl-modules"
71         @echo "                   install deploy"
72         @echo "                   create-database"
73         @echo "                   clean"
74
75 aspdocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/*
76         rm -rf aspdocs
77         cp -pr httemplate aspdocs
78         perl -p -i -e "\
79           s/%%%VERSION%%%/${VERSION}/g;\
80         " aspdocs/index.html
81         touch aspdocs
82
83
84 masondocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/*
85         rm -rf masondocs
86         cp -pr httemplate masondocs
87         ( cd masondocs; \
88           ../bin/masonize; \
89         )
90         perl -p -i -e "\
91           s/%%%VERSION%%%/${VERSION}/g;\
92         " masondocs/index.html
93         touch masondocs
94
95 alldocs: aspdocs masondocs
96
97 docs:
98         make ${TEMPLATE}docs
99
100 htmlman:
101         [ -e ./httemplate/docs/man ] || mkdir httemplate/docs/man
102         [ -e ./httemplate/docs/man/bin ] || mkdir httemplate/docs/man/bin
103         [ -e ./httemplate/docs/man/FS ] || mkdir httemplate/docs/man/FS
104         [ -e ./httemplate/docs/man/FS/UI ] || mkdir httemplate/docs/man/FS/UI
105         [ -e ./httemplate/docs/man/FS/part_export ] || mkdir httemplate/docs/man/FS/part_export
106         chmod a+rx bin/pod2x
107         [ -e DONT_REBUILD_DOCS ] || bin/pod2x
108
109 forcehtmlman:
110         [ -e ./httemplate/docs/man ] || mkdir httemplate/docs/man
111         [ -e ./httemplate/docs/man/bin ] || mkdir httemplate/docs/man/bin
112         [ -e ./httemplate/docs/man/FS ] || mkdir httemplate/docs/man/FS
113         [ -e ./httemplate/docs/man/FS/UI ] || mkdir httemplate/docs/man/FS/UI
114         [ -e ./httemplate/docs/man/FS/part_export ] || mkdir httemplate/docs/man/FS/part_export
115         bin/pod2x
116
117 install-docs: docs
118         [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
119         cp -r ${TEMPLATE}docs ${FREESIDE_DOCUMENT_ROOT}
120         [ "${TEMPLATE}" = "asp" -a ! -e ${ASP_GLOBAL} ] && mkdir ${ASP_GLOBAL} || true
121         [ "${TEMPLATE}" = "asp" ] && chown -R freeside ${ASP_GLOBAL} || true
122         [ "${TEMPLATE}" = "asp" ] && cp htetc/global.asa ${ASP_GLOBAL} || true
123         [ "${TEMPLATE}" = "mason" ] && cp htetc/handler.pl ${MASON_HANDLER} || true
124         [ "${TEMPLATE}" = "mason" ] && \
125           perl -p -i -e "\
126             s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
127           " ${MASON_HANDLER} || true
128         [ "${TEMPLATE}" = "mason" -a ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
129         [ "${TEMPLATE}" = "mason" ] && chown -R freeside ${MASONDATA} || true
130
131 perl-modules:
132         cd FS; \
133         [ -e Makefile ] || perl Makefile.PL; \
134         make
135
136 install-perl-modules: perl-modules
137         cd FS; \
138         make install UNINST=1
139
140 install-init:
141         #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
142         install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
143         perl -p -i -e "\
144           s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
145           s'%%%FREESIDE_PATH%%%'${FREESIDE_PATH}'g;\
146           s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
147           s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
148         " ${INIT_FILE}
149
150 install: install-perl-modules install-docs install-init
151
152 deploy: install
153         ${HTTPD_RESTART}
154         ${FREESIDE_RESTART}
155
156 create-database:
157         perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
158
159 create-config: install-perl-modules
160         [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
161         install -d -o freeside ${FREESIDE_CONF}
162
163         touch ${FREESIDE_CONF}/secrets
164         chown freeside ${FREESIDE_CONF}/secrets
165         chmod 600 ${FREESIDE_CONF}/secrets
166
167         echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
168         chmod 600 ${FREESIDE_CONF}/secrets
169         chown freeside ${FREESIDE_CONF}/secrets
170
171         mkdir "${FREESIDE_CONF}/conf.${DATASOURCE}"
172         rm -rf conf/registries #old dirs just won't go away
173         #cp conf/[a-z]* "${FREESIDE_CONF}/conf.${DATASOURCE}"
174         cp `ls -d conf/[a-z]* | grep -v CVS` "${FREESIDE_CONF}/conf.${DATASOURCE}"
175         chown -R freeside "${FREESIDE_CONF}/conf.${DATASOURCE}"
176
177         mkdir "${FREESIDE_CONF}/counters.${DATASOURCE}"
178         chown freeside "${FREESIDE_CONF}/counters.${DATASOURCE}"
179
180         mkdir "${FREESIDE_CONF}/cache.${DATASOURCE}"
181         chown freeside "${FREESIDE_CONF}/cache.${DATASOURCE}"
182
183         mkdir "${FREESIDE_CONF}/export.${DATASOURCE}"
184         chown freeside "${FREESIDE_CONF}/export.${DATASOURCE}"
185
186 clean:
187         rm -rf aspdocs masondocs
188         cd FS; \
189         make clean
190
191 #these are probably only useful if you're me...
192
193 upload-docs: forcehtmlman
194         ssh pouncequick.420.am rm -rf /var/www/www.sisd.com/freeside/devdocs
195         scp -pr httemplate/docs pouncequick.420.am:/var/www/www.sisd.com/freeside/devdocs
196
197 release: upload-docs
198         cd /home/ivan/freeside
199         #cvs tag ${TAG}
200         cvs tag -F ${TAG}
201
202         #cd /home/ivan
203         cvs export -r ${TAG} -d freeside-${VERSION} freeside
204         tar czvf freeside-${VERSION}.tar.gz freeside-${VERSION}
205
206         scp freeside-${VERSION}.tar.gz ivan@pouncequick.420.am:/var/www/sisd.420.am/freeside/
207         mv freeside-${VERSION} freeside-${VERSION}.tar.gz ..
208
209 update-webdemo:
210         ssh ivan@pouncequick.420.am '( cd freeside; cvs update -d -P )'
211         #ssh root@pouncequick.420.am '( cd /home/ivan/freeside; make clean; make deploy )'
212         ssh root@pouncequick.420.am '( cd /home/ivan/freeside; make deploy )'
213