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
70 INSSERV_OVERRIDE = /etc/insserv/overrides
72 FREESIDE_RESTART = ${INIT_FILE} restart
74 #deb, redhat, fedora, mandrake, suse, others?
79 #edit the stuff below to have the daemons start
84 SELFSERVICE_USER = fs_selfservice
85 #never run on the same machine in production!!!
86 SELFSERVICE_MACHINES =
87 # SELFSERVICE_MACHINES = www.example.com
88 # SELFSERVICE_MACHINES = web1.example.com web2.example.com
90 #user with sudo access on SELFSERVICE_MACHINES for automated self-service
92 SELFSERVICE_INSTALL_USER = ivan
93 SELFSERVICE_INSTALL_USERADD = /usr/sbin/useradd
94 #SELFSERVICE_INSTALL_USERADD = "/usr/sbin/pw useradd"
98 RT_DOMAIN = example.com
99 RT_TIMEZONE = US/Pacific
100 #RT_TIMEZONE = US/Eastern
101 FREESIDE_URL = "http://localhost/freeside/"
103 #for now, same db as specified in DATASOURCE... eventually, otherwise?
104 RT_DB_DATABASE = freeside
108 # for auto-version updates, so we can "make release" more things automatically
109 RPM_SPECFILE = rpm/freeside.spec
116 #only used for dev kludge now, not a big deal
117 FREESIDE_PATH = `pwd`
118 PERL_INC_DEV_KLUDGE = /usr/local/share/perl/5.14.2/
120 VERSION := `grep '^$$VERSION' FS/FS.pm | cut -d\' -f2`
121 TAG := freeside_`grep '^$$VERSION' FS/FS.pm | cut -d\' -f2 | perl -pe 's/\./_/g'`
123 #DEBVERSION = `echo ${VERSION} | perl -pe 's/(\d)([a-z])/\1~\2/'`-1
125 TEXMFHOME := "\$$TEXMFHOME"
134 @echo "supported targets:"
135 @echo " create-database create-config"
136 @echo " install deploy"
137 @echo " configure-rt create-rt"
140 @echo " install-docs install-perl-modules"
141 @echo " install-init install-apache"
142 @echo " install-rt install-texmf"
143 @echo " install-selfservice update-selfservice"
145 @echo " dev dev-docs dev-perl-modules"
147 @echo " masondocs alldocs docs"
149 @echo " perl-modules"
151 #@echo " upload-docs release"
154 masondocs: httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/*
156 cp -pr httemplate masondocs
165 chmod a+rx ./bin/pod2x
168 install-docs: check-conflicts docs
169 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
170 cp -r masondocs ${FREESIDE_DOCUMENT_ROOT}
171 chown -R freeside:freeside ${FREESIDE_DOCUMENT_ROOT}
172 cp htetc/handler.pl ${MASON_HANDLER}
174 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
175 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
176 " ${MASON_HANDLER} || true
177 mkdir -p ${FREESIDE_EXPORT}/profile
178 chown freeside ${FREESIDE_EXPORT}/profile
179 cp htetc/htpasswd.logout ${FREESIDE_CONF}
180 [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
181 chown -R freeside ${MASONDATA}
184 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
185 ln -s ${FREESIDE_PATH}/httemplate ${FREESIDE_DOCUMENT_ROOT}
186 cp htetc/handler.pl ${MASON_HANDLER}
188 s'###use Module::Refresh;###'use Module::Refresh;'; \
189 s'###Module::Refresh->refresh;###'Module::Refresh->refresh;'; \
190 " ${MASON_HANDLER} || true
194 [ -e Makefile ] || perl Makefile.PL; \
197 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
198 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
199 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
200 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
201 s'%%%RT_PATH%%%'${RT_PATH}'g; \
202 s'%%%MASONDATA%%%'${MASONDATA}'g;\
203 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
206 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
207 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
208 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
209 " blib/lib/FS/Cron/*.pm;\
211 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
212 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
213 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
214 " blib/lib/FS/part_export/*.pm;\
216 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
217 " blib/lib/FS/cust_main/*.pm blib/lib/FS/cust_pkg/*.pm;\
219 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
220 " blib/lib/FS/Daemon/*.pm;\
222 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
223 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
224 s|%%%FREESIDE_LOCK%%%|${FREESIDE_LOCK}|g;\
225 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
226 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
227 s|%%%DIST_CONF%%%|${DIST_CONF}|g;\
230 install-perl-modules: check-conflicts perl-modules install-rt-initialdata
231 [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
232 && rm ${PERL_INC_DEV_KLUDGE}/FS \
233 && mv ${PERL_INC_DEV_KLUDGE}/FS.old ${PERL_INC_DEV_KLUDGE}/FS \
236 make install UNINST=1
237 #install this for freeside-setup
238 install -d $(DIST_CONF)
239 #install conf/[a-z]* $(DEFAULT_CONF)
241 install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
243 dev-perl-modules: perl-modules
244 [ -d ${PERL_INC_DEV_KLUDGE}/FS -a ! -L ${PERL_INC_DEV_KLUDGE}/FS ] \
245 && mv ${PERL_INC_DEV_KLUDGE}/FS ${PERL_INC_DEV_KLUDGE}/FS.old \
248 rm -rf ${PERL_INC_DEV_KLUDGE}/FS
249 ln -sf ${FREESIDE_PATH}/FS/blib/lib/FS ${PERL_INC_DEV_KLUDGE}/FS
252 install -D -o freeside -m 444 etc/longtable.sty \
253 /usr/local/share/texmf/tex/latex/longtable.sty
254 texhash /usr/local/share/texmf
257 #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
258 install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
260 s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
261 s/%%%API_USER%%%/${API_USER}/g;\
262 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
263 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
268 [ -e ${APACHE_CONF}/freeside-base.conf ] && rm ${APACHE_CONF}/freeside-base.conf || true
269 [ -d ${APACHE_CONF} ] && \
270 ( install -o root -m 755 htetc/freeside-base2.conf ${APACHE_CONF} && \
271 ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \
272 ( [ ${TORRUS_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-torrus.conf ${APACHE_CONF} || true ) && \
274 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
275 s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g; \
276 s'%%%MASON_HANDLER%%%'${MASON_HANDLER}'g; \
277 " ${APACHE_CONF}/freeside-*.conf \
279 [ -d ${INSSERV_OVERRIDE} ] && [ -x /sbin/insserv ] && ( install -o root -m 755 init.d/insserv-override-apache2 ${INSSERV_OVERRIDE}/apache2 && insserv -d ) || true
282 [ -e ~freeside ] || cp -pr /etc/skel ~freeside && chown -R freeside ~freeside
283 [ -e ~freeside/.ssh/id_dsa.pub ] || [ -e ~freeside/.ssh/id_rsa.pub ] || su - freeside -c 'ssh-keygen -t dsa'
284 for MACHINE in ${SELFSERVICE_MACHINES}; do \
285 scp -r fs_selfservice/FS-SelfService ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
286 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; perl Makefile.PL && make" ;\
287 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
288 scp ~freeside/.ssh/id_dsa.pub ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
289 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" ;\
290 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo install -o freeside -d /usr/local/freeside" ;\
294 for MACHINE in ${SELFSERVICE_MACHINES}; do \
295 RSYNC_RSH=ssh rsync -rlptz fs_selfservice/FS-SelfService/ ${SELFSERVICE_INSTALL_USER}@$$MACHINE:FS-SelfService ;\
296 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; make clean; perl Makefile.PL && make" ;\
297 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
301 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
302 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
303 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
305 install: install-perl-modules install-docs install-init install-apache install-rt install-torrus install-texmf install-chown
311 dev: dev-perl-modules dev-docs
314 perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
316 create-config: install-perl-modules
317 [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
318 install -d -o freeside ${FREESIDE_CONF}
320 touch ${FREESIDE_CONF}/secrets
321 chown freeside ${FREESIDE_CONF}/secrets
322 chmod 600 ${FREESIDE_CONF}/secrets
324 /bin/echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
325 chmod 600 ${FREESIDE_CONF}/secrets
326 chown freeside ${FREESIDE_CONF}/secrets
328 mkdir "${FREESIDE_CACHE}/counters.${DATASOURCE}"
329 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
331 mkdir "${FREESIDE_CACHE}/cache.${DATASOURCE}"
332 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
334 mkdir "${FREESIDE_EXPORT}/export.${DATASOURCE}"
335 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
337 #install this for freeside-setup
338 install -d $(DIST_CONF)
339 #install conf/[a-z]* $(DEFAULT_CONF)
341 install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
346 cp config.layout.in config.layout; \
348 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
349 s'%%%MASONDATA%%%'${MASONDATA}'g;\
351 ./configure --enable-layout=Freeside\
352 --with-db-type=${DB_TYPE} \
353 --with-db-dba=${DB_USER} \
354 --with-db-database=${RT_DB_DATABASE} \
355 --with-db-rt-user=${DB_USER} \
356 --with-db-rt-pass="${DB_PASSWORD}" \
357 --with-web-user=freeside \
358 --with-web-group=freeside \
359 --with-rt-group=freeside \
360 --with-web-handler=modperl2
362 create-rt: configure-rt
363 [ -d /opt ] || mkdir /opt #doh
364 [ -d /opt/rt3 ] || mkdir /opt/rt3 #
365 [ -d /opt/rt3/share ] || mkdir /opt/rt3/share #
367 rt/sbin/rt-setup-database --dba '${DB_USER}' \
368 --dba-password '${DB_PASSWORD}' \
371 rt/sbin/rt-setup-database --dba-password '${DB_PASSWORD}' \
373 && rt/sbin/rt-setup-database --dba-password '${DB_PASSWORD}' \
375 --datafile ${RT_PATH}/etc/initialdata \
378 install-rt: check-conflicts
379 if [ ${RT_ENABLED} -eq 1 ]; then ( cd rt; make install ); fi
380 if [ ${RT_ENABLED} -eq 1 ]; then perl -p -i -e "\
381 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
382 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
383 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
384 " ${RT_PATH}/etc/RT_SiteConfig.pm; fi
385 if [ ${RT_ENABLED} -eq 1 ]; then \
386 chown -R freeside:freeside ${RT_PATH}/etc; fi
388 install-rt-initialdata:
389 if [ ${RT_ENABLED} -eq 1 ] && [ -d ${RT_PATH} ]; then \
390 chown -R freeside:freeside ${RT_PATH}/etc; \
391 install -D -o freeside -g freeside -m 0440 rt/etc/initialdata \
392 ${RT_PATH}/etc/initialdata; fi
396 torrus_user=freeside var_user=freeside var_group=freeside ./configure
399 if [ ${TORRUS_ENABLED} -eq 1 ]; then ( cd torrus; \
403 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
404 " /usr/local/etc/torrus/conf/torrus-siteconfig.pl; \
410 rm -rf httemplate/docs/man
415 -cd fs_selfservice/FS-SelfService; \
419 ! grep -r --exclude='*config.log*' '--exclude=*config.status*' --exclude=gnupg_details_on_output_formats '--exclude=*mason_handler*' '^=======$$' .
421 #these are probably only useful if you're me...
423 #release: upload-docs
426 # Update the changelog
428 #cvs commit -m "Updated for ${VERSION}" ChangeLog
430 # Update the RPM specfile
431 #cvs edit ${RPM_SPECFILE}
432 #perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
433 #perl -p -i -e "s/\d+[^\}]+/1/ if /%define\s+release\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
434 #cvs commit -m "Updated for ${VERSION}" ${RPM_SPECFILE}
436 # Update the Debian changelog
437 #cvs edit debian/changelog
438 #dch -v ${DEBVERSION} -p "New upstream release"
439 #cvs commit -m "Updated for ${VERSION}" debian/changelog
441 # Make sure other people's changes are pulled in!
448 git archive --prefix=freeside-${VERSION}/ ${TAG} | gzip -9 >freeside-${VERSION}.tar.gz
450 scp freeside-${VERSION}.tar.gz ivan@420.am:/var/www/www.sisd.com/freeside/
451 mv freeside-${VERSION}.tar.gz ..
453 #these things failing should not make release target fail, so: "|| true"
455 #kick off vmware update
456 #./BUILD_VMWARE_APPLIANCE ${$TAG} || true
458 #kick off deb package update
460 #kick off rpm package update too?
464 #update web demo self-service?