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)
34 #deb (-7 and upgrades)
35 FREESIDE_DOCUMENT_ROOT = /var/www/freeside
36 #deb (new installs of 8+)
37 #FREESIDE_DOCUMENT_ROOT = /var/www/html/freeside
38 #redhat, fedora, mandrake
39 #FREESIDE_DOCUMENT_ROOT = /var/www/html/freeside
41 #FREESIDE_DOCUMENT_ROOT = /usr/local/www/data/freeside
43 #FREESIDE_DOCUMENT_ROOT = /var/www/htdocs/freeside
45 #FREESIDE_DOCUMENT_ROOT = /srv/www/htdocs/freeside
47 #FREESIDE_DOCUMENT_ROOT = /usr/local/apache/htdocs/freeside
49 #deb, redhat, fedora, mandrake, suse, others?
50 INIT_FILE = /etc/init.d/freeside
52 #INIT_FILE = /usr/local/etc/rc.d/011.freeside.sh
55 INIT_INSTALL = PATH=$PATH:/sbin /usr/sbin/update-rc.d freeside defaults 23 01
57 #INIT_INSTALL = /sbin/chkconfig freeside on
58 #not necessary (freebsd)
59 #INIT_INSTALL = /usr/bin/true
62 #HTTPD_RESTART = /etc/init.d/apache restart
64 HTTPD_RESTART = /etc/init.d/apache2 restart
65 #redhat, fedora, mandrake
66 #HTTPD_RESTART = /etc/init.d/httpd restart
68 #HTTPD_RESTART = /usr/local/etc/rc.d/apache.sh stop || true; sleep 10; /usr/local/etc/rc.d/apache.sh start
70 #HTTPD_RESTART = kill -TERM `cat /var/www/logs/httpd.pid`; sleep 10; /usr/sbin/httpd -u -DSSL
72 #HTTPD_RESTART = /usr/local/apache/bin/apachectl stop; sleep 10; /usr/local/apache/bin/apachectl startssl
74 #(an include directory, not a file, "Include /etc/apache/conf.d" in httpd.conf)
75 #debian unstable/8.0+, apache2.4
76 APACHE_CONF = /etc/apache2/conf-available
78 #APACHE_CONF = /etc/apache2/conf.d
80 INSSERV_OVERRIDE = /etc/insserv/overrides
82 FREESIDE_RESTART = ${INIT_FILE} restart
84 #deb, redhat, fedora, mandrake, suse, others?
89 #edit the stuff below to have the daemons start
94 SELFSERVICE_USER = fs_selfservice
95 #never run on the same machine in production!!!
96 SELFSERVICE_MACHINES =
97 # SELFSERVICE_MACHINES = www.example.com
98 # SELFSERVICE_MACHINES = web1.example.com web2.example.com
100 #user with sudo access on SELFSERVICE_MACHINES for automated self-service
102 SELFSERVICE_INSTALL_USER = ivan
103 SELFSERVICE_INSTALL_USERADD = /usr/sbin/useradd
104 #SELFSERVICE_INSTALL_USERADD = "/usr/sbin/pw useradd"
108 RT_DOMAIN = example.com
109 RT_TIMEZONE = US/Pacific
110 #RT_TIMEZONE = US/Eastern
111 FREESIDE_URL = "http://192.168.1.6/freeside/"
113 #for now, same db as specified in DATASOURCE... eventually, otherwise?
114 RT_DB_DATABASE = freeside
118 # for auto-version updates, so we can "make release" more things automatically
119 RPM_SPECFILE = rpm/freeside.spec
126 #only used for dev kludge now, not a big deal
127 FREESIDE_PATH = `pwd`
128 PERL_INC_DEV_KLUDGE = /usr/local/share/perl/5.14.2/
130 VERSION := `grep '^$$VERSION' FS/FS.pm | cut -d\' -f2`
131 TAG := freeside_`grep '^$$VERSION' FS/FS.pm | cut -d\' -f2 | perl -pe 's/\./_/g'`
133 #DEBVERSION = `echo ${VERSION} | perl -pe 's/(\d)([a-z])/\1~\2/'`-1
135 TEXMFHOME := "\$$TEXMFHOME"
144 @echo "supported targets:"
145 @echo " create-database create-config"
146 @echo " install deploy"
147 @echo " configure-rt create-rt"
150 @echo " install-docs install-perl-modules"
151 @echo " install-init install-apache"
152 @echo " install-rt install-texmf"
153 @echo " install-selfservice update-selfservice"
155 @echo " dev dev-docs dev-perl-modules"
157 @echo " masondocs alldocs docs"
159 @echo " perl-modules"
161 #@echo " upload-docs release"
164 masondocs: httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/*
166 cp -pr httemplate masondocs
175 chmod a+rx ./bin/pod2x
179 #ancient attempt to avoid overwriting customer modifications directly to production web files that's overlived its usefulness
180 #[ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
181 #cp -r masondocs ${FREESIDE_DOCUMENT_ROOT}
182 [ -h ${FREESIDE_DOCUMENT_ROOT} ] && rm ${FREESIDE_DOCUMENT_ROOT} || true
183 mkdir -p ${FREESIDE_DOCUMENT_ROOT}
184 cp -r masondocs/* masondocs/.htaccess ${FREESIDE_DOCUMENT_ROOT}
185 chown -R freeside:freeside ${FREESIDE_DOCUMENT_ROOT}
186 install -D htetc/handler.pl ${MASON_HANDLER}
188 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
189 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
190 " ${MASON_HANDLER} || true
191 mkdir -p ${FREESIDE_EXPORT}/profile
192 chown freeside ${FREESIDE_EXPORT}/profile
193 [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
194 chown -R freeside ${MASONDATA}
197 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
198 ln -s ${FREESIDE_PATH}/httemplate ${FREESIDE_DOCUMENT_ROOT}
199 cp htetc/handler.pl ${MASON_HANDLER}
201 s'###use Module::Refresh;###'use Module::Refresh;'; \
202 s'###Module::Refresh->refresh;###'Module::Refresh->refresh;'; \
203 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
204 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
205 " ${MASON_HANDLER} || true
209 [ -e Makefile ] || perl Makefile.PL; \
212 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
213 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
214 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
215 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
216 s'%%%RT_PATH%%%'${RT_PATH}'g; \
217 s'%%%MASONDATA%%%'${MASONDATA}'g;\
218 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
221 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
222 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
223 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
224 " blib/lib/FS/Cron/*.pm;\
226 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
227 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
228 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
229 " blib/lib/FS/part_export/*.pm;\
231 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
232 " blib/lib/FS/cust_main/*.pm blib/lib/FS/cust_pkg/*.pm;\
234 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
235 " blib/lib/FS/Daemon/*.pm;\
237 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
238 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
239 s|%%%FREESIDE_LOCK%%%|${FREESIDE_LOCK}|g;\
240 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
241 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
242 s|%%%DIST_CONF%%%|${DIST_CONF}|g;\
245 install-perl-modules: perl-modules install-rt-initialdata
246 [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
247 && rm ${PERL_INC_DEV_KLUDGE}/FS \
248 && mv ${PERL_INC_DEV_KLUDGE}/FS.old ${PERL_INC_DEV_KLUDGE}/FS \
251 make install UNINST=1
252 #install this for freeside-setup
253 install -d $(DIST_CONF)
254 #install conf/[a-z]* $(DEFAULT_CONF)
256 install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
258 dev-perl-modules: perl-modules
259 [ -d ${PERL_INC_DEV_KLUDGE}/FS -a ! -L ${PERL_INC_DEV_KLUDGE}/FS ] \
260 && mv ${PERL_INC_DEV_KLUDGE}/FS ${PERL_INC_DEV_KLUDGE}/FS.old \
263 rm -rf ${PERL_INC_DEV_KLUDGE}/FS
264 ln -sf ${FREESIDE_PATH}/FS/blib/lib/FS ${PERL_INC_DEV_KLUDGE}/FS
267 install -D -o freeside -m 444 etc/longtable.sty \
268 /usr/local/share/texmf/tex/latex/longtable.sty
269 texhash /usr/local/share/texmf
272 #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
273 install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
275 s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
276 s/%%%API_USER%%%/${API_USER}/g;\
277 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
278 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
283 [ -e ${APACHE_CONF}/freeside-base.conf ] && rm ${APACHE_CONF}/freeside-base.conf || true
284 [ -d ${APACHE_CONF} ] && \
285 ( install -o root -m 755 htetc/freeside-base${APACHE_VERSION}.conf ${APACHE_CONF} && \
286 ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \
287 ( [ ${TORRUS_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-torrus.conf ${APACHE_CONF} || true ) && \
289 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
290 s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g; \
291 s'%%%MASON_HANDLER%%%'${MASON_HANDLER}'g; \
292 " ${APACHE_CONF}/freeside-*.conf \
294 [ -d ${APACHE_CONF} ] && [ -x /usr/sbin/a2enconf ] && ( /usr/sbin/a2enconf freeside-base${APACHE_VERSION} ) || true
295 [ -d ${APACHE_CONF} ] && [ ${APACHE_VERSION} = '2.4' ] && [ -x /usr/sbin/a2disconf ] && ( /usr/sbin/a2disconf freeside-base2 ) || true
296 [ -d ${APACHE_CONF} ] && [ -x /usr/sbin/a2enconf ] && [ ${RT_ENABLED} -eq 1 ] && ( /usr/sbin/a2enconf freeside-rt ) || true
297 [ -d ${INSSERV_OVERRIDE} ] && [ -x /sbin/insserv ] && ( install -o root -m 755 init.d/insserv-override-apache2 ${INSSERV_OVERRIDE}/apache2 && insserv -d ) || true
300 [ -e ~freeside ] || cp -pr /etc/skel ~freeside && chown -R freeside ~freeside
301 [ -e ~freeside/.ssh/id_rsa.pub ] || su - freeside -c 'ssh-keygen'
302 for MACHINE in ${SELFSERVICE_MACHINES}; do \
303 scp -r fs_selfservice/FS-SelfService ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
304 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; perl Makefile.PL && make" ;\
305 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
306 scp ~freeside/.ssh/id_rsa.pub ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
307 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_rsa.pub ~freeside/.ssh/authorized_keys" ;\
308 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo install -o freeside -d /usr/local/freeside" ;\
312 for MACHINE in ${SELFSERVICE_MACHINES}; do \
313 RSYNC_RSH=ssh rsync -rlptz fs_selfservice/FS-SelfService/ ${SELFSERVICE_INSTALL_USER}@$$MACHINE:FS-SelfService ;\
314 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; make clean; perl Makefile.PL && make" ;\
315 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
319 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
320 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
321 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
323 install: install-perl-modules install-docs install-init install-apache install-rt install-torrus install-texmf install-chown
329 dev: dev-perl-modules dev-docs
332 perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
334 create-config: install-perl-modules
335 [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
336 install -d -o freeside ${FREESIDE_CONF}
338 touch ${FREESIDE_CONF}/secrets
339 chown freeside ${FREESIDE_CONF}/secrets
340 chmod 600 ${FREESIDE_CONF}/secrets
342 /bin/echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
343 chmod 600 ${FREESIDE_CONF}/secrets
344 chown freeside ${FREESIDE_CONF}/secrets
346 mkdir "${FREESIDE_CACHE}/counters.${DATASOURCE}"
347 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
349 mkdir "${FREESIDE_CACHE}/cache.${DATASOURCE}"
350 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
352 mkdir "${FREESIDE_EXPORT}/export.${DATASOURCE}"
353 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
355 #install this for freeside-setup
356 install -d $(DIST_CONF)
357 #install conf/[a-z]* $(DEFAULT_CONF)
359 install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
364 cp config.layout.in config.layout; \
366 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
367 s'%%%MASONDATA%%%'${MASONDATA}'g;\
369 ./configure --enable-layout=Freeside\
370 --with-db-type=${DB_TYPE} \
371 --with-db-dba=${DB_USER} \
372 --with-db-database=${RT_DB_DATABASE} \
373 --with-db-rt-user=${DB_USER} \
374 --with-db-rt-pass="${DB_PASSWORD}" \
375 --with-web-user=freeside \
376 --with-web-group=freeside \
377 --with-rt-group=freeside \
378 --with-web-handler=modperl2
380 create-rt: configure-rt
381 [ -d /opt ] || mkdir /opt #doh
382 [ -d /opt/rt3 ] || mkdir /opt/rt3 #
383 [ -d /opt/rt3/share ] || mkdir /opt/rt3/share #
385 rt/sbin/rt-setup-database --dba '${DB_USER}' \
386 --dba-password '${DB_PASSWORD}' \
389 rt/sbin/rt-setup-database --dba-password '${DB_PASSWORD}' \
391 && rt/sbin/rt-setup-database --dba-password '${DB_PASSWORD}' \
393 --datafile ${RT_PATH}/etc/initialdata \
397 if [ ${RT_ENABLED} -eq 1 ]; then ( cd rt; make install ); fi
398 if [ ${RT_ENABLED} -eq 1 ]; then perl -p -i -e "\
399 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
400 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
401 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
402 " ${RT_PATH}/etc/RT_SiteConfig.pm; fi
403 if [ ${RT_ENABLED} -eq 1 ]; then \
404 chown -R freeside:freeside ${RT_PATH}/etc; fi
406 install-rt-initialdata:
407 if [ ${RT_ENABLED} -eq 1 ] && [ -d ${RT_PATH} ]; then \
408 chown -R freeside:freeside ${RT_PATH}/etc; \
409 install -D -o freeside -g freeside -m 0440 rt/etc/initialdata \
410 ${RT_PATH}/etc/initialdata; fi
414 torrus_user=freeside var_user=freeside var_group=freeside ./configure
417 if [ ${TORRUS_ENABLED} -eq 1 ]; then ( cd torrus; \
421 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
422 " /usr/local/etc/torrus/conf/torrus-siteconfig.pl; \
428 rm -rf httemplate/docs/man
433 -cd fs_selfservice/FS-SelfService; \
436 #these are probably only useful if you're me...
438 #release: upload-docs
441 # Update the changelog
443 #cvs commit -m "Updated for ${VERSION}" ChangeLog
445 # Update the RPM specfile
446 #cvs edit ${RPM_SPECFILE}
447 #perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
448 #perl -p -i -e "s/\d+[^\}]+/1/ if /%define\s+release\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
449 #cvs commit -m "Updated for ${VERSION}" ${RPM_SPECFILE}
451 # Update the Debian changelog
452 #cvs edit debian/changelog
453 #dch -v ${DEBVERSION} -p "New upstream release"
454 #cvs commit -m "Updated for ${VERSION}" debian/changelog
456 # Make sure other people's changes are pulled in!
463 git archive --prefix=freeside-${VERSION}/ ${TAG} | gzip -9 >freeside-${VERSION}.tar.gz
465 scp freeside-${VERSION}.tar.gz ivan@freeside.biz:/var/www/www.freeside.biz/freeside/
466 mv freeside-${VERSION}.tar.gz ..
468 #these things failing should not make release target fail, so: "|| true"
470 #kick off vmware update
471 #./BUILD_VMWARE_APPLIANCE ${$TAG} || true
473 #kick off deb package update
475 #kick off rpm package update too?
479 #update web demo self-service?