Skip to content

Commit 17ecef6

Browse files
committed
HOTFIX: ops: add support for MW API EMAIL USER/PW
Bug: T409420
1 parent 3952f92 commit 17ecef6

6 files changed

Lines changed: 54 additions & 15 deletions

bin/debian_swarm_deploy.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,29 @@ usermod -a -G docker twlight
3838
rm -rf /srv/TWLight
3939
# Pull TWLight code and make twlight user the owner
4040
git clone https://github.com/WikipediaLibrary/TWLight.git /srv/TWLight
41-
cd /srv/TWLight
41+
cd /srv/TWLight || exit
4242
# Get on correct branch
4343
echo "Enter git branch:"
4444
read TWLIGHT_GIT_BRANCH
4545
git checkout "${TWLIGHT_GIT_BRANCH}" && git pull
4646

4747
# Get input from human
4848
echo "Enter DJANGO_DB_NAME:"
49-
read DJANGO_DB_NAME
49+
read -r DJANGO_DB_NAME
5050
echo "Enter DJANGO_DB_USER:"
51-
read DJANGO_DB_USER
51+
read -r DJANGO_DB_USER
5252
echo "Enter TWLIGHT_OAUTH_CONSUMER_KEY:"
53-
read TWLIGHT_OAUTH_CONSUMER_KEY
53+
read -r TWLIGHT_OAUTH_CONSUMER_KEY
5454
echo "Enter TWLIGHT_OAUTH_CONSUMER_SECRET:"
55-
read TWLIGHT_OAUTH_CONSUMER_SECRET
55+
read -r TWLIGHT_OAUTH_CONSUMER_SECRET
5656
echo "Enter TWLIGHT_EZPROXY_SECRET:"
57-
read TWLIGHT_EZPROXY_SECRET
57+
read -r TWLIGHT_EZPROXY_SECRET
58+
echo "Enter MW_API_EMAIL_USER"
59+
read -r MW_API_EMAIL_USER
60+
echo "Enter MW_API_EMAIL_PASSWORD"
61+
read -r MW_API_EMAIL_PASSWORD
5862
echo "Enter stack environment (eg. override | staging | production):"
59-
read TWLIGHT_STACK_ENV
63+
read -r TWLIGHT_STACK_ENV
6064

6165
# Setup DKIM
6266
ssh-keygen -t rsa -b 1024 -m PEM -P "" -f dkim
@@ -92,6 +96,8 @@ printf "${SECRET_KEY}" | docker secret create SECRET_KEY -
9296
printf "${TWLIGHT_OAUTH_CONSUMER_KEY}" | docker secret create TWLIGHT_OAUTH_CONSUMER_KEY -
9397
printf "${TWLIGHT_OAUTH_CONSUMER_SECRET}" | docker secret create TWLIGHT_OAUTH_CONSUMER_SECRET -
9498
printf "${TWLIGHT_EZPROXY_SECRET}" | docker secret create TWLIGHT_EZPROXY_SECRET -
99+
printf "${MW_API_EMAIL_USER}" | docker secret create MW_API_EMAIL_USER -
100+
printf "${MW_API_EMAIL_PASSWORD}" | docker secret create MW_API_EMAIL_PASSWORD -
95101
echo "Deploying stack"
96102
docker stack deploy -c "docker-compose.yml" -c "docker-compose.${TWLIGHT_STACK_ENV}.yml" "${TWLIGHT_STACK_ENV}"
97103
echo "Setting up crontab. *WARNING* This will create duplicate jobs if run repeatedly."

bin/twlight_docker_secrets.sh

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,59 @@
22

33
if [ ! -n "${DJANGO_DB_NAME+isset}" ]
44
then
5-
export DJANGO_DB_NAME=$(cat /run/secrets/DJANGO_DB_NAME 2>/dev/null)
5+
DJANGO_DB_NAME=$(cat /run/secrets/DJANGO_DB_NAME 2>/dev/null)
6+
export DJANGO_DB_NAME
67
fi
78

89
if [ ! -n "${DJANGO_DB_USER+isset}" ]
910
then
10-
export DJANGO_DB_USER=$(cat /run/secrets/DJANGO_DB_USER 2>/dev/null)
11+
DJANGO_DB_USER=$(cat /run/secrets/DJANGO_DB_USER 2>/dev/null)
12+
export DJANGO_DB_USER
1113
fi
1214

1315
if [ ! -n "${DJANGO_DB_PASSWORD+isset}" ]
1416
then
15-
export DJANGO_DB_PASSWORD=$(cat /run/secrets/DJANGO_DB_PASSWORD 2>/dev/null)
17+
DJANGO_DB_PASSWORD=$(cat /run/secrets/DJANGO_DB_PASSWORD 2>/dev/null)
18+
export DJANGO_DB_PASSWORD
1619
fi
1720

