Commit | Line | Data |
---|---|---|
cc5b00a4 JP |
1 | #!/usr/bin/env bash |
2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
3 | YML=$DIR/../containers/app.yml | |
4 | if [ -f $YML ] | |
5 | then | |
6 | echo "cannot run test if $YML exists." | |
7 | exit | |
8 | fi | |
9 | ||
10 | check_value () { | |
11 | VAR=$1 | |
12 | VAL=$2 | |
13 | YML=$3 | |
14 | if ! [[ $(grep $VAR $YML |sed -e "s/ $VAR: //") == "$VAL" ]] | |
15 | then | |
16 | echo $VAR is NOT $VAL | |
17 | echo TEST FAILED. Aborting. | |
18 | exit 1 | |
19 | fi | |
20 | } | |
21 | ||
22 | hostname='test.myhost.com' | |
23 | developer='admin@mail.myhost.com' | |
24 | smtp_address='smtp.myhostn.com' | |
25 | smtp_port='' | |
26 | smtp_user='smtpuser' | |
27 | smtp_pass='smtp-pw' | |
28 | notification='' | |
29 | letsencrypt='le@myhost.com' | |
30 | maxmind='' | |
31 | $DIR/../discourse-setup --skip-connection-test --skip-rebuild <<EOF | |
32 | $hostname | |
33 | $developer | |
34 | $smtp_address | |
35 | $smtp_port | |
36 | $smtp_user | |
37 | $smtp_pass | |
38 | $notification | |
39 | $letsencrypt | |
40 | $maxmind | |
41 | ||
42 | ||
43 | EOF | |
44 | check_value DISCOURSE_HOSTNAME $hostname $YML | |
45 | check_value DISCOURSE_SMTP_ADDRESS $smtp_address $YML | |
46 | check_value DISCOURSE_SMTP_PORT 587 $YML | |
47 | check_value DISCOURSE_SMTP_USER_NAME $smtp_user $YML | |
48 | check_value DISCOURSE_SMTP_PASSWORD \"$smtp_pass\" $YML | |
49 | check_value DISCOURSE_SMTP_DOMAIN $hostname $YML | |
50 | check_value DISCOURSE_NOTIFICATION_EMAIL noreply@$hostname $YML | |
51 | echo "################################ Initial install succeeded. ###################################" | |
52 | echo "Now running edit test." | |
53 | hostname='new.myhost.com' | |
54 | developer='new@mail.myhost.com' | |
55 | smtp_address='new.myhostn.com' | |
56 | smtp_port='2525' | |
57 | smtp_user='newuser' | |
58 | smtp_pass='new-smtp-pw' | |
59 | notification='somuser@otherhost.com' | |
60 | smtp_domain=otherhost.com # NOTE: script uses notification hostnme | |
61 | letsencrypt='le-new@myhost.com' | |
62 | maxmind='maxthisone' | |
63 | $DIR/../discourse-setup --skip-connection-test --skip-rebuild <<EOF | |
64 | $hostname | |
65 | $developer | |
66 | $smtp_address | |
67 | $smtp_port | |
68 | $smtp_user | |
69 | $smtp_pass | |
70 | $notification | |
71 | $letsencrypt | |
72 | $maxmind | |
73 | ||
74 | ||
75 | EOF | |
76 | check_value DISCOURSE_HOSTNAME $hostname $YML | |
77 | check_value DISCOURSE_SMTP_ADDRESS $smtp_address $YML | |
78 | check_value DISCOURSE_SMTP_PORT $smtp_port $YML | |
79 | check_value DISCOURSE_SMTP_USER_NAME $smtp_user $YML | |
80 | check_value DISCOURSE_SMTP_PASSWORD \"$smtp_pass\" $YML | |
81 | check_value DISCOURSE_SMTP_DOMAIN $smtp_domain $YML | |
82 | check_value DISCOURSE_NOTIFICATION_EMAIL $notification $YML | |
83 | echo "################################ Update of values succeeded. ###################################" | |
84 | echo "Removing $YML*" | |
85 | rm $YML* | |
86 | ||
87 | echo "Test succeeded. Removing $YML" | |
88 | rm $YML |