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