re-email invoice, closes: bug#526 and have print and email invoice links redirect...
[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_MACHINES = localhost
55 # SELFSERVICE_MACHINES = web1.example.com web2.example.com
56
57 #---
58
59 #not changable yet
60 FREESIDE_CONF = /usr/local/etc/freeside
61
62 VERSION=1.5.0pre4
63 TAG=freeside_1_5_0pre4
64
65 help:
66         @echo "supported targets: aspdocs masondocs alldocs docs install-docs"
67         @echo "                   htmlman"
68         @echo "                   perl-modules install-perl-modules"
69         @echo "                   install deploy"
70         @echo "                   create-database"
71         @echo "                   clean"
72
73 aspdocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/*
74         rm -rf aspdocs
75         cp -pr httemplate aspdocs
76         perl -p -i -e "\
77           s/%%%VERSION%%%/${VERSION}/g;\
78         " aspdocs/index.html
79         touch aspdocs
80
81
82 masondocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/*
83         rm -rf masondocs
84         cp -pr httemplate masondocs
85         ( cd masondocs; \
86           ../bin/masonize; \
87         )
88         perl -p -i -e "\
89           s/%%%VERSION%%%/${VERSION}/g;\
90         " masondocs/index.html
91         touch masondocs
92
93 alldocs: aspdocs masondocs
94
95 docs:
96         make ${TEMPLATE}docs
97
98 htmlman:
99         [ -e ./httemplate/docs/man ] || mkdir httemplate/docs/man
100         [ -e ./httemplate/docs/man/bin ] || mkdir httemplate/docs/man/bin
101         [ -e ./httemplate/docs/man/FS ] || mkdir httemplate/docs/man/FS
102         [ -e ./httemplate/docs/man/FS/UI ] || mkdir httemplate/docs/man/FS/UI
103         [ -e ./httemplate/docs/man/FS/part_export ] || mkdir httemplate/docs/man/FS/part_export
104         chmod a+rx bin/pod2x
105         [ -e DONT_REBUILD_DOCS ] || bin/pod2x
106
107 forcehtmlman:
108         [ -e ./httemplate/docs/man ] || mkdir httemplate/docs/man
109         [ -e ./httemplate/docs/man/bin ] || mkdir httemplate/docs/man/bin
110         [ -e ./httemplate/docs/man/FS ] || mkdir httemplate/docs/man/FS
111         [ -e ./httemplate/docs/man/FS/UI ] || mkdir httemplate/docs/man/FS/UI
112         [ -e ./httemplate/docs/man/FS/part_export ] || mkdir httemplate/docs/man/FS/part_export
113         bin/pod2x
114
115 install-docs: docs
116         [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
117         cp -r ${TEMPLATE}docs ${FREESIDE_DOCUMENT_ROOT}
118         [ "${TEMPLATE}" = "asp" -a ! -e ${ASP_GLOBAL} ] && mkdir ${ASP_GLOBAL} || true
119         [ "${TEMPLATE}" = "asp" ] && chown -R freeside ${ASP_GLOBAL} || true
120         [ "${TEMPLATE}" = "asp" ] && cp htetc/global.asa ${ASP_GLOBAL} || true
121         [ "${TEMPLATE}" = "mason" ] && cp htetc/handler.pl ${MASON_HANDLER} || true
122         [ "${TEMPLATE}" = "mason" -a ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
123         [ "${TEMPLATE}" = "mason" ] && chown -R freeside ${MASONDATA} || true
124
125 perl-modules:
126         cd FS; \
127         [ -e Makefile ] || perl Makefile.PL; \
128         make
129
130 install-perl-modules: perl-modules
131         cd FS; \
132         make install UNINST=1
133
134 install-init:
135         #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
136         install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
137         perl -p -i -e "\
138           s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
139           s'%%%FREESIDE_PATH%%%'${FREESIDE_PATH}'g;\
140           s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
141           s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
142         " ${INIT_FILE}
143
144 install: install-perl-modules install-docs install-init
145
146 deploy: install
147         ${HTTPD_RESTART}
148         ${FREESIDE_RESTART}
149
150 create-database:
151         perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
152
153 create-config: install-perl-modules
154         [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
155         install -d -o 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         cp `ls -d conf/[a-z]* | grep -v CVS` "${FREESIDE_CONF}/conf.${DATASOURCE}"
169         chown -R freeside "${FREESIDE_CONF}/conf.${DATASOURCE}"
170
171         mkdir "${FREESIDE_CONF}/counters.${DATASOURCE}"
172         chown freeside "${FREESIDE_CONF}/counters.${DATASOURCE}"
173
174         mkdir "${FREESIDE_CONF}/cache.${DATASOURCE}"
175         chown freeside "${FREESIDE_CONF}/cache.${DATASOURCE}"
176
177         mkdir "${FREESIDE_CONF}/export.${DATASOURCE}"
178         chown freeside "${FREESIDE_CONF}/export.${DATASOURCE}"
179
180 clean:
181         rm -rf aspdocs masondocs
182         cd FS; \
183         make clean
184
185 #these are probably only useful if you're me...
186
187 upload-docs: forcehtmlman
188         ssh cleanwhisker.420.am rm -rf /var/www/www.sisd.com/freeside/devdocs
189         scp -pr httemplate/docs cleanwhisker.420.am:/var/www/www.sisd.com/freeside/devdocs
190
191 release: upload-docs
192         cd /home/ivan/freeside
193         #cvs tag ${TAG}
194         cvs tag -F ${TAG}
195
196         #cd /home/ivan
197         cvs export -r ${TAG} -d freeside-${VERSION} freeside
198         tar czvf freeside-${VERSION}.tar.gz freeside-${VERSION}
199
200         scp freeside-${VERSION}.tar.gz ivan@cleanwhisker.420.am:/var/www/sisd.420.am/freeside/
201         mv freeside-${VERSION} freeside-${VERSION}.tar.gz ..
202
203 update-webdemo:
204         ssh ivan@pouncequick.420.am '( cd freeside; cvs update -d -P )'
205         #ssh root@pouncequick.420.am '( cd /home/ivan/freeside; make clean; make deploy )'
206         ssh root@pouncequick.420.am '( cd /home/ivan/freeside; make deploy )'
207