aboutsummaryrefslogtreecommitdiffstats
path: root/bin/switch-site
diff options
context:
space:
mode:
authorZarino Zappia <mail@zarino.co.uk>2017-06-30 10:51:57 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-08-10 12:51:15 +0100
commit97fb9772bc96e82f2edb8a9191dd359b07a04fa7 (patch)
treec10acb19c6476a24d2832143b3fd0dd9e6f3d088 /bin/switch-site
parenteda7a2d88e13a89e22843203cf4f749c8679b4d7 (diff)
Add switch-site script for easily switching config
Given a set of config files of the format `conf/general-{cobrand}.yml` this script lets you easily create and recreate a symlink at `conf/general.yml` that points to the cobrand config of your choice. The test suite also then uses this naming convention.
Diffstat (limited to 'bin/switch-site')
-rwxr-xr-xbin/switch-site35
1 files changed, 35 insertions, 0 deletions
diff --git a/bin/switch-site b/bin/switch-site
new file mode 100755
index 000000000..c4ca53ca9
--- /dev/null
+++ b/bin/switch-site
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Symlinks a file like conf/general-foobar.yml to conf/general.yml,
+# to make switching between cobrands simpler while debugging.
+
+# Takes a single argument which should be a site name from one of
+# your config files, like "oxfordshire" from conf/general-oxforshire.yml
+
+# Run from the fixmystreet directory, like so:
+# $ bin/switch-site oxfordshire
+
+if [ -z "$1" ]
+then
+ current_target=$(readlink conf/general.yml)
+ if [ -z $current_target ]
+ then
+ echo 'Supply a config name, from the following list:'
+ else
+ echo 'Currently using settings from:'
+ echo " $current_target"
+ echo 'To change, supply a config name from the following list:'
+ fi
+ ls conf/general-*.yml | sed 's/.*general-\(.*\)\.yml/ \1/'
+ exit 1
+fi
+
+if [ -e "conf/general-$1.yml" ]
+then
+ # -f flag replaces the target file if it already exists.
+ # Remember that 1st argument is a file path relative to
+ # the file specified in the second argument.
+ ln -sf general-$1.yml conf/general.yml
+else
+ echo "File conf/general-$1.yml does not exist."
+fi