From 91406f02b2a87e0dbfaf8a391edd049c25563848 Mon Sep 17 00:00:00 2001 From: sn4il Date: Tue, 27 Jun 2023 10:59:14 +0300 Subject: Initial commit --- bin/currencies.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 bin/currencies.sh (limited to 'bin/currencies.sh') diff --git a/bin/currencies.sh b/bin/currencies.sh new file mode 100755 index 0000000..0bb684d --- /dev/null +++ b/bin/currencies.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +fiatentry() { + printf "## %s\n" "$1" >> "$3" + code=$(/usr/bin/curl -o /tmp/ratesx-resp.txt -s -w "%{http_code}" rub.rate.sx/$2) + if [[ $code == 200 ]]; then + cat /tmp/ratesx-resp.txt >> "$3" + else + printf "rate.sx вернул $code :(\n" >> "$3" + fi + printf "%s\n" '---' >> "$3" +} + +echo "# Курсы криптовалют" > /opt/gemini/crypto.gmi +echo "(обновление раз в 10 минут с rate.sx)" >> /opt/gemini/crypto.gmi +echo "udp $(date +"%Y-%m-%d %H:%M") GMT+3" >> /opt/gemini/cryptfiato.gmi +echo '```' >> /opt/gemini/crypto.gmi +/usr/bin/curl rate.sx/?qTF | tail -n +6>> /opt/gemini/crypto.gmi +echo '```' >> /opt/gemini/crypto.gmi + +echo "# Курсы фиатных валют к рублю" > /opt/gemini/fiat.gmi +echo "(обновление раз в 10 минут с rate.sx)" >> /opt/gemini/fiat.gmi +echo "udp $(date +"%Y-%m-%d %H:%M") GMT+3" >> /opt/gemini/fiat.gmi + +fiatentry "Доллар США" 1USD /opt/gemini/fiat.gmi +fiatentry "Евро" 1EUR /opt/gemini/fiat.gmi +fiatentry "Юань" 1CNY /opt/gemini/fiat.gmi +fiatentry "Иена" 1JPY /opt/gemini/fiat.gmi +fiatentry "Турецкая лира" 1TRY /opt/gemini/fiat.gmi +fiatentry "Швейцарский франк" 1CHF /opt/gemini/fiat.gmi +fiatentry "Британский фунт" 1GBP /opt/gemini/fiat.gmi + -- cgit v1.2.3