1821
if [ ! -n "${DKIM_PRIVATE_KEY+isset}" ]
1922
then
20-
export DKIM_PRIVATE_KEY=$(cat /run/secrets/DKIM_PRIVATE_KEY 2>/dev/null)
23+
DKIM_PRIVATE_KEY=$(cat /run/secrets/DKIM_PRIVATE_KEY 2>/dev/null)
24+
export DKIM_PRIVATE_KEY
2125
fi
2226

2327
if [ ! -n "${SECRET_KEY+isset}" ]
2428
then
25-
export SECRET_KEY=$(cat /run/secrets/SECRET_KEY 2>/dev/null)
29+
SECRET_KEY=$(cat /run/secrets/SECRET_KEY 2>/dev/null)
30+
export SECRET_KEY
2631
fi
2732

2833
if [ ! -n "${TWLIGHT_OAUTH_CONSUMER_KEY+isset}" ]
2934
then
30-
export TWLIGHT_OAUTH_CONSUMER_KEY=$(cat /run/secrets/TWLIGHT_OAUTH_CONSUMER_KEY 2>/dev/null)
35+
TWLIGHT_OAUTH_CONSUMER_KEY=$(cat /run/secrets/TWLIGHT_OAUTH_CONSUMER_KEY 2>/dev/null)
36+
export TWLIGHT_OAUTH_CONSUMER_KEY
3137
fi
3238

3339
if [ ! -n "${TWLIGHT_OAUTH_CONSUMER_SECRET+isset}" ]
3440
then
35-
export TWLIGHT_OAUTH_CONSUMER_SECRET=$(cat /run/secrets/TWLIGHT_OAUTH_CONSUMER_SECRET 2>/dev/null)
41+
TWLIGHT_OAUTH_CONSUMER_SECRET=$(cat /run/secrets/TWLIGHT_OAUTH_CONSUMER_SECRET 2>/dev/null)
42+
export TWLIGHT_OAUTH_CONSUMER_SECRET
3643
fi
3744

3845
if [ ! -n "${TWLIGHT_EZPROXY_SECRET+isset}" ]
3946
then
40-
export TWLIGHT_EZPROXY_SECRET=$(cat /run/secrets/TWLIGHT_EZPROXY_SECRET 2>/dev/null)
47+
TWLIGHT_EZPROXY_SECRET=$(cat /run/secrets/TWLIGHT_EZPROXY_SECRET 2>/dev/null)
48+
export TWLIGHT_EZPROXY_SECRET
49+
fi
50+
51+
if [ ! -n "${MW_API_EMAIL_USER+isset}" ]
52+
then
53+
MW_API_EMAIL_USER=$(cat /run/secrets/MW_API_EMAIL_USER 2>/dev/null)
54+
export MW_API_EMAIL_USER
55+
fi
56+
if [ ! -n "${MW_API_EMAIL_PASSWORD+isset}" ]
57+
then
58+
MW_API_EMAIL_PASSWORD=$(cat /run/secrets/MW_API_EMAIL_PASSWORD 2>/dev/null)
59+
export MW_API_EMAIL_PASSWORD
4160
fi

docker-compose.override.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ secrets:
2222
file: ./secrets/TWLIGHT_OAUTH_CONSUMER_SECRET
2323
TWLIGHT_EZPROXY_SECRET:
2424
file: ./secrets/TWLIGHT_EZPROXY_SECRET
25+
MW_API_EMAIL_USER:
26+
file: ./secrets/MW_API_EMAIL_USER
27+
MW_API_EMAIL_PASSWORD:
28+
file: ./secrets/MW_API_EMAIL_PASSWORD
2529

2630
services:
2731
twlight:

docker-compose.production.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ secrets:
2121
external: true
2222
TWLIGHT_EZPROXY_SECRET:
2323
external: true
24+
MW_API_EMAIL_USER:
25+
external: true
26+
MW_API_EMAIL_PASSWORD:
27+
external: true
2428

2529
services:
2630
migrate:

docker-compose.staging.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ secrets:
2121
external: true
2222
TWLIGHT_EZPROXY_SECRET:
2323
external: true
24+
MW_API_EMAIL_USER:
25+
external: true
26+
MW_API_EMAIL_PASSWORD:
27+
external: true
2428

2529
services:
2630
migrate:

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ services:
5151
- TWLIGHT_OAUTH_CONSUMER_KEY
5252
- TWLIGHT_OAUTH_CONSUMER_SECRET
5353
- TWLIGHT_EZPROXY_SECRET
54+
- MW_API_EMAIL_USER
55+
- MW_API_EMAIL_PASSWORD
5456
web:
5557
ports:
5658
- "80:80"

0 commit comments

Comments
 (0)