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 = PATH=$PATH:/sbin /usr/sbin/update-rc.d freeside defaults 23 01
50 #INIT_INSTALL = /sbin/chkconfig freeside on
51 #not necessary (freebsd)
52 #INIT_INSTALL = /usr/bin/true
55 #HTTPD_RESTART = /etc/init.d/apache restart
57 HTTPD_RESTART = /etc/init.d/apache2 restart
58 #redhat, fedora, mandrake
59 #HTTPD_RESTART = /etc/init.d/httpd restart
61 #HTTPD_RESTART = /usr/local/etc/rc.d/apache.sh stop || true; sleep 10; /usr/local/etc/rc.d/apache.sh start
63 #HTTPD_RESTART = kill -TERM `cat /var/www/logs/httpd.pid`; sleep 10; /usr/sbin/httpd -u -DSSL
65 #HTTPD_RESTART = /usr/local/apache/bin/apachectl stop; sleep 10; /usr/local/apache/bin/apachectl startssl
67 #(an include directory, not a file, "Include /etc/apache/conf.d" in httpd.conf)
69 APACHE_CONF = /etc/apache2/conf.d
71 FREESIDE_RESTART = ${INIT_FILE} restart
73 #deb, redhat, fedora, mandrake, suse, others?
78 #edit the stuff below to have the daemons start
82 SELFSERVICE_USER = fs_selfservice
83 #never run on the same machine in production!!!
84 SELFSERVICE_MACHINES =
85 # SELFSERVICE_MACHINES = www.example.com
86 # SELFSERVICE_MACHINES = web1.example.com web2.example.com
88 #user with sudo access on SELFSERVICE_MACHINES for automated self-service
90 SELFSERVICE_INSTALL_USER = ivan
91 SELFSERVICE_INSTALL_USERADD = /usr/sbin/useradd
92 #SELFSERVICE_INSTALL_USERADD = "/usr/sbin/pw useradd"
96 RT_DOMAIN = example.com
97 RT_TIMEZONE = US/Pacific
98 #RT_TIMEZONE = US/Eastern
99 FREESIDE_URL = "http://localhost/freeside/"
101 #for now, same db as specified in DATASOURCE... eventually, otherwise?
102 RT_DB_DATABASE = freeside
106 # for auto-version updates, so we can "make release" more things automatically
107 RPM_SPECFILE = rpm/freeside.spec
114 #only used for dev kludge now, not a big deal
115 FREESIDE_PATH = `pwd`
116 PERL_INC_DEV_KLUDGE = /usr/local/share/perl/5.14.2/
118 VERSION := `grep '^$$VERSION' FS/FS.pm | cut -d\' -f2`
119 TAG := "freeside_`echo ${VERSION} | perl -pe 's/\./_/g'`"
121 DEBVERSION := `echo ${VERSION} | perl -pe 's/(\d)([a-z])/\1~\2/'`-1
123 TEXMFHOME := "\$$TEXMFHOME"
126 @echo "supported targets:"
127 @echo " create-database create-config"
128 @echo " install deploy"
129 @echo " configure-rt create-rt"
132 @echo " install-docs install-perl-modules"
133 @echo " install-init install-apache"
134 @echo " install-rt install-texmf"
135 @echo " install-selfservice update-selfservice"
137 @echo " dev dev-docs dev-perl-modules"
139 @echo " masondocs alldocs docs"
141 @echo " perl-modules"
143 #@echo " upload-docs release"
146 masondocs: httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/*
148 cp -pr httemplate masondocs
157 chmod a+rx ./bin/pod2x
160 install-docs: check-conflicts docs
161 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
162 cp -r masondocs ${FREESIDE_DOCUMENT_ROOT}
163 chown -R freeside:freeside ${FREESIDE_DOCUMENT_ROOT}
164 cp htetc/handler.pl ${MASON_HANDLER}
165 cp htetc/htpasswd.logout ${FREESIDE_CONF}
166 [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
167 chown -R freeside ${MASONDATA}
170 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
171 ln -s ${FREESIDE_PATH}/httemplate ${FREESIDE_DOCUMENT_ROOT}
172 cp htetc/handler.pl ${MASON_HANDLER}
174 s'###use Module::Refresh;###'use Module::Refresh;'; \
175 s'###Module::Refresh->refresh;###'Module::Refresh->refresh;'; \
176 " ${MASON_HANDLER} || true
180 [ -e Makefile ] || perl Makefile.PL; \
183 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
184 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
185 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
186 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
187 s'%%%RT_PATH%%%'${RT_PATH}'g; \
188 s'%%%MASONDATA%%%'${MASONDATA}'g;\
189 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
192 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
193 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
194 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
195 " blib/lib/FS/Cron/*.pm;\
197 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
198 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
199 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
200 " blib/lib/FS/part_export/*.pm;\
202 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
203 " blib/lib/FS/cust_main/*.pm blib/lib/FS/cust_pkg/*.pm;\
205 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
206 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
207 s|%%%FREESIDE_LOCK%%%|${FREESIDE_LOCK}|g;\
208 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
209 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
210 s|%%%DIST_CONF%%%|${DIST_CONF}|g;\
213 install-perl-modules: check-conflicts perl-modules install-rt-initialdata
214 [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
215 && rm ${PERL_INC_DEV_KLUDGE}/FS \
216 && mv ${PERL_INC_DEV_KLUDGE}/FS.old ${PERL_INC_DEV_KLUDGE}/FS \
219 make install UNINST=1
220 #install this for freeside-setup
221 install -d $(DIST_CONF)
222 #install conf/[a-z]* $(DEFAULT_CONF)
224 install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
226 dev-perl-modules: perl-modules
227 [ -d ${PERL_INC_DEV_KLUDGE}/FS -a ! -L ${PERL_INC_DEV_KLUDGE}/FS ] \
228 && mv ${PERL_INC_DEV_KLUDGE}/FS ${PERL_INC_DEV_KLUDGE}/FS.old \
231 rm -rf ${PERL_INC_DEV_KLUDGE}/FS
232 ln -sf ${FREESIDE_PATH}/FS/blib/lib/FS ${PERL_INC_DEV_KLUDGE}/FS
235 install -D -o freeside -m 444 etc/fslongtable.sty \
236 `kpsewhich -expand-var \\\$$TEXMFLOCAL`/tex/generic/fslongtable.sty
237 texhash `kpsewhich -expand-var \\\$$TEXMFLOCAL`
240 #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
241 install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
243 s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
244 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
245 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
250 [ -e ${APACHE_CONF}/freeside-base.conf ] && rm ${APACHE_CONF}/freeside-base.conf || true
251 [ -d ${APACHE_CONF} ] && \
252 ( install -o root -m 755 htetc/freeside-base2.conf ${APACHE_CONF} && \
253 ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \
254 ( [ ${TORRUS_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-torrus.conf ${APACHE_CONF} || true ) && \
256 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
257 s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g; \
258 s'%%%MASON_HANDLER%%%'${MASON_HANDLER}'g; \
259 " ${APACHE_CONF}/freeside-*.conf \
263 [ -e ~freeside ] || cp -pr /etc/skel ~freeside && chown -R freeside ~freeside
264 [ -e ~freeside/.ssh/id_dsa.pub ] || [ -e ~freeside/.ssh/id_rsa.pub ] || su - freeside -c 'ssh-keygen -t dsa'
265 for MACHINE in ${SELFSERVICE_MACHINES}; do \
266 scp -r fs_selfservice/FS-SelfService ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
267 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; perl Makefile.PL && make" ;\
268 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
269 scp ~freeside/.ssh/id_dsa.pub ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
270 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" ;\
271 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo install -o freeside -d /usr/local/freeside" ;\
275 for MACHINE in ${SELFSERVICE_MACHINES}; do \
276 RSYNC_RSH=ssh rsync -rlptz fs_selfservice/FS-SelfService/ ${SELFSERVICE_INSTALL_USER}@$$MACHINE:FS-SelfService ;\
277 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; make clean; perl Makefile.PL && make" ;\
278 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
282 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
283 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
284 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
286 install: install-perl-modules install-docs install-init install-apache install-rt install-torrus install-texmf install-chown
292 dev: dev-perl-modules dev-docs
295 perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
297 create-config: install-perl-modules
298 [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
299 install -d -o freeside ${FREESIDE_CONF}
301 touch ${FREESIDE_CONF}/secrets
302 chown freeside ${FREESIDE_CONF}/secrets
303 chmod 600 ${FREESIDE_CONF}/secrets
305 /bin/echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
306 chmod 600 ${FREESIDE_CONF}/secrets
307 chown freeside ${FREESIDE_CONF}/secrets
309 mkdir "${FREESIDE_CACHE}/counters.${DATASOURCE}"
310 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
312 mkdir "${FREESIDE_CACHE}/cache.${DATASOURCE}"
313 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
315 mkdir "${FREESIDE_EXPORT}/export.${DATASOURCE}"
316 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
318 #install this for freeside-setup
319 install -d $(DIST_CONF)
320 #install conf/[a-z]* $(DEFAULT_CONF)
322 install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
327 cp config.layout.in config.layout; \
329 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
330 s'%%%MASONDATA%%%'${MASONDATA}'g;\
332 ./configure --enable-layout=Freeside\
333 --with-db-type=${DB_TYPE} \
334 --with-db-dba=${DB_USER} \
335 --with-db-database=${RT_DB_DATABASE} \
336 --with-db-rt-user=${DB_USER} \
337 --with-db-rt-pass=${DB_PASSWORD} \
338 --with-web-user=freeside \
339 --with-web-group=freeside \
340 --with-rt-group=freeside \
341 --with-web-handler=modperl2
343 create-rt: configure-rt
344 [ -d /opt ] || mkdir /opt #doh
345 [ -d /opt/rt3 ] || mkdir /opt/rt3 #
346 [ -d /opt/rt3/share ] || mkdir /opt/rt3/share #
348 rt/sbin/rt-setup-database --dba '${DB_USER}' \
349 --dba-password '${DB_PASSWORD}' \
352 rt/sbin/rt-setup-database --dba-password '${DB_PASSWORD}' \
354 && rt/sbin/rt-setup-database --dba-password '${DB_PASSWORD}' \
356 --datafile ${RT_PATH}/etc/initialdata \
359 install-rt: check-conflicts
360 if [ ${RT_ENABLED} -eq 1 ]; then ( cd rt; make install ); fi
361 if [ ${RT_ENABLED} -eq 1 ]; then perl -p -i -e "\
362 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
363 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
364 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
365 " ${RT_PATH}/etc/RT_SiteConfig.pm; fi
366 if [ ${RT_ENABLED} -eq 1 ]; then \
367 chown -R freeside:freeside ${RT_PATH}/etc; fi
369 install-rt-initialdata:
370 if [ ${RT_ENABLED} -eq 1 ] && [ -d ${RT_PATH} ]; then \
371 chown -R freeside:freeside ${RT_PATH}/etc; \
372 install -D -o freeside -g freeside -m 0440 rt/etc/initialdata \
373 ${RT_PATH}/etc/initialdata; fi
377 torrus_user=freeside var_user=freeside var_group=freeside ./configure
380 if [ ${TORRUS_ENABLED} -eq 1 ]; then ( cd torrus; \
384 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
385 " /usr/local/etc/torrus/conf/torrus-siteconfig.pl; \
391 rm -rf httemplate/docs/man
396 -cd fs_selfservice/FS-SelfService; \
400 ! grep -r --exclude='*config.log*' '--exclude=*config.status*' --exclude=gnupg_details_on_output_formats '--exclude=*mason_handler*' '^=======$$' .
402 #these are probably only useful if you're me...
404 #release: upload-docs
407 # Update the changelog
409 #cvs commit -m "Updated for ${VERSION}" ChangeLog
411 # Update the RPM specfile
412 #cvs edit ${RPM_SPECFILE}
413 #perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
414 #perl -p -i -e "s/\d+[^\}]+/1/ if /%define\s+release\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
415 #cvs commit -m "Updated for ${VERSION}" ${RPM_SPECFILE}
417 # Update the Debian changelog
418 #cvs edit debian/changelog
419 #dch -v ${DEBVERSION} -p "New upstream release"
420 #cvs commit -m "Updated for ${VERSION}" debian/changelog
422 # Make sure other people's changes are pulled in!
429 git archive --prefix=freeside-${VERSION}/ ${TAG} | gzip -9 >freeside-${VERSION}.tar.gz
431 scp freeside-${VERSION}.tar.gz ivan@420.am:/var/www/www.sisd.com/freeside/
432 mv freeside-${VERSION}.tar.gz ..
434 #these things failing should not make release target fail, so: "|| true"
436 #kick off vmware update
437 #./BUILD_VMWARE_APPLIANCE ${$TAG} || true
439 #kick off deb package update
441 #kick off rpm package update too?
445 #update web demo self-service?