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
26 #mod_perl v2 prereleases up to and including 1.999_21
28 #mod_perl v2 proper and prereleases 1.999_22 and after
32 FREESIDE_DOCUMENT_ROOT = /var/www/freeside
33 #redhat, fedora, mandrake
34 #FREESIDE_DOCUMENT_ROOT = /var/www/html/freeside
36 #FREESIDE_DOCUMENT_ROOT = /usr/local/www/data/freeside
38 #FREESIDE_DOCUMENT_ROOT = /var/www/htdocs/freeside
40 #FREESIDE_DOCUMENT_ROOT = /srv/www/htdocs/freeside
42 #FREESIDE_DOCUMENT_ROOT = /usr/local/apache/htdocs/freeside
44 #deb, redhat, fedora, mandrake, suse, others?
45 INIT_FILE = /etc/init.d/freeside
47 #INIT_FILE = /usr/local/etc/rc.d/011.freeside.sh
50 INIT_INSTALL = /usr/sbin/update-rc.d freeside defaults 21 20
52 #INIT_INSTALL = /sbin/chkconfig freeside on
53 #not necessary (freebsd)
54 #INIT_INSTALL = /usr/bin/true
57 #HTTPD_RESTART = /etc/init.d/apache restart
59 HTTPD_RESTART = /etc/init.d/apache2 restart
60 #redhat, fedora, mandrake
61 #HTTPD_RESTART = /etc/init.d/httpd restart
63 #HTTPD_RESTART = /usr/local/etc/rc.d/apache.sh stop || true; sleep 10; /usr/local/etc/rc.d/apache.sh start
65 #HTTPD_RESTART = kill -TERM `cat /var/www/logs/httpd.pid`; sleep 10; /usr/sbin/httpd -u -DSSL
67 #HTTPD_RESTART = /usr/local/apache/bin/apachectl stop; sleep 10; /usr/local/apache/bin/apachectl startssl
69 #(an include directory, not a file, "Include /etc/apache/conf.d" in httpd.conf)
71 #APACHE_CONF = /etc/apache/conf.d
73 APACHE_CONF = /etc/apache2/conf.d
75 FREESIDE_RESTART = ${INIT_FILE} restart
77 #deb, redhat, fedora, mandrake, suse, others?
82 #edit the stuff below to have the daemons start
86 SELFSERVICE_USER = fs_selfservice
87 #never run on the same machine in production!!!
88 SELFSERVICE_MACHINES =
89 # SELFSERVICE_MACHINES = www.example.com
90 # SELFSERVICE_MACHINES = web1.example.com web2.example.com
92 #user with sudo access on SELFSERVICE_MACHINES for automated self-service
94 SELFSERVICE_INSTALL_USER = ivan
95 SELFSERVICE_INSTALL_USERADD = /usr/sbin/useradd
96 #SELFSERVICE_INSTALL_USERADD = "/usr/sbin/pw useradd"
100 RT_DOMAIN = example.com
101 RT_TIMEZONE = US/Pacific
102 #RT_TIMEZONE = US/Eastern
103 FREESIDE_URL = "http://localhost/freeside/"
105 #for now, same db as specified in DATASOURCE... eventually, otherwise?
106 RT_DB_DATABASE = freeside
108 RPM_SPECFILE = install/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.8.8/
123 DEBVERSION = `echo ${VERSION} | perl -pe 's/(\d)([a-z])/\1~\2/'`-1
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"
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 update-webdemo"
146 masondocs: httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/*
148 cp -pr httemplate masondocs
157 chmod a+rx ./bin/pod2x
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}
166 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
167 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
168 s'%%%MASONDATA%%%'${MASONDATA}'g;\
170 [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
171 chown -R freeside ${MASONDATA}
174 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
175 ln -s ${FREESIDE_PATH}/httemplate ${FREESIDE_DOCUMENT_ROOT}
176 cp htetc/handler.pl ${MASON_HANDLER}
178 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
179 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
180 s'%%%MASONDATA%%%'${MASONDATA}'g;\
181 s'###use Module::Refresh;###'use Module::Refresh;'; \
182 s'###Module::Refresh->refresh;###'Module::Refresh->refresh;'; \
183 " ${MASON_HANDLER} || true
188 [ -e Makefile ] || perl Makefile.PL; \
191 s/%%%VERSION%%%/${VERSION}/g;\
194 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
195 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
198 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
199 " blib/lib/FS/part_export/*.pm;\
201 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
202 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
203 s|%%%FREESIDE_LOCK%%%|${FREESIDE_LOCK}|g;\
204 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
205 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
208 install-perl-modules: perl-modules
209 [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
210 && rm ${PERL_INC_DEV_KLUDGE}/FS \
211 && mv ${PERL_INC_DEV_KLUDGE}/FS.old ${PERL_INC_DEV_KLUDGE}/FS \
214 make install UNINST=1
216 dev-perl-modules: perl-modules
217 [ -d ${PERL_INC_DEV_KLUDGE}/FS -a ! -L ${PERL_INC_DEV_KLUDGE}/FS ] \
218 && mv ${PERL_INC_DEV_KLUDGE}/FS ${PERL_INC_DEV_KLUDGE}/FS.old \
221 rm -rf ${PERL_INC_DEV_KLUDGE}/FS
222 ln -sf ${FREESIDE_PATH}/FS/blib/lib/FS ${PERL_INC_DEV_KLUDGE}/FS
225 #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
226 install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
228 s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
229 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
230 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
235 [ -e ${APACHE_CONF}/freeside-base.conf ] && rm ${APACHE_CONF}/freeside-base.conf || true
236 [ -d ${APACHE_CONF} ] && \
237 ( install -o root -m 755 htetc/freeside-base${APACHE_VERSION}.conf ${APACHE_CONF} && \
238 ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \
240 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
241 s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g; \
242 s'%%%MASON_HANDLER%%%'${MASON_HANDLER}'g; \
243 " ${APACHE_CONF}/freeside-*.conf \
247 [ -e ~freeside ] || cp -pr /etc/skel ~freeside && chown -R freeside ~freeside
248 [ -e ~freeside/.ssh/id_dsa.pub ] || [ -e ~freeside/.ssh/id_rsa.pub ] || su - freeside -c 'ssh-keygen -t dsa'
249 for MACHINE in ${SELFSERVICE_MACHINES}; do \
250 scp -r fs_selfservice/FS-SelfService ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
251 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; perl Makefile.PL && make" ;\
252 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
253 scp ~freeside/.ssh/id_dsa.pub ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
254 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo ${SELFSERVICE_INSTALL_USERADD} freeside; sudo install -d -o freeside -m 600 ~freeside/.ssh/" ;\
255 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo ${SELFSERVICE_INSTALL_USERADD} freeside; sudo install -o freeside -m 600 ./id_dsa.pub ~freeside/.ssh/authorized_keys" ;\
256 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo install -o freeside -d /usr/local/freeside" ;\
260 for MACHINE in ${SELFSERVICE_MACHINES}; do \
261 RSYNC_RSH=ssh rsync -rlptz fs_selfservice/FS-SelfService/ ${SELFSERVICE_INSTALL_USER}@$$MACHINE:FS-SelfService ;\
262 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; make clean; perl Makefile.PL && make" ;\
263 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
266 install: install-perl-modules install-docs install-init install-apache install-rt
272 dev: dev-perl-modules dev-docs
275 perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
277 create-config: install-perl-modules
278 [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
279 install -d -o freeside ${FREESIDE_CONF}
281 touch ${FREESIDE_CONF}/secrets
282 chown freeside ${FREESIDE_CONF}/secrets
283 chmod 600 ${FREESIDE_CONF}/secrets
285 echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
286 chmod 600 ${FREESIDE_CONF}/secrets
287 chown freeside ${FREESIDE_CONF}/secrets
289 mkdir "${FREESIDE_CONF}/conf.${DATASOURCE}"
290 rm -rf conf/registries #old dirs just won't go away
291 #cp conf/[a-z]* "${FREESIDE_CONF}/conf.${DATASOURCE}"
292 cp `ls -d conf/[a-z]* | grep -v CVS` "${FREESIDE_CONF}/conf.${DATASOURCE}"
293 chown -R freeside "${FREESIDE_CONF}/conf.${DATASOURCE}"
295 mkdir "${FREESIDE_CACHE}/counters.${DATASOURCE}"
296 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
298 mkdir "${FREESIDE_CACHE}/cache.${DATASOURCE}"
299 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
301 mkdir "${FREESIDE_EXPORT}/export.${DATASOURCE}"
302 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
306 cp config.layout.in config.layout; \
308 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
309 s'%%%MASONDATA%%%'${MASONDATA}'g;\
311 ./configure --enable-layout=Freeside\
312 --with-db-type=${DB_TYPE} \
313 --with-db-dba=${DB_USER} \
314 --with-db-database=${RT_DB_DATABASE} \
315 --with-db-rt-user=${DB_USER} \
316 --with-db-rt-pass=${DB_PASSWORD} \
317 --with-web-user=freeside \
318 --with-web-group=freeside \
319 --with-rt-group=freeside
321 create-rt: configure-rt
322 [ -d /opt ] || mkdir /opt #doh
323 [ -d /opt/rt3 ] || mkdir /opt/rt3 #
324 [ -d /opt/rt3/share ] || mkdir /opt/rt3/share #
326 rt/sbin/rt-setup-database --dba '${DB_USER}' \
327 -dba-password '${DB_PASSWORD}' \
330 rt/sbin/rt-setup-database --action insert_initial \
331 && rt/sbin/rt-setup-database --action insert --datafile ${RT_PATH}/etc/initialdata \
334 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
335 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
336 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
337 " ${RT_PATH}/etc/RT_SiteConfig.pm
340 [ ${RT_ENABLED} -eq 1 ] && ( cd rt; make install ) || true
344 rm -rf httemplate/docs/man
349 -cd fs_selfservice/FS-SelfService; \
352 #these are probably only useful if you're me...
354 #release: upload-docs
357 # Update the changelog
359 cvs commit -m "Updated for ${VERSION}" ChangeLog
361 # Update the RPM specfile
362 cvs edit ${RPM_SPECFILE}
363 perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
364 cvs commit -m "Updated for ${VERSION}" ${RPM_SPECFILE}
366 # Update the Debian changelog
367 cvs edit debian/changelog
368 dch -v ${DEBVERSION} -p "New upstream release"
369 cvs commit -m "Updated for ${VERSION}" debian/changelog
375 cvs export -r ${TAG} -d freeside-${VERSION} freeside
376 tar czvf freeside-${VERSION}.tar.gz freeside-${VERSION}
378 scp freeside-${VERSION}.tar.gz ivan@420.am:/var/www/www.sisd.com/freeside/
379 mv freeside-${VERSION} freeside-${VERSION}.tar.gz ..
381 #these things failing should not make release target fail, so: "|| true"
383 #kick off vmware update
384 #./BUILD_VMWARE_APPLIANCE ${$TAG} || true
386 #kick off deb package update
388 #kick off rpm package update too?
392 #update web demo self-service?
395 ssh ivan@420.am '( cd freeside; cvs update -d -P )'
396 #ssh root@420.am '( cd /home/ivan/freeside; make clean; make deploy )'
397 ssh root@420.am '( cd /home/ivan/freeside; make deploy )'