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 = localhost
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;\
197 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
198 " blib/lib/FS/part_export/*.pm;\
200 s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
201 s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
202 s|%%%FREESIDE_LOCK%%%|${FREESIDE_LOCK}|g;\
203 s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
204 s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
207 install-perl-modules: perl-modules
208 [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
209 && rm ${PERL_INC_DEV_KLUDGE}/FS \
210 && mv ${PERL_INC_DEV_KLUDGE}/FS.old ${PERL_INC_DEV_KLUDGE}/FS \
213 make install UNINST=1
215 dev-perl-modules: perl-modules
216 [ -d ${PERL_INC_DEV_KLUDGE}/FS -a ! -L ${PERL_INC_DEV_KLUDGE}/FS ] \
217 && mv ${PERL_INC_DEV_KLUDGE}/FS ${PERL_INC_DEV_KLUDGE}/FS.old \
220 rm -rf ${PERL_INC_DEV_KLUDGE}/FS
221 ln -sf ${FREESIDE_PATH}/FS/blib/lib/FS ${PERL_INC_DEV_KLUDGE}/FS
224 #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
225 install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
227 s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
228 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
229 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
234 [ -e ${APACHE_CONF}/freeside-base.conf ] && rm ${APACHE_CONF}/freeside-base.conf || true
235 [ -d ${APACHE_CONF} ] && \
236 ( install -o root -m 755 htetc/freeside-base${APACHE_VERSION}.conf ${APACHE_CONF} && \
237 ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \
239 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
240 s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g; \
241 s'%%%MASON_HANDLER%%%'${MASON_HANDLER}'g; \
242 " ${APACHE_CONF}/freeside-*.conf \
246 [ -e ~freeside ] || cp -pr /etc/skel ~freeside && chown -R freeside ~freeside
247 [ -e ~freeside/.ssh/id_dsa.pub ] || su - freeside -c 'ssh-keygen -t dsa'
248 for MACHINE in ${SELFSERVICE_MACHINES}; do \
249 scp -r fs_selfservice/FS-SelfService ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
250 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; perl Makefile.PL && make" ;\
251 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
252 scp ~freeside/.ssh/id_dsa.pub ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
253 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo ${SELFSERVICE_INSTALL_USERADD} freeside; sudo install -d -o freeside -m 600 ~freeside/.ssh/" ;\
254 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo ${SELFSERVICE_INSTALL_USERADD} freeside; sudo install -o freeside -m 600 ./id_dsa.pub ~freeside/.ssh/authorized_keys" ;\
255 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo install -o freeside -d /usr/local/freeside" ;\
259 for MACHINE in ${SELFSERVICE_MACHINES}; do \
260 RSYNC_RSH=ssh rsync -rlptz fs_selfservice/FS-SelfService/ ${SELFSERVICE_INSTALL_USER}@$$MACHINE:FS-SelfService ;\
261 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; make clean; perl Makefile.PL && make" ;\
262 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
265 install: install-perl-modules install-docs install-init install-apache install-rt
271 dev: dev-perl-modules dev-docs
274 perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
276 create-config: install-perl-modules
277 [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
278 install -d -o freeside ${FREESIDE_CONF}
280 touch ${FREESIDE_CONF}/secrets
281 chown freeside ${FREESIDE_CONF}/secrets
282 chmod 600 ${FREESIDE_CONF}/secrets
284 echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
285 chmod 600 ${FREESIDE_CONF}/secrets
286 chown freeside ${FREESIDE_CONF}/secrets
288 mkdir "${FREESIDE_CONF}/conf.${DATASOURCE}"
289 rm -rf conf/registries #old dirs just won't go away
290 #cp conf/[a-z]* "${FREESIDE_CONF}/conf.${DATASOURCE}"
291 cp `ls -d conf/[a-z]* | grep -v CVS` "${FREESIDE_CONF}/conf.${DATASOURCE}"
292 chown -R freeside "${FREESIDE_CONF}/conf.${DATASOURCE}"
294 mkdir "${FREESIDE_CACHE}/counters.${DATASOURCE}"
295 chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
297 mkdir "${FREESIDE_CACHE}/cache.${DATASOURCE}"
298 chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
300 mkdir "${FREESIDE_EXPORT}/export.${DATASOURCE}"
301 chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
305 cp config.layout.in config.layout; \
307 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
308 s'%%%MASONDATA%%%'${MASONDATA}'g;\
310 ./configure --enable-layout=Freeside\
311 --with-db-type=${DB_TYPE} \
312 --with-db-dba=${DB_USER} \
313 --with-db-database=${RT_DB_DATABASE} \
314 --with-db-rt-user=${DB_USER} \
315 --with-db-rt-pass=${DB_PASSWORD} \
316 --with-web-user=freeside \
317 --with-web-group=freeside \
318 --with-rt-group=freeside
320 create-rt: configure-rt
321 [ -d /opt ] || mkdir /opt #doh
322 [ -d /opt/rt3 ] || mkdir /opt/rt3 #
323 [ -d /opt/rt3/share ] || mkdir /opt/rt3/share #
325 rt/sbin/rt-setup-database --dba '${DB_USER}' \
326 -dba-password '${DB_PASSWORD}' \
329 rt/sbin/rt-setup-database --action insert_initial \
330 && rt/sbin/rt-setup-database --action insert --datafile ${RT_PATH}/etc/initialdata \
333 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
334 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
335 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
336 " ${RT_PATH}/etc/RT_SiteConfig.pm
339 [ ${RT_ENABLED} -eq 1 ] && ( cd rt; make install ) || true
343 rm -rf httemplate/docs/man
348 -cd fs_selfservice/FS-SelfService; \
351 #these are probably only useful if you're me...
353 #release: upload-docs
356 # Update the changelog
358 cvs commit -m "Updated for ${VERSION}" ChangeLog
360 # Update the RPM specfile
361 cvs edit ${RPM_SPECFILE}
362 perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${RPM_SPECFILE}
363 cvs commit -m "Updated for ${VERSION}" ${RPM_SPECFILE}
365 # Update the Debian changelog
366 cvs edit debian/changelog
367 dch -v ${DEBVERSION} -p "New upstream release"
368 cvs commit -m "Updated for ${VERSION}" debian/changelog
374 cvs export -r ${TAG} -d freeside-${VERSION} freeside
375 tar czvf freeside-${VERSION}.tar.gz freeside-${VERSION}
377 scp freeside-${VERSION}.tar.gz ivan@420.am:/var/www/www.sisd.com/freeside/
378 mv freeside-${VERSION} freeside-${VERSION}.tar.gz ..
380 #these things failing should not make release target fail, so: "|| true"
382 #kick off vmware update
383 #./BUILD_VMWARE_APPLIANCE ${$TAG} || true
385 #kick off deb package update
387 #kick off rpm package update too?
391 #update web demo self-service?
394 ssh ivan@420.am '( cd freeside; cvs update -d -P )'
395 #ssh root@420.am '( cd /home/ivan/freeside; make clean; make deploy )'
396 ssh root@420.am '( cd /home/ivan/freeside; make deploy )'