domain=$1
+FREESIDE_CONF=%%%FREESIDE_CONF%%%
+FREESIDE_CACHE=%%%FREESIDE_CACHE%%%
+FREESIDE_EXPORT=%%%FREESIDE_EXPORT%%%
+
+#without this, [a-z]* matches CVS/, the copy doesn't return a sucessful error
+# status, and the rest of the commands aren't run
+export LANG=C
+
createdb $domain && \
\
-mkdir /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain && \
+mkdir $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain && \
\
-chown freeside /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain && \
+chown freeside $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain && \
\
-cp /home/ivan/freeside/conf/[a-z]* /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain
-
-
-touch /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain/secrets && \
+cp /home/ivan/freeside/conf/[a-z]* $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain && \
+\
+touch $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
\
-chown freeside /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain/secrets && \
+chown freeside $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
\
-chmod 600 /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain/secrets && \
+chmod 600 $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
\
-echo -e "DBI:Pg:dbname=$domain\nfreeside\n" >/usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain/secrets && \
+echo -e "DBI:Pg:dbname=$domain\nfreeside\n" >$FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
\
-mkdir /usr/local/etc/freeside/counters.DBI:Pg:dbname=$domain && \
-mkdir /usr/local/etc/freeside/cache.DBI:Pg:dbname=$domain && \
-mkdir /usr/local/etc/freeside/export.DBI:Pg:dbname=$domain
+mkdir $FREESIDE_CACHE/counters.DBI:Pg:dbname=$domain && \
+mkdir $FREESIDE_CACHE/cache.DBI:Pg:dbname=$domain && \
+mkdir $FREESIDE_EXPORT/export.DBI:Pg:dbname=$domain