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