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