Skip to content

Commit 7be6c71

Browse files
AndrewFerrsandhose
andauthored
start_for_complement.sh: use more shell builtins (#18293)
Avoid calling external tools when shell builtins suffice. ### Pull Request Checklist <!-- Please read https://element-hq.github.io/synapse/latest/development/contributing_guide.html before submitting your pull request --> * [x] Pull request is based on the develop branch * [x] Pull request includes a [changelog file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should: - Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.". - Use markdown where necessary, mostly for `code blocks`. - End with either a period (.) or an exclamation mark (!). - Start with a capital letter. - Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry. * [x] [Code style](https://element-hq.github.io/synapse/latest/code_style.html) is correct (run the [linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters)) --------- Co-authored-by: Quentin Gliech <[email protected]>
1 parent 5ab05e7 commit 7be6c71

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

changelog.d/18293.docker

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In start_for_complement.sh, replace some external program calls with shell builtins.

docker/complement/conf/start_for_complement.sh

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ echo " Args: $*"
99
echo " Env: SYNAPSE_COMPLEMENT_DATABASE=$SYNAPSE_COMPLEMENT_DATABASE SYNAPSE_COMPLEMENT_USE_WORKERS=$SYNAPSE_COMPLEMENT_USE_WORKERS SYNAPSE_COMPLEMENT_USE_ASYNCIO_REACTOR=$SYNAPSE_COMPLEMENT_USE_ASYNCIO_REACTOR"
1010

1111
function log {
12-
d=$(date +"%Y-%m-%d %H:%M:%S,%3N")
12+
d=$(printf '%(%Y-%m-%d %H:%M:%S)T,%.3s\n' ${EPOCHREALTIME/./ })
1313
echo "$d $*"
1414
}
1515

@@ -103,12 +103,11 @@ fi
103103
# Note that both the key and certificate are in PEM format (not DER).
104104

105105
# First generate a configuration file to set up a Subject Alternative Name.
106-
cat > /conf/server.tls.conf <<EOF
106+
echo "\
107107
.include /etc/ssl/openssl.cnf
108108
109109
[SAN]
110-
subjectAltName=DNS:${SERVER_NAME}
111-
EOF
110+
subjectAltName=DNS:${SERVER_NAME}" > /conf/server.tls.conf
112111

113112
# Generate an RSA key
114113
openssl genrsa -out /conf/server.tls.key 2048
@@ -123,8 +122,8 @@ openssl x509 -req -in /conf/server.tls.csr \
123122
-out /conf/server.tls.crt -extfile /conf/server.tls.conf -extensions SAN
124123

125124
# Assert that we have a Subject Alternative Name in the certificate.
126-
# (grep will exit with 1 here if there isn't a SAN in the certificate.)
127-
openssl x509 -in /conf/server.tls.crt -noout -text | grep DNS:
125+
# (the test will exit with 1 here if there isn't a SAN in the certificate.)
126+
[[ $(openssl x509 -in /conf/server.tls.crt -noout -text) == *DNS:* ]]
128127

129128
export SYNAPSE_TLS_CERT=/conf/server.tls.crt
130129
export SYNAPSE_TLS_KEY=/conf/server.tls.key

0 commit comments

Comments
 (0)