3 #solaris and perhaps other very weirdass /bin/sh
12 DATASOURCE = DBI:${DB_TYPE}:dbname=freeside
14 #changable now (some things which should go to the others still go to CONF)
15 FREESIDE_CONF = /usr/local/etc/freeside
16 FREESIDE_LOG = /usr/local/etc/freeside
17 FREESIDE_LOCK = /usr/local/etc/freeside
18 FREESIDE_CACHE = /usr/local/etc/freeside
19 FREESIDE_EXPORT = /usr/local/etc/freeside
21 MASON_HANDLER = ${FREESIDE_CONF}/handler.pl
22 MASONDATA = ${FREESIDE_CACHE}/masondata
24 #where to put the default configuraiton used by freeside-setup to initialize
25 #a new database (not used after that). primarily of interest to distro
27 DIST_CONF = ${FREESIDE_CONF}/default_conf
30 FREESIDE_DOCUMENT_ROOT = /var/www/freeside
31 #redhat, fedora, mandrake
32 #FREESIDE_DOCUMENT_ROOT = /var/www/html/freeside
34 #FREESIDE_DOCUMENT_ROOT = /usr/local/www/data/freeside
36 #FREESIDE_DOCUMENT_ROOT = /var/www/htdocs/freeside
38 #FREESIDE_DOCUMENT_ROOT = /srv/www/htdocs/freeside
40 #FREESIDE_DOCUMENT_ROOT = /usr/local/apache/htdocs/freeside
42 #deb, redhat, fedora, mandrake, suse, others?
43 INIT_FILE = /etc/init.d/freeside
45 #INIT_FILE = /usr/local/etc/rc.d/011.freeside.sh
48 INIT_INSTALL = /bin/true
49 #INIT_INSTALL = PATH=$PATH:/sbin /usr/sbin/update-rc.d freeside defaults 23 01
51 #INIT_INSTALL = /sbin/chkconfig freeside on
52 #not necessary (freebsd)
53 #INIT_INSTALL = /usr/bin/true
56 #HTTPD_RESTART = /etc/init.d/apache restart
58 HTTPD_RESTART = /etc/init.d/apache2 restart
59 #redhat, fedora, mandrake
60 #HTTPD_RESTART = /etc/init.d/httpd restart
62 #HTTPD_RESTART = /usr/local/etc/rc.d/apache.sh stop || true; sleep 10; /usr/local/etc/rc.d/apache.sh start
64 #HTTPD_RESTART = kill -TERM `cat /var/www/logs/httpd.pid`; sleep 10; /usr/sbin/httpd -u -DSSL
66 #HTTPD_RESTART = /usr/local/apache/bin/apachectl stop; sleep 10; /usr/local/apache/bin/apachectl startssl
68 #(an include directory, not a file, "Include /etc/apache/conf.d" in httpd.conf)
70 APACHE_CONF = /etc/apache2/conf.d
72 FREESIDE_RESTART = ${INIT_FILE} restart
74 #deb, redhat, fedora, mandrake, suse, others?
79 #edit the stuff below to have the daemons start
83 SELFSERVICE_USER = fs_selfservice
84 #never run on the same machine in production!!!
85 SELFSERVICE_MACHINES =
86 # SELFSERVICE_MACHINES = www.example.com
87 # SELFSERVICE_MACHINES = web1.example.com web2.example.com
89 #user with sudo access on SELFSERVICE_MACHINES for automated self-service
91 SELFSERVICE_INSTALL_USER = ivan
92 SELFSERVICE_INSTALL_USERADD = /usr/sbin/useradd
93 #SELFSERVICE_INSTALL_USERADD = "/usr/sbin/pw useradd"
97 RT_DOMAIN = example.com
98 RT_TIMEZONE = US/Pacific
99 #RT_TIMEZONE = US/Eastern
100 FREESIDE_URL = "http://localhost/freeside/"
102 #for now, same db as specified in DATASOURCE... eventually, otherwise?
103 RT_DB_DATABASE = freeside
107 # for cvs-upgrade-deploy target, the username who checked out the CVS copy.
110 # for auto-version updates, so we can "make release" more things automatically
111 RPM_SPECFILE = rpm/freeside.spec
118 #only used for dev kludge now, not a big deal
119 FREESIDE_PATH = `pwd`
120 PERL_INC_DEV_KLUDGE = /usr/local/share/perl/5.10.1/
125 DEBVERSION = `echo ${VERSION} | perl -pe 's/(\d)([a-z])/\1~\2/'`-1
127 TEXMFHOME := "\$$TEXMFHOME"
130 @echo "supported targets:"
131 @echo " create-database create-config"
132 @echo " install deploy"
133 @echo " cvs-upgrade-deploy"
134 @echo " configure-rt create-rt"
137 @echo " install-docs install-perl-modules"
138 @echo " install-init install-apache"
139 @echo " install-rt install-texmf"
140 @echo " install-selfservice update-selfservice"
142 @echo " dev dev-docs dev-perl-modules"
144 @echo " masondocs alldocs docs"
146 @echo " perl-modules"
148 #@echo " upload-docs release"
151 masondocs: httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/*
153 cp -pr httemplate masondocs
162 chmod a+rx ./bin/pod2x
165 install-docs: check-conflicts docs
166 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
167 cp -r masondocs ${FREESIDE_DOCUMENT_ROOT}
168 chown -R freeside:freeside ${FREESIDE_DOCUMENT_ROOT}
169 cp htetc/handler.pl ${MASON_HANDLER}
170 cp htetc/htpasswd.logout ${FREESIDE_CONF}
171 [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
172 chown -R freeside ${MASONDATA}
175 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
176 ln -s ${FREESIDE_PATH}/httemplate ${FREESIDE_DOCUMENT_ROOT}
177 cp htetc/handler.pl ${MASON_HANDLER}
179 s'###use Module::Refresh;###'use Module::Refresh;'; \
180 s'###Module::Refresh->refresh;###'Module::Refresh->refresh;'; \
181 " ${MASON_HANDLER} || true
185 [ -e Makefile ] || perl Makefile.PL; \
188 s/%%%VERSION%%%/${VERSION}/g;\
191 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
192 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
193 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
194 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
195 s'%%%RT_PATH%%%'${RT_PATH}'g; \
196 s'%%%MASONDATA%%%'${MASONDATA}'g;\
197 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
200 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
201 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
202 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
203 " blib/lib/FS/Cron/*.pm;\
205 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
206 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
207 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
208 " blib/lib/FS/part_export/*.pm;\
210 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
211 " blib/lib/FS/cust_main/*.pm blib/lib/FS/cust_pkg/*.pm;\
213 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
214 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
215 s|%%%FREESIDE_LOCK%%%|${FREESIDE_LOCK}|g;\
216 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
217 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
218 s|%%%DIST_CONF%%%|${DIST_CONF}|g;\
221 install-perl-modules: check-conflicts perl-modules install-rt-initialdata
222 [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
223 && rm ${PERL_INC_DEV_KLUDGE}/FS \
224 && mv ${PERL_INC_DEV_KLUDGE}/FS.old ${PERL_INC_DEV_KLUDGE}/FS \
227 make install UNINST=1
228 #install this for freeside-setup
229 install -d $(DIST_CONF)
230 #install conf/[a-z]* $(DEFAULT_CONF)
232 install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
234 dev-perl-modules: perl-modules
235 [ -d ${PERL_INC_DEV_KLUDGE}/FS -a ! -L ${PERL_INC_DEV_KLUDGE}/FS ] \
236 && mv ${PERL_INC_DEV_KLUDGE}/FS ${PERL_INC_DEV_KLUDGE}/FS.old \
239 rm -rf ${PERL_INC_DEV_KLUDGE}/FS
240 ln -sf ${FREESIDE_PATH}/FS/blib/lib/FS ${PERL_INC_DEV_KLUDGE}/FS
243 install -D -o freeside -m 444 etc/fslongtable.sty \
244 `kpsewhich -expand-var \\\$$TEXMFLOCAL`/tex/generic/fslongtable.sty
245 texhash `kpsewhich -expand-var \\\$$TEXMFLOCAL`
248 #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
249 install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
251 s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
252 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
253 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
258 [ -e ${APACHE_CONF}/freeside-base.conf ] && rm ${APACHE_CONF}/freeside-base.conf || true
259 [ -d ${APACHE_CONF} ] && \
260 ( install -o root -m 755 htetc/freeside-base2.conf ${APACHE_CONF} && \
261 ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \
262 ( [ ${TORRUS_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-torrus.conf ${APACHE_CONF} || true ) && \
264 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
265 s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g; \
266 s'%%%MASON_HANDLER%%%'${MASON_HANDLER}'g; \
267 " ${APACHE_CONF}/freeside-*.conf \
271 [ -e ~freeside ] || cp -pr /etc/skel ~freeside && chown -R freeside ~freeside
272 [ -e ~freeside/.ssh/id_dsa.pub ] || [ -e ~freeside/.ssh/id_rsa.pub ] || su - freeside -c 'ssh-keygen -t dsa'
273 for MACHINE in ${SELFSERVICE_MACHINES}; do \
274 scp -r fs_selfservice/FS-SelfService ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
275 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; perl Makefile.PL && make" ;\
276 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
277 scp ~freeside/.ssh/id_dsa.pub ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
278 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo ${SELFSERVICE_INSTALL_USERADD} freeside; sudo install -d -o freeside -m 600 ~freeside/.ssh/; sudo install -o freeside -m 600 ./id_dsa.pub ~freeside/.ssh/authorized_keys" ;\
279 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo install -o freeside -d /usr/local/freeside" ;\
283 for MACHINE in ${SELFSERVICE_MACHINES}; do \
284 RSYNC_RSH=ssh rsync -rlptz fs_selfservice/FS-SelfService/ ${SELFSERVICE_INSTALL_USER}@$$MACHINE:FS-SelfService ;\
285 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; make clean; perl Makefile.PL && make" ;\
286 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
290 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
291 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
292 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
294 install: install-perl-modules install-docs install-init install-apache install-rt install-torrus install-texmf install-chown
301 su ${CVS_USER} -c 'cvs update -d -P'
302 make install-perl-modules
303 su freeside -c "freeside-upgrade ${CVS_USER}" #not really the same user
306 dev: dev-perl-modules dev-docs
309 perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
311 create-config: install-perl-modules
312 [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
313 install -d -o freeside ${FREESIDE_CONF}
315 touch ${FREESIDE_CONF}/secrets
316 chown freeside ${FREESIDE_CONF}/secrets
317 chmod 600 ${FREESIDE_CONF}/secrets
319 /bin/echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
320 chmod 600 ${FREESIDE_CONF}/secrets
321 chown freeside ${FREESIDE_CONF}/secrets
323 mkdir "${FREESIDE_CACHE}/counters.${DATASOURCE}"
324 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
326 mkdir "${FREESIDE_CACHE}/cache.${DATASOURCE}"
327 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
329 mkdir "${FREESIDE_EXPORT}/export.${DATASOURCE}"
330 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
332 #install this for freeside-setup
333 install -d $(DIST_CONF)
334 #install conf/[a-z]* $(DEFAULT_CONF)
336 install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
341 cp config.layout.in config.layout; \
343 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
344 s'%%%MASONDATA%%%'${MASONDATA}'g;\
346 ./configure --enable-layout=Freeside\
347 --with-db-type=${DB_TYPE} \
348 --with-db-dba=${DB_USER} \
349 --with-db-database=${RT_DB_DATABASE} \
350 --with-db-rt-user=${DB_USER} \
351 --with-db-rt-pass=${DB_PASSWORD} \
352 --with-web-user=freeside \
353 --with-web-group=freeside \
354 --with-rt-group=freeside \
355 --with-web-handler=modperl2
357 create-rt: configure-rt
358 [ -d /opt ] || mkdir /opt #doh
359 [ -d /opt/rt3 ] || mkdir /opt/rt3 #
360 [ -d /opt/rt3/share ] || mkdir /opt/rt3/share #
362 rt/sbin/rt-setup-database --dba '${DB_USER}' \
363 --dba-password '${DB_PASSWORD}' \
366 rt/sbin/rt-setup-database --dba-password '${DB_PASSWORD}' \
368 && rt/sbin/rt-setup-database --dba-password '${DB_PASSWORD}' \
370 --datafile ${RT_PATH}/etc/initialdata \
373 install-rt: check-conflicts
374 if [ ${RT_ENABLED} -eq 1 ]; then ( cd rt; make install ); fi
375 if [ ${RT_ENABLED} -eq 1 ]; then perl -p -i -e "\
376 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
377 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
378 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
379 " ${RT_PATH}/etc/RT_SiteConfig.pm; fi
380 if [ ${RT_ENABLED} -eq 1 ]; then \
381 chown -R freeside:freeside ${RT_PATH}/etc; fi
383 install-rt-initialdata:
384 if [ ${RT_ENABLED} -eq 1 ] && [ -d ${RT_PATH} ]; then \
385 chown -R freeside:freeside ${RT_PATH}/etc; \
386 install -D -o freeside -g freeside -m 0440 rt/etc/initialdata \
387 ${RT_PATH}/etc/initialdata; fi
391 torrus_user=freeside var_user=freeside var_group=freeside ./configure
394 if [ ${TORRUS_ENABLED} -eq 1 ]; then ( cd torrus; \
398 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
399 " /usr/local/etc/torrus/conf/torrus-siteconfig.pl; \
405 rm -rf httemplate/docs/man
410 -cd fs_selfservice/FS-SelfService; \
414 ! grep -r --exclude='*config.log*' '--exclude=*config.status*' --exclude=gnupg_details_on_output_formats '--exclude=*mason_handler*' '^=======$$' .
416 #these are probably only useful if you're me...
418 #release: upload-docs
421 # Update the changelog
423 cvs commit -m "Updated for ${VERSION}" ChangeLog
425 # Update the RPM specfile
426 cvs edit ${RPM_SPECFILE}
427 perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
428 perl -p -i -e "s/\d+[^\}]+/1/ if /%define\s+release\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
429 cvs commit -m "Updated for ${VERSION}" ${RPM_SPECFILE}
431 # Update the Debian changelog
432 cvs edit debian/changelog
433 dch -v ${DEBVERSION} -p "New upstream release"
434 cvs commit -m "Updated for ${VERSION}" debian/changelog
436 # Make sure other people's changes are pulled in!
437 cvs update -d -P || true #it exits 1...
444 cvs export -r ${TAG} -d freeside-${VERSION} freeside
445 tar czvf freeside-${VERSION}.tar.gz freeside-${VERSION}
447 scp freeside-${VERSION}.tar.gz ivan@420.am:/var/www/www.sisd.com/freeside/
448 mv freeside-${VERSION} freeside-${VERSION}.tar.gz ..
450 #these things failing should not make release target fail, so: "|| true"
452 #kick off vmware update
453 #./BUILD_VMWARE_APPLIANCE ${$TAG} || true
455 #kick off deb package update
457 #kick off rpm package update too?
461 #update web demo self-service?