So I'm working on a project that sometimes requires me to switch my server configuration. This is due to some circumstances with database drivers and names that are "too expensive to fix" ...
That made me think though: "Why do I always copy these files around manually?"
I decided I won't and wrote this small script to help me:
#!/bin/bash
if [ $# != 1 ]
then
echo "you must provide a configuration to switch to"
exit
fi;
if [ -a $TOMCAT_HOME/conf/server_$1.xml ]
then
rm $TOMCAT_HOME/conf/server.xml
cp $TOMCAT_HOME/conf/server_$1.xml $TOMCAT_HOME/conf/server.xml
else
echo "given configuration was not found. did not make any changes."
fi;
exit 0
Usage is dead simple: I made this available system-wide and can just call:
switch-config postgres
or
switch-config firebird
To make changes happen.
This is built for my personal convenience, so please ignore the incredibly bad error messages, also the (nonexistent) directory structure is for simple convenience. Comments like "move the different configurations somewhere else" don't help me.
In any case, what can I improve?