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