discourse_docker/tests/update-old-templates

95 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
YML=$DIR/../containers/app.yml
if [ -f $YML ]
then
echo "cannot run test if $YML exists."
exit
fi
check_value () {
VAR=$1
VAL=$2
YML=$3
if ! [[ $(grep $VAR $YML |sed -e "s/ $VAR: //") == "$VAL" ]]
then
echo $VAR is NOT $VAL
echo TEST FAILED. Aborting.
exit 1
fi
}
# get old (Sep 6, 2016) standalone.yml that's missing MAXMIND and other values
git show 7cf781fc0cf2542040f35e40cf79a1ab079c59f0:samples/standalone.yml>containers/app.yml > $YML
hostname='new.myhost.com'
developer='new@mail.myhost.com'
smtp_address='new.myhostn.com'
smtp_port='2525'
smtp_user='newuser'
smtp_pass='new-smtp-pw'
notification='somuser@otherhost.com'
smtp_domain=otherhost.com # NOTE: script uses notification hostnme
letsencrypt='le-new@myhost.com'
maxmind='maxthisone'
$DIR/../discourse-setup --skip-connection-test --skip-rebuild <<EOF
$hostname
$developer
$smtp_address
$smtp_port
$smtp_user
$smtp_pass
$notification
$letsencrypt
$maxmind
EOF
check_value DISCOURSE_HOSTNAME $hostname $YML
check_value DISCOURSE_SMTP_ADDRESS $smtp_address $YML
check_value DISCOURSE_SMTP_PORT $smtp_port $YML
check_value DISCOURSE_SMTP_USER_NAME $smtp_user $YML
check_value DISCOURSE_SMTP_PASSWORD \"$smtp_pass\" $YML
check_value DISCOURSE_SMTP_DOMAIN $smtp_domain $YML
check_value DISCOURSE_NOTIFICATION_EMAIL $notification $YML
check_value DISCOURSE_MAXMIND_LICENSE_KEY $maxmind $YML
echo "Update values Test succeeded. Removing $YML"
rm $YML*
# get old (Apr 13, 2018) web_only.yml that's missing MAXMIND and other values
YML=$DIR/../containers/web_only.yml
git show 04a06dd05ee5aaec8082c503c8b8429e51f239e0:samples/web_only.yml> $YML
hostname='new.myhost.com'
developer='new-admin@mail.myhost.com'
smtp_address='new.myhostn.com'
smtp_port='2525'
smtp_user='newuser'
smtp_pass='new-smtp-pw'
notification='somuser@otherhost.com'
smtp_domain=otherhost.com # NOTE: script uses notification hostnme
letsencrypt='le-new@myhost.com'
maxmind='maxthisone'
$DIR/../discourse-setup --skip-connection-test --skip-rebuild <<EOF
$hostname
$developer
$smtp_address
$smtp_port
$smtp_user
$smtp_pass
$notification
$letsencrypt
$maxmind
EOF
check_value DISCOURSE_HOSTNAME $hostname $YML
check_value DISCOURSE_SMTP_ADDRESS $smtp_address $YML
check_value DISCOURSE_SMTP_PORT $smtp_port $YML
check_value DISCOURSE_SMTP_USER_NAME $smtp_user $YML
check_value DISCOURSE_SMTP_PASSWORD \"$smtp_pass\" $YML
check_value DISCOURSE_SMTP_DOMAIN $smtp_domain $YML
check_value DISCOURSE_NOTIFICATION_EMAIL $notification $YML
check_value DISCOURSE_MAXMIND_LICENSE_KEY $maxmind $YML
echo "Update values Test succeeded. Removing $YML"
rm $YML*