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
29 #mod_perl v2 1.999_22 on Apache 2.0 through 2.3 (Debian ancient through 7.x)
31 #Apache 2.4 (Debian 8.x)
35 FREESIDE_DOCUMENT_ROOT = /var/www/freeside
36 #redhat, fedora, mandrake
37 #FREESIDE_DOCUMENT_ROOT = /var/www/html/freeside
39 #FREESIDE_DOCUMENT_ROOT = /usr/local/www/data/freeside
41 #FREESIDE_DOCUMENT_ROOT = /var/www/htdocs/freeside
43 #FREESIDE_DOCUMENT_ROOT = /srv/www/htdocs/freeside
45 #FREESIDE_DOCUMENT_ROOT = /usr/local/apache/htdocs/freeside
47 #deb, redhat, fedora, mandrake, suse, others?
48 INIT_FILE = /etc/init.d/freeside
50 #INIT_FILE = /usr/local/etc/rc.d/011.freeside.sh
53 INIT_INSTALL = PATH=$PATH:/sbin /usr/sbin/update-rc.d freeside defaults 23 01
55 #INIT_INSTALL = /sbin/chkconfig freeside on
56 #not necessary (freebsd)
57 #INIT_INSTALL = /usr/bin/true
60 #HTTPD_RESTART = /etc/init.d/apache restart
62 HTTPD_RESTART = /etc/init.d/apache2 restart
63 #redhat, fedora, mandrake
64 #HTTPD_RESTART = /etc/init.d/httpd restart
66 #HTTPD_RESTART = /usr/local/etc/rc.d/apache.sh stop || true; sleep 10; /usr/local/etc/rc.d/apache.sh start
68 #HTTPD_RESTART = kill -TERM `cat /var/www/logs/httpd.pid`; sleep 10; /usr/sbin/httpd -u -DSSL
70 #HTTPD_RESTART = /usr/local/apache/bin/apachectl stop; sleep 10; /usr/local/apache/bin/apachectl startssl
72 #(an include directory, not a file, "Include /etc/apache/conf.d" in httpd.conf)
73 #debian unstable/8.0+, apache2.4
74 APACHE_CONF = /etc/apache2/conf-available
76 #APACHE_CONF = /etc/apache2/conf.d
78 INSSERV_OVERRIDE = /etc/insserv/overrides
80 FREESIDE_RESTART = ${INIT_FILE} restart
82 #deb, redhat, fedora, mandrake, suse, others?
87 #edit the stuff below to have the daemons start
91 SELFSERVICE_USER = fs_selfservice
92 #never run on the same machine in production!!!
93 SELFSERVICE_MACHINES =
94 # SELFSERVICE_MACHINES = www.example.com
95 # SELFSERVICE_MACHINES = web1.example.com web2.example.com
97 #user with sudo access on SELFSERVICE_MACHINES for automated self-service
99 SELFSERVICE_INSTALL_USER = ivan
100 SELFSERVICE_INSTALL_USERADD = /usr/sbin/useradd
101 #SELFSERVICE_INSTALL_USERADD = "/usr/sbin/pw useradd"
105 RT_DOMAIN = example.com
106 RT_TIMEZONE = US/Pacific
107 #RT_TIMEZONE = US/Eastern
108 FREESIDE_URL = "http://localhost/freeside/"
110 #for now, same db as specified in DATASOURCE... eventually, otherwise?
111 RT_DB_DATABASE = freeside
115 # for auto-version updates, so we can "make release" more things automatically
116 RPM_SPECFILE = rpm/freeside.spec
123 #only used for dev kludge now, not a big deal
124 FREESIDE_PATH = `pwd`
125 PERL_INC_DEV_KLUDGE = /usr/local/share/perl/5.14.2/
127 VERSION := `grep '^$$VERSION' FS/FS.pm | cut -d\' -f2`
128 TAG := freeside_`grep '^$$VERSION' FS/FS.pm | cut -d\' -f2 | perl -pe 's/\./_/g'`
130 #DEBVERSION = `echo ${VERSION} | perl -pe 's/(\d)([a-z])/\1~\2/'`-1
132 TEXMFHOME := "\$$TEXMFHOME"
141 @echo "supported targets:"
142 @echo " create-database create-config"
143 @echo " install deploy"
144 @echo " configure-rt create-rt"
147 @echo " install-docs install-perl-modules"
148 @echo " install-init install-apache"
149 @echo " install-rt install-texmf"
150 @echo " install-selfservice update-selfservice"
152 @echo " dev dev-docs dev-perl-modules"
154 @echo " masondocs alldocs docs"
156 @echo " perl-modules"
158 #@echo " upload-docs release"
161 masondocs: httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/*
163 cp -pr httemplate masondocs
172 chmod a+rx ./bin/pod2x
176 #ancient attempt to avoid overwriting customer modifications directly to production web files that's overlived its usefulness
177 #[ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
178 #cp -r masondocs ${FREESIDE_DOCUMENT_ROOT}
179 [ -h ${FREESIDE_DOCUMENT_ROOT} ] && rm ${FREESIDE_DOCUMENT_ROOT} || true
180 mkdir -p ${FREESIDE_DOCUMENT_ROOT}
181 cp -r masondocs/* masondocs/.htaccess ${FREESIDE_DOCUMENT_ROOT}
182 chown -R freeside:freeside ${FREESIDE_DOCUMENT_ROOT}
183 install -D htetc/handler.pl ${MASON_HANDLER}
185 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
186 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
187 " ${MASON_HANDLER} || true
188 mkdir -p ${FREESIDE_EXPORT}/profile
189 chown freeside ${FREESIDE_EXPORT}/profile
190 [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
191 chown -R freeside ${MASONDATA}
194 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
195 ln -s ${FREESIDE_PATH}/httemplate ${FREESIDE_DOCUMENT_ROOT}
196 cp htetc/handler.pl ${MASON_HANDLER}
198 s'###use Module::Refresh;###'use Module::Refresh;'; \
199 s'###Module::Refresh->refresh;###'Module::Refresh->refresh;'; \
200 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
201 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
202 " ${MASON_HANDLER} || true
206 [ -e Makefile ] || perl Makefile.PL; \
209 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
210 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
211 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
212 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
213 s'%%%RT_PATH%%%'${RT_PATH}'g; \
214 s'%%%MASONDATA%%%'${MASONDATA}'g;\
215 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
218 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
219 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
220 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
221 " blib/lib/FS/Cron/*.pm;\
223 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
224 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
225 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
226 " blib/lib/FS/part_export/*.pm;\
228 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
229 " blib/lib/FS/cust_main/*.pm blib/lib/FS/cust_pkg/*.pm;\
231 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
232 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
233 s|%%%FREESIDE_LOCK%%%|${FREESIDE_LOCK}|g;\
234 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
235 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
236 s|%%%DIST_CONF%%%|${DIST_CONF}|g;\
239 install-perl-modules: perl-modules install-rt-initialdata
240 [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
241 && rm ${PERL_INC_DEV_KLUDGE}/FS \
242 && mv ${PERL_INC_DEV_KLUDGE}/FS.old ${PERL_INC_DEV_KLUDGE}/FS \
245 make install UNINST=1
246 #install this for freeside-setup
247 install -d $(DIST_CONF)
248 #install conf/[a-z]* $(DEFAULT_CONF)
250 install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
252 dev-perl-modules: perl-modules
253 [ -d ${PERL_INC_DEV_KLUDGE}/FS -a ! -L ${PERL_INC_DEV_KLUDGE}/FS ] \
254 && mv ${PERL_INC_DEV_KLUDGE}/FS ${PERL_INC_DEV_KLUDGE}/FS.old \
257 rm -rf ${PERL_INC_DEV_KLUDGE}/FS
258 ln -sf ${FREESIDE_PATH}/FS/blib/lib/FS ${PERL_INC_DEV_KLUDGE}/FS
261 install -D -o freeside -m 444 etc/longtable.sty \
262 /usr/local/share/texmf/tex/latex/longtable.sty
263 texhash /usr/local/share/texmf
266 #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
267 install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
269 s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
270 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
271 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
276 [ -e ${APACHE_CONF}/freeside-base.conf ] && rm ${APACHE_CONF}/freeside-base.conf || true
277 [ -d ${APACHE_CONF} ] && \
278 ( install -o root -m 755 htetc/freeside-base${APACHE_VERSION}.conf ${APACHE_CONF} && \
279 ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \
280 ( [ ${TORRUS_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-torrus.conf ${APACHE_CONF} || true ) && \
282 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
283 s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g; \
284 s'%%%MASON_HANDLER%%%'${MASON_HANDLER}'g; \
285 " ${APACHE_CONF}/freeside-*.conf \
287 [ -d ${APACHE_CONF} ] && [ -x /usr/sbin/a2enconf ] && ( /usr/sbin/a2enconf freeside-base${APACHE_VERSION} ) || true
288 [ -d ${APACHE_CONF} ] && [ ${APACHE_VERSION} = '2.4' ] && [ -x /usr/sbin/a2disconf ] && ( /usr/sbin/a2disconf freeside-base2 ) || true
289 [ -d ${APACHE_CONF} ] && [ -x /usr/sbin/a2enconf ] && [ ${RT_ENABLED} -eq 1 ] && ( /usr/sbin/a2enconf freeside-rt ) || true
290 [ -d ${INSSERV_OVERRIDE} ] && [ -x /sbin/insserv ] && ( install -o root -m 755 init.d/insserv-override-apache2 ${INSSERV_OVERRIDE}/apache2 && insserv -d ) || true
293 [ -e ~freeside ] || cp -pr /etc/skel ~freeside && chown -R freeside ~freeside
294 [ -e ~freeside/.ssh/id_dsa.pub ] || [ -e ~freeside/.ssh/id_rsa.pub ] || su - freeside -c 'ssh-keygen -t dsa'
295 for MACHINE in ${SELFSERVICE_MACHINES}; do \
296 scp -r fs_selfservice/FS-SelfService ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
297 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; perl Makefile.PL && make" ;\
298 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
299 scp ~freeside/.ssh/id_dsa.pub ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
300 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo ${SELFSERVICE_INSTALL_USERADD} freeside; sudo install -d -o freeside -m 755 ~freeside/.ssh/; sudo install -o freeside -m 600 ./id_dsa.pub ~freeside/.ssh/authorized_keys" ;\
301 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo install -o freeside -d /usr/local/freeside" ;\
305 for MACHINE in ${SELFSERVICE_MACHINES}; do \
306 RSYNC_RSH=ssh rsync -rlptz fs_selfservice/FS-SelfService/ ${SELFSERVICE_INSTALL_USER}@$$MACHINE:FS-SelfService ;\
307 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; make clean; perl Makefile.PL && make" ;\
308 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
312 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
313 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
314 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
316 install: install-perl-modules install-docs install-init install-apache install-rt install-torrus install-texmf install-chown
322 dev: dev-perl-modules dev-docs
325 perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
327 create-config: install-perl-modules
328 [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
329 install -d -o freeside ${FREESIDE_CONF}
331 touch ${FREESIDE_CONF}/secrets
332 chown freeside ${FREESIDE_CONF}/secrets
333 chmod 600 ${FREESIDE_CONF}/secrets
335 /bin/echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
336 chmod 600 ${FREESIDE_CONF}/secrets
337 chown freeside ${FREESIDE_CONF}/secrets
339 mkdir "${FREESIDE_CACHE}/counters.${DATASOURCE}"
340 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
342 mkdir "${FREESIDE_CACHE}/cache.${DATASOURCE}"
343 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
345 mkdir "${FREESIDE_EXPORT}/export.${DATASOURCE}"
346 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
348 #install this for freeside-setup
349 install -d $(DIST_CONF)
350 #install conf/[a-z]* $(DEFAULT_CONF)
352 install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
357 cp config.layout.in config.layout; \
359 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
360 s'%%%MASONDATA%%%'${MASONDATA}'g;\
362 ./configure --enable-layout=Freeside\
363 --with-db-type=${DB_TYPE} \
364 --with-db-dba=${DB_USER} \
365 --with-db-database=${RT_DB_DATABASE} \
366 --with-db-rt-user=${DB_USER} \
367 --with-db-rt-pass="${DB_PASSWORD}" \
368 --with-web-user=freeside \
369 --with-web-group=freeside \
370 --with-rt-group=freeside \
371 --with-web-handler=modperl2
373 create-rt: configure-rt
374 [ -d /opt ] || mkdir /opt #doh
375 [ -d /opt/rt3 ] || mkdir /opt/rt3 #
376 [ -d /opt/rt3/share ] || mkdir /opt/rt3/share #
378 rt/sbin/rt-setup-database --dba '${DB_USER}' \
379 --dba-password '${DB_PASSWORD}' \
382 rt/sbin/rt-setup-database --dba-password '${DB_PASSWORD}' \
384 && rt/sbin/rt-setup-database --dba-password '${DB_PASSWORD}' \
386 --datafile ${RT_PATH}/etc/initialdata \
390 if [ ${RT_ENABLED} -eq 1 ]; then ( cd rt; make install ); fi
391 if [ ${RT_ENABLED} -eq 1 ]; then perl -p -i -e "\
392 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
393 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
394 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
395 " ${RT_PATH}/etc/RT_SiteConfig.pm; fi
396 if [ ${RT_ENABLED} -eq 1 ]; then \
397 chown -R freeside:freeside ${RT_PATH}/etc; fi
399 install-rt-initialdata:
400 if [ ${RT_ENABLED} -eq 1 ] && [ -d ${RT_PATH} ]; then \
401 chown -R freeside:freeside ${RT_PATH}/etc; \
402 install -D -o freeside -g freeside -m 0440 rt/etc/initialdata \
403 ${RT_PATH}/etc/initialdata; fi
407 torrus_user=freeside var_user=freeside var_group=freeside ./configure
410 if [ ${TORRUS_ENABLED} -eq 1 ]; then ( cd torrus; \
414 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
415 " /usr/local/etc/torrus/conf/torrus-siteconfig.pl; \
421 rm -rf httemplate/docs/man
426 -cd fs_selfservice/FS-SelfService; \
429 #these are probably only useful if you're me...
431 #release: upload-docs
434 # Update the changelog
436 #cvs commit -m "Updated for ${VERSION}" ChangeLog
438 # Update the RPM specfile
439 #cvs edit ${RPM_SPECFILE}
440 #perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
441 #perl -p -i -e "s/\d+[^\}]+/1/ if /%define\s+release\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
442 #cvs commit -m "Updated for ${VERSION}" ${RPM_SPECFILE}
444 # Update the Debian changelog
445 #cvs edit debian/changelog
446 #dch -v ${DEBVERSION} -p "New upstream release"
447 #cvs commit -m "Updated for ${VERSION}" debian/changelog
449 # Make sure other people's changes are pulled in!
456 git archive --prefix=freeside-${VERSION}/ ${TAG} | gzip -9 >freeside-${VERSION}.tar.gz
458 scp freeside-${VERSION}.tar.gz ivan@420.am:/var/www/www.sisd.com/freeside/
459 mv freeside-${VERSION}.tar.gz ..
461 #these things failing should not make release target fail, so: "|| true"
463 #kick off vmware update
464 #./BUILD_VMWARE_APPLIANCE ${$TAG} || true
466 #kick off deb package update
468 #kick off rpm package update too?
472 #update web demo self-service?