From 7ece61f7620e0c8d5a1176e4d7a99e1801f7ce4d Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 26 Sep 2019 23:50:16 +0200 Subject: [PATCH] If a secret.key file is present, import it even in start() --- Dockerfile | 2 +- entrypoint.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dee509c..f2022f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,7 @@ ENV RUSTFLAGS "-C link-arg=-s" RUN apt-get update && apt-get install -qy --no-install-recommends $BUILD_DEPS && \ curl -sSf https://sh.rustup.rs | bash -s -- -y --default-toolchain nightly && \ export PATH="$HOME/.cargo/bin:$PATH" && \ - echo "Compiling encrypted-dns version 0.2.5" && \ + echo "Compiling encrypted-dns version 0.2.6" && \ cargo install encrypted-dns && \ mkdir -p /opt/encrypted-dns/sbin && \ mv ~/.cargo/bin/encrypted-dns /opt/encrypted-dns/sbin/ && \ diff --git a/entrypoint.sh b/entrypoint.sh index c38a24a..9868232 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -78,6 +78,7 @@ init() { --config "$CONFIG_FILE" \ --import-from-dnscrypt-wrapper "${KEYS_DIR}/secret.key" \ --dry-run >/dev/null || exit 1 + mv -f "${KEYS_DIR}/secret.key" "${KEYS_DIR}/secret.key.migrated" fi /opt/encrypted-dns/sbin/encrypted-dns \ @@ -149,6 +150,14 @@ ensure_initialized() { start() { ensure_initialized + if [ -f "${KEYS_DIR}/secret.key" ]; then + echo "Importing the previous secret key [${KEYS_DIR}/secret.key]" + /opt/encrypted-dns/sbin/encrypted-dns \ + --config "$CONFIG_FILE" \ + --import-from-dnscrypt-wrapper "${KEYS_DIR}/secret.key" \ + --dry-run >/dev/null || exit 1 + mv -f "${KEYS_DIR}/secret.key" "${KEYS_DIR}/secret.key.migrated" + fi /opt/encrypted-dns/sbin/encrypted-dns \ --config "$CONFIG_FILE" --dry-run | tee "${KEYS_DIR}/provider-info.txt"