aboutsummaryrefslogtreecommitdiff
path: root/bin/currencies.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/currencies.sh')
-rwxr-xr-xbin/currencies.sh32
1 files changed, 32 insertions, 0 deletions
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
+