3 #solaris and perhaps other very weirdass /bin/sh
6 DATASOURCE = DBI:Pg:dbname=freeside
7 #DATASOURCE=DBI:mysql:freeside
14 MASON_HANDLER = /usr/local/etc/freeside/handler.pl
15 MASONDATA = /usr/local/etc/freeside/masondata
18 FREESIDE_DOCUMENT_ROOT = /var/www/freeside
19 #redhat, fedora, mandrake
20 #FREESIDE_DOCUMENT_ROOT = /var/www/html/freeside
22 #FREESIDE_DOCUMENT_ROOT = /usr/local/www/data/freeside
24 #FREESIDE_DOCUMENT_ROOT = /var/www/htdocs/freeside
26 #FREESIDE_DOCUMENT_ROOT = /srv/www/htdocs/freeside
28 #FREESIDE_DOCUMENT_ROOT = /usr/local/apache/htdocs/freeside
30 #deb, redhat, fedora, mandrake, suse, others?
31 INIT_FILE = /etc/init.d/freeside
33 #INIT_FILE = /usr/local/etc/rc.d/011.freeside.sh
36 INIT_INSTALL = /usr/sbin/update-rc.d freeside defaults 21 20
38 #INIT_INSTALL = /sbin/chkconfig freeside on
39 #not necessary (freebsd)
40 #INIT_INSTALL = /usr/bin/true
43 HTTPD_RESTART = /etc/init.d/apache restart
44 #redhat, fedora, mandrake
45 #HTTPD_RESTART = /etc/init.d/httpd restart
47 #HTTPD_RESTART = /usr/local/etc/rc.d/apache.sh stop || true; sleep 10; /usr/local/etc/rc.d/apache.sh start
49 #HTTPD_RESTART = kill -TERM `cat /var/www/logs/httpd.pid`; sleep 10; /usr/sbin/httpd -u -DSSL
51 #HTTPD_RESTART = /usr/local/apache/bin/apachectl stop; sleep 10; /usr/local/apache/bin/apachectl startssl
53 #(an include directory, not a file - "Include /etc/apache/conf.d" in httpd.conf)
55 APACHE_CONF = /etc/apache/conf.d
57 FREESIDE_RESTART = ${INIT_FILE} restart
59 #deb, redhat, fedora, mandrake, suse, others?
64 #edit the stuff below to have the daemons start
68 SELFSERVICE_USER = fs_selfservice
69 #never run on the same machine in production!!!
70 SELFSERVICE_MACHINES = localhost
71 # SELFSERVICE_MACHINES = www.example.com
72 # SELFSERVICE_MACHINES = web1.example.com web2.example.com
74 #user with sudo access on SELFSERVICE_MACHINES for automated self-service
76 SELFSERVICE_INSTALL_USER = ivan
77 SELFSERVICE_INSTALL_USERADD = /usr/sbin/useradd
78 #SELFSERVICE_INSTALL_USERADD = "/usr/sbin/pw useradd"
82 RT_DOMAIN = example.com
83 RT_TIMEZONE = US/Pacific
84 #RT_TIMEZONE = US/Eastern
85 FREESIDE_URL = "http://localhost/freeside/"
87 #for now, same db as specified in DATASOURCE... eventually, otherwise?
88 RT_DB_DATABASE = freeside
93 FREESIDE_CONF = /usr/local/etc/freeside
97 #only used for dev kludge now, not a big deal
99 PERL_INC_DEV_KLUDGE = /usr/local/share/perl/5.8.8/
105 @echo "supported targets:"
106 @echo " create-database create-config"
107 @echo " install deploy"
108 @echo " configure-rt create-rt"
111 @echo " install-docs install-perl-modules"
112 @echo " install-init install-apache"
114 @echo " install-selfservice update-selfservice"
116 @echo " dev dev-docs dev-perl-modules"
118 @echo " masondocs alldocs docs"
119 @echo " htmlman forcehtmlman"
120 @echo " perl-modules"
122 #@echo " upload-docs release update-webdemo"
125 masondocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/*
127 cp -pr httemplate masondocs
136 [ -e ./httemplate/docs/man ] || mkdir httemplate/docs/man
137 [ -e ./httemplate/docs/man/bin ] || mkdir httemplate/docs/man/bin
138 [ -e ./httemplate/docs/man/FS ] || mkdir httemplate/docs/man/FS
139 [ -e ./httemplate/docs/man/FS/UI ] || mkdir httemplate/docs/man/FS/UI
140 [ -e ./httemplate/docs/man/FS/part_export ] || mkdir httemplate/docs/man/FS/part_export
142 [ -e DONT_REBUILD_DOCS ] || bin/pod2x
145 [ -e ./httemplate/docs/man ] || mkdir httemplate/docs/man
146 [ -e ./httemplate/docs/man/bin ] || mkdir httemplate/docs/man/bin
147 [ -e ./httemplate/docs/man/FS ] || mkdir httemplate/docs/man/FS
148 [ -e ./httemplate/docs/man/FS/UI ] || mkdir httemplate/docs/man/FS/UI
149 [ -e ./httemplate/docs/man/FS/part_export ] || mkdir httemplate/docs/man/FS/part_export
153 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
154 cp -r ${TEMPLATE}docs ${FREESIDE_DOCUMENT_ROOT}
155 cp htetc/handler.pl ${MASON_HANDLER}
157 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
158 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
160 [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
161 chown -R freeside ${MASONDATA}
164 [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
165 ln -s ${FREESIDE_PATH}/httemplate ${FREESIDE_DOCUMENT_ROOT}
166 cp htetc/handler.pl ${MASON_HANDLER}
168 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
169 s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
170 s'###use Module::Refresh;###'use Module::Refresh;'; \
171 s'###Module::Refresh->refresh;###'Module::Refresh->refresh;'; \
172 " ${MASON_HANDLER} || true
177 [ -e Makefile ] || perl Makefile.PL; \
180 s/%%%VERSION%%%/${VERSION}/g;\
183 install-perl-modules: perl-modules
184 [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
185 && rm ${PERL_INC_DEV_KLUDGE}/FS \
186 && mv ${PERL_INC_DEV_KLUDGE}/FS.old ${PERL_INC_DEV_KLUDGE}/FS \
189 make install UNINST=1
191 dev-perl-modules: perl-modules
192 [ -d ${PERL_INC_DEV_KLUDGE}/FS -a ! -L ${PERL_INC_DEV_KLUDGE}/FS ] \
193 && mv ${PERL_INC_DEV_KLUDGE}/FS ${PERL_INC_DEV_KLUDGE}/FS.old \
196 rm -rf ${PERL_INC_DEV_KLUDGE}/FS
197 ln -sf ${FREESIDE_PATH}/FS/blib/lib/FS ${PERL_INC_DEV_KLUDGE}/FS
200 #[ -e ${INIT_FILE} ] || install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
201 install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
203 s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
204 s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
205 s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
210 [ -d ${APACHE_CONF} ] && \
211 ( install -o root -m 755 htetc/freeside-base.conf ${APACHE_CONF} && \
212 ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \
214 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
215 " ${APACHE_CONF}/freeside-*.conf \
219 [ -e ~freeside/.ssh/id_dsa.pub ] || su - freeside -c 'ssh-keygen -t dsa'
220 for MACHINE in ${SELFSERVICE_MACHINES}; do \
221 scp -r fs_selfservice/FS-SelfService ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
222 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; perl Makefile.PL && make" ;\
223 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
224 scp ~freeside/.ssh/id_dsa.pub ${SELFSERVICE_INSTALL_USER}@$$MACHINE:. ;\
225 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo ${SELFSERVICE_INSTALL_USERADD} freeside; sudo install -d -o freeside -m 600 ~freeside/.ssh/" ;\
226 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo ${SELFSERVICE_INSTALL_USERADD} freeside; sudo install -o freeside -m 600 ./id_dsa.pub ~freeside/.ssh/authorized_keys" ;\
227 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "sudo install -o freeside -d /usr/local/freeside" ;\
231 for MACHINE in ${SELFSERVICE_MACHINES}; do \
232 RSYNC_RSH=ssh rsync -rlptz fs_selfservice/FS-SelfService/ ${SELFSERVICE_INSTALL_USER}@$$MACHINE:FS-SelfService ;\
233 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; perl Makefile.PL && make" ;\
234 ssh ${SELFSERVICE_INSTALL_USER}@$$MACHINE "cd FS-SelfService; sudo make install" ;\
237 install: install-perl-modules install-docs install-init install-apache install-rt
243 dev: dev-perl-modules dev-docs
246 perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
248 create-config: install-perl-modules
249 [ -e ${FREESIDE_CONF} ] && mv ${FREESIDE_CONF} ${FREESIDE_CONF}.`date +%Y%m%d%H%M%S` || true
250 install -d -o freeside ${FREESIDE_CONF}
252 touch ${FREESIDE_CONF}/secrets
253 chown freeside ${FREESIDE_CONF}/secrets
254 chmod 600 ${FREESIDE_CONF}/secrets
256 echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
257 chmod 600 ${FREESIDE_CONF}/secrets
258 chown freeside ${FREESIDE_CONF}/secrets
260 mkdir "${FREESIDE_CONF}/conf.${DATASOURCE}"
261 rm -rf conf/registries #old dirs just won't go away
262 #cp conf/[a-z]* "${FREESIDE_CONF}/conf.${DATASOURCE}"
263 cp `ls -d conf/[a-z]* | grep -v CVS` "${FREESIDE_CONF}/conf.${DATASOURCE}"
264 chown -R freeside "${FREESIDE_CONF}/conf.${DATASOURCE}"
266 mkdir "${FREESIDE_CONF}/counters.${DATASOURCE}"
267 chown freeside "${FREESIDE_CONF}/counters.${DATASOURCE}"
269 mkdir "${FREESIDE_CONF}/cache.${DATASOURCE}"
270 chown freeside "${FREESIDE_CONF}/cache.${DATASOURCE}"
272 mkdir "${FREESIDE_CONF}/export.${DATASOURCE}"
273 chown freeside "${FREESIDE_CONF}/export.${DATASOURCE}"
277 cp config.layout.in config.layout; \
279 s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
280 s'%%%MASONDATA%%%'${MASONDATA}'g;\
282 ./configure --enable-layout=Freeside\
284 --with-db-dba=${DB_USER} \
285 --with-db-database=${RT_DB_DATABASE} \
286 --with-db-rt-user=${DB_USER} \
287 --with-db-rt-pass=${DB_PASSWORD} \
288 --with-web-user=freeside \
289 --with-web-group=freeside \
290 --with-rt-group=freeside
292 create-rt: configure-rt
293 [ -d /opt ] || mkdir /opt #doh
294 [ -d /opt/rt3 ] || mkdir /opt/rt3 #
295 [ -d /opt/rt3/share ] || mkdir /opt/rt3/share #
297 echo -e "${DB_PASSWORD}\n\\d sessions"\
298 | psql -U ${DB_USER} -W ${RT_DB_DATABASE} 2>&1\
299 | grep '^Did not find'\
300 && rt/sbin/rt-setup-database --dba '${DB_USER}' \
301 --dba-password '${DB_PASSWORD}' \
304 rt/sbin/rt-setup-database --action insert_initial \
305 && rt/sbin/rt-setup-database --action insert --datafile ${RT_PATH}/etc/initialdata \
308 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
309 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
310 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
311 " ${RT_PATH}/etc/RT_SiteConfig.pm
314 [ ${RT_ENABLED} -eq 1 ] && ( cd rt; make install ) || true
318 rm -rf httemplate/docs/man
323 -cd fs_selfservice/FS-SelfService; \
326 #these are probably only useful if you're me...
328 upload-docs: forcehtmlman
329 ssh 420.am rm -rf /var/www/www.sisd.com/freeside/docs
330 scp -pr httemplate/docs 420.am:/var/www/www.sisd.com/freeside/docs
332 #release: upload-docs
334 cd /home/ivan/freeside
339 cvs export -r ${TAG} -d freeside-${VERSION} freeside
340 tar czvf freeside-${VERSION}.tar.gz freeside-${VERSION}
342 scp freeside-${VERSION}.tar.gz ivan@420.am:/var/www/www.sisd.com/freeside/
343 mv freeside-${VERSION} freeside-${VERSION}.tar.gz ..
346 ssh ivan@420.am '( cd freeside; cvs update -d -P )'
347 #ssh root@420.am '( cd /home/ivan/freeside; make clean; make deploy )'
348 ssh root@420.am '( cd /home/ivan/freeside; make deploy )'