| 1 |
#!/bin/sh |
|---|
| 2 |
# your root directory $root appears not to exist." $Id$ |
|---|
| 3 |
# |
|---|
| 4 |
# TODO: add error checking for users typing the wrong name |
|---|
| 5 |
|
|---|
| 6 |
s=$1 |
|---|
| 7 |
if [ -z "$s" ]; |
|---|
| 8 |
then |
|---|
| 9 |
echo "usage: configure.sh server-name" |
|---|
| 10 |
exit 1 |
|---|
| 11 |
fi |
|---|
| 12 |
|
|---|
| 13 |
# FIXME: remove this and move into setup |
|---|
| 14 |
xsl="_config/parse-config.xsl" |
|---|
| 15 |
xml="_config/servers.xml" |
|---|
| 16 |
sp="stringparam" |
|---|
| 17 |
|
|---|
| 18 |
if [ ! -d "_config" ]; |
|---|
| 19 |
then |
|---|
| 20 |
echo "Please run configure.sh from within your feedmelinks svn checkout directory." |
|---|
| 21 |
exit 1 |
|---|
| 22 |
fi |
|---|
| 23 |
|
|---|
| 24 |
if [ ! -f "$xml" ]; |
|---|
| 25 |
then |
|---|
| 26 |
echo "First, copy servers-template.xml to servers.xml (in the _config) folder, and fill in the values for your database and server paths" |
|---|
| 27 |
exit 1 |
|---|
| 28 |
fi |
|---|
| 29 |
|
|---|
| 30 |
root=`xsltproc --$sp server-name $s --$sp mode atom --$sp atom webserver-root $xsl $xml` |
|---|
| 31 |
|
|---|
| 32 |
if [ ! -d $root ]; |
|---|
| 33 |
then |
|---|
| 34 |
echo "Error: Your root directory $root appears not to exist." |
|---|
| 35 |
echo "Check the folder permissions and your $xml" |
|---|
| 36 |
exit 1 |
|---|
| 37 |
fi |
|---|
| 38 |
|
|---|
| 39 |
domain=`xsltproc --$sp server-name $s --$sp mode domain $xsl $xml` |
|---|
| 40 |
|
|---|
| 41 |
if [ "$domain" = "FML_NO_SUCH_SERVER" ]; |
|---|
| 42 |
then |
|---|
| 43 |
echo "Error: You have tried to configure a server that is not defined in $xml." |
|---|
| 44 |
echo "Please double-check your config file and try again." |
|---|
| 45 |
exit 1 |
|---|
| 46 |
fi |
|---|
| 47 |
|
|---|
| 48 |
echo 1. Writing the custom apache and php configs for your server \"$s\" |
|---|
| 49 |
xsltproc --$sp server-name $s --$sp mode htaccess $xsl $xml > $root/.htaccess |
|---|
| 50 |
|
|---|
| 51 |
echo 2. Adding the standard Feed Me Links server configs |
|---|
| 52 |
cat $root/.htaccess-global >> $root/.htaccess |
|---|
| 53 |
|
|---|
| 54 |
echo $domain > $root/_config/domain.txt |
|---|
| 55 |
|
|---|
| 56 |
echo "3. Saving your configurations in env.inc.php (for the main application to read)" |
|---|
| 57 |
xsltproc --$sp server-name $s --$sp mode php $xsl $xml > $root/modules/env.inc.php |
|---|
| 58 |
|
|---|
| 59 |
echo "4. ...and in shell-script format (for maintenance scripts to read)..." |
|---|
| 60 |
xsltproc --$sp server-name $s --$sp mode sh $xsl $xml > $root/bin/env.sh |
|---|
| 61 |
|
|---|
| 62 |
echo "5. ...and as a perl module (for things like the AIM bot and the add-link from email script)..." |
|---|
| 63 |
cp $root/lib/FeedMeLinks/Environment-template.pm $root/lib/FeedMeLinks/Environment.pm |
|---|
| 64 |
xsltproc --$sp server-name $s --$sp mode perl $xsl $xml >> $root/lib/FeedMeLinks/Environment.pm |
|---|
| 65 |
|
|---|
| 66 |
echo "6. ...and as a crontab so that all the background processes will run at the correct times with the correct permissions" |
|---|
| 67 |
crontab="$root/_config/crontab.INSTALL_ME" |
|---|
| 68 |
xsltproc --$sp server-name $s --$sp mode crontab $xsl $xml > $crontab |
|---|
| 69 |
echo >> $crontab |
|---|
| 70 |
echo "# to edit, change $root/_config/crontab-template.txt" >> $crontab |
|---|
| 71 |
cat $root/_config/crontab-template.txt >> $crontab |
|---|
| 72 |
|
|---|
| 73 |
echo "don't forget to install your new crontab in $crontab (copy, crontab -e, paste, save, done!)" |
|---|
| 74 |
|
|---|
| 75 |
exit 0 |
|---|
| 76 |
|
|---|