To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / deploy / any @ 1610:c6bee0e62957
| 1 | 1593:83412a0a2389 | Chris | #!/bin/bash |
|---|---|---|---|
| 2 | |||
| 3 | # To be sourced into a container-specific start.sh file, not run |
||
| 4 | # standalone |
||
| 5 | |||
| 6 | usage() {
|
||
| 7 | echo "Usage: $0 <database-password> <api-key> <api-httpauth-password>" 1>&2 |
||
| 8 | exit 2 |
||
| 9 | } |
||
| 10 | |||
| 11 | dbpass="$1" |
||
| 12 | if [ -z "$dbpass" ]; then |
||
| 13 | usage |
||
| 14 | fi |
||
| 15 | |||
| 16 | apikey="$2" |
||
| 17 | if [ -z "$apikey" ]; then |
||
| 18 | usage |
||
| 19 | fi |
||
| 20 | |||
| 21 | apipass="$3" |
||
| 22 | if [ -z "$apipass" ]; then |
||
| 23 | usage |
||
| 24 | fi |
||
| 25 | |||
| 26 | set -eu -o pipefail |
||
| 27 | |||
| 28 | rootdir="$mydir/../.." |
||
| 29 | |||
| 30 | deploydir="$rootdir"/deploy |
||
| 31 | if [ ! -d "$deploydir" ]; then |
||
| 32 | echo "ERROR: Unexpected repository layout - expected directory at $deploydir" |
||
| 33 | exit 2 |
||
| 34 | fi |
||
| 35 | |||
| 36 | managerdir="$deploydir/vagrant" |
||
| 37 | if [ ! -d "$managerdir" ]; then |
||
| 38 | echo "ERROR: Required directory $managerdir not found" |
||
| 39 | exit 2 |
||
| 40 | fi |
||
| 41 | |||
| 42 | configdir="$deploydir/config" |
||
| 43 | if [ ! -d "$configdir" ]; then |
||
| 44 | echo "ERROR: Required directory $configdir not found" |
||
| 45 | exit 2 |
||
| 46 | fi |
||
| 47 | |||
| 48 | if [ ! -f "$rootdir/postgres-dumpall" ]; then |
||
| 49 | 1605:18643ab36008 | Chris | echo "ERROR: I expect to find a Postgres SQL multi-db dump file in $rootdir/postgres-dumpall. Create an empty file there if you don't want to load a database." |
| 50 | 1593:83412a0a2389 | Chris | exit 2 |
| 51 | fi |
||
| 52 | |||
| 53 | fontdir="$rootdir"/public/themes/soundsoftware/stylesheets/fonts |
||
| 54 | if [ ! -f "$fontdir/24BC0E_0_0.woff" ]; then |
||
| 55 | echo "ERROR: I expect to find necessary webfonts in $fontdir" |
||
| 56 | exit 2 |
||
| 57 | fi |
||
| 58 | |||
| 59 | 1610:c6bee0e62957 | Chris | #apischeme=http |
| 60 | #apihost=localhost |
||
| 61 | 1593:83412a0a2389 | Chris | |
| 62 | 1610:c6bee0e62957 | Chris | apischeme=https |
| 63 | apihost=code.soundsoftware.ac.uk |
||
| 64 | 1593:83412a0a2389 | Chris | |
| 65 | for f in "$configdir"/*.in "$rootdir"/extra/soundsoftware/extract-docs.sh ; do |
||
| 66 | out="$configdir"/$(basename "$f" .in).gen |
||
| 67 | cat "$f" | sed \ |
||
| 68 | -e 's/INSERT_DATABASE_PASSWORD_HERE/'"$dbpass"'/g' \ |
||
| 69 | -e 's/INSERT_API_KEY_HERE/'"$apikey"'/g' \ |
||
| 70 | -e 's/INSERT_API_SCHEME_HERE/'"$apischeme"'/g' \ |
||
| 71 | -e 's/INSERT_API_HOST_HERE/'"$apihost"'/g' \ |
||
| 72 | -e 's/INSERT_API_USER_HERE/user/g' \ |
||
| 73 | -e 's/INSERT_API_PASSWORD_HERE/'"$apipass"'/g' \ |
||
| 74 | > "$out" |
||
| 75 | done |
||
| 76 | 1607:1c904260787b | Chris | #!/bin/bash |
| 77 | |||
| 78 | set -e |
||
| 79 | |||
| 80 | cd /var/www/code |
||
| 81 | |||
| 82 | for t in minutely hourly daily monthly; do |
||
| 83 | for s in deploy/config/cron.$t/[0-9]* ; do |
||
| 84 | name=$(basename $s) |
||
| 85 | actual="/etc/cron.$t/$name" |
||
| 86 | echo "Running cron script $actual..." |
||
| 87 | "$actual" |
||
| 88 | done |
||
| 89 | done |
||
| 90 | 1601:07deb8466f65 | Chris | #!/bin/bash |
| 91 | |||
| 92 | mydir=$(dirname "$0") |
||
| 93 | 1603:455ca6e45c49 | Chris | case "$mydir" in |
| 94 | /*) ;; |
||
| 95 | *) mydir=$(echo "$(pwd)/$mydir" | sed 's,/\./,/,g') |
||
| 96 | esac |
||
| 97 | 1601:07deb8466f65 | Chris | |
| 98 | if [ "$mydir" != "/code-to-deploy/deploy/any" ]; then |
||
| 99 | echo "ERROR: Expected repository to be at /code-to-deploy prior to provisioning" |
||
| 100 | 1603:455ca6e45c49 | Chris | echo " (My directory is $mydir, expected /code-to-deploy/deploy/any)" |
| 101 | 1601:07deb8466f65 | Chris | exit 2 |
| 102 | fi |
||
| 103 | |||
| 104 | 1604:2162f6ff8580 | Chris | set -e |
| 105 | |||
| 106 | . "$mydir"/prepare.sh |
||
| 107 | 1601:07deb8466f65 | Chris | |
| 108 | for f in "$mydir"/../provision.d/[0-9]*.sh ; do |
||
| 109 | case "$f" in |
||
| 110 | *~) ;; |
||
| 111 | *) echo "Running provisioning script: $f" |
||
| 112 | 1605:18643ab36008 | Chris | /bin/bash "$f" </dev/null ;; # close stdin to avoid interactivity |
| 113 | 1601:07deb8466f65 | Chris | esac |
| 114 | done |
||
| 115 | |||
| 116 | echo "All provisioning scripts complete" |