oops, wrong logo
[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
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" -a ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
125         [ "${TEMPLATE}" = "mason" ] && chown -R freeside ${MASONDATA} || true
126
127 perl-modules:
128         cd FS; \
129         [ -e Makefile ] || perl Makefile.PL; \
130         make
131
132 install-perl-modules: perl-modules
133         cd FS; \
134         make install UNINST=1
135
136 install-init:
137         #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
138         install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
139         perl -p -i -e "\
140           s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
141           s'%%%FREESIDE_PATH%%%'${FREESIDE_PATH}'g;\
142           s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
143           s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
144         " ${INIT_FILE}
145
146 install: install-perl-modules install-docs install-init
147
148 deploy: install
149         ${HTTPD_RESTART}
150         ${FREESIDE_RESTART}
151
152 create-database:
153         perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
154
155 create-config: install-perl-modules
156         [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
157         install -d -o freeside ${FREESIDE_CONF}
158
159         touch ${FREESIDE_CONF}/secrets
160         chown freeside ${FREESIDE_CONF}/secrets
161         chmod 600 ${FREESIDE_CONF}/secrets
162
163         echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
164         chmod 600 ${FREESIDE_CONF}/secrets
165         chown freeside ${FREESIDE_CONF}/secrets
166
167         mkdir "${FREESIDE_CONF}/conf.${DATASOURCE}"
168         rm -rf conf/registries #old dirs just won't go away
169         #cp conf/[a-z]* "${FREESIDE_CONF}/conf.${DATASOURCE}"
170         cp `ls -d conf/[a-z]* | grep -v CVS` "${FREESIDE_CONF}/conf.${DATASOURCE}"
171         chown -R freeside "${FREESIDE_CONF}/conf.${DATASOURCE}"
172
173         mkdir "${FREESIDE_CONF}/counters.${DATASOURCE}"
174         chown freeside "${FREESIDE_CONF}/counters.${DATASOURCE}"
175
176         mkdir "${FREESIDE_CONF}/cache.${DATASOURCE}"
177         chown freeside "${FREESIDE_CONF}/cache.${DATASOURCE}"
178
179         mkdir "${FREESIDE_CONF}/export.${DATASOURCE}"
180         chown freeside "${FREESIDE_CONF}/export.${DATASOURCE}"
181
182 clean:
183         rm -rf aspdocs masondocs
184         cd FS; \
185         make clean
186
187 #these are probably only useful if you're me...
188
189 upload-docs: forcehtmlman
190         ssh pouncequick.420.am rm -rf /var/www/www.sisd.com/freeside/devdocs
191         scp -pr httemplate/docs pouncequick.420.am:/var/www/www.sisd.com/freeside/devdocs
192
193 release: upload-docs
194         cd /home/ivan/freeside
195         #cvs tag ${TAG}
196         cvs tag -F ${TAG}
197
198         #cd /home/ivan
199         cvs export -r ${TAG} -d freeside-${VERSION} freeside
200         tar czvf freeside-${VERSION}.tar.gz freeside-${VERSION}
201
202         scp freeside-${VERSION}.tar.gz ivan@pouncequick.420.am:/var/www/sisd.420.am/freeside/
203         mv freeside-${VERSION} freeside-${VERSION}.tar.gz ..
204
205 update-webdemo:
206         ssh ivan@pouncequick.420.am '( cd freeside; cvs update -d -P )'
207         #ssh root@pouncequick.420.am '( cd /home/ivan/freeside; make clean; make deploy )'
208         ssh root@pouncequick.420.am '( cd /home/ivan/freeside; make deploy )'
209