This commit is contained in:
nicolas.dorier 2023-01-06 10:22:57 +09:00
parent c94a3ecd0b
commit ba4e9c30c9
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
4 changed files with 23 additions and 0 deletions

View File

@ -60,6 +60,20 @@ if [[ "$1" == "bitcoin-cli" || "$1" == "bitcoin-tx" || "$1" == "bitcoind" || "$1
ln -sfn "$BITCOIN_DATA" /home/bitcoin/.bitcoin
chown -h bitcoin:bitcoin /home/bitcoin/.bitcoin
rm -f /home/bitcoin/.bitcoin/settings.json
# peers_dat is routinely corrupted, preventing bitcoind to start, see https://github.com/bitcoin/bitcoin/issues/26599
peers_dat="/home/bitcoin/.bitcoin/peers.dat"
peers_dat_corrupted="/home/bitcoin/.bitcoin/peers_corrupted.dat"
if [[ -f "${peers_dat}" ]]; then
actual_hash=$(head -c -32 "${peers_dat}" | sha256sum | cut -c1-64 | xxd -r -p | sha256sum | cut -c1-64)
expected_hash=$(tail -c 32 "${peers_dat}" | xxd -ps -c 32)
if [[ "${actual_hash}" != "${expected_hash}" ]]; then
echo "${peers_dat} is corrupted, moving it to ${peers_dat_corrupted}"
rm -f "${peers_dat_corrupted}"
mv "${peers_dat}" "${peers_dat_corrupted}"
fi
fi
exec gosu bitcoin "$@"
else
exec "$@"

View File

@ -22,6 +22,9 @@ RUN set -ex \
FROM debian:bullseye-slim
COPY --from=builder "/tmp/bin" /usr/local/bin
RUN apt-get update && \
apt-get install -qq --no-install-recommends xxd && \
rm -rf /var/lib/apt/lists/*
RUN chmod +x /usr/local/bin/gosu && groupadd -r bitcoin && useradd -r -m -g bitcoin bitcoin
# create data directory

View File

@ -27,6 +27,9 @@ FROM arm32v7/debian:bullseye-slim
COPY --from=builder "/tmp/bin" /usr/local/bin
COPY --from=builder /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static
RUN apt-get update && \
apt-get install -qq --no-install-recommends xxd && \
rm -rf /var/lib/apt/lists/*
RUN chmod +x /usr/local/bin/gosu && groupadd -r bitcoin && useradd -r -m -g bitcoin bitcoin
# create data directory

View File

@ -27,6 +27,9 @@ FROM arm64v8/debian:bullseye-slim
COPY --from=builder "/tmp/bin" /usr/local/bin
COPY --from=builder /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static
RUN apt-get update && \
apt-get install -qq --no-install-recommends xxd && \
rm -rf /var/lib/apt/lists/*
RUN chmod +x /usr/local/bin/gosu && groupadd -r bitcoin && useradd -r -m -g bitcoin bitcoin
# create data directory