Last active
December 25, 2025 05:23
-
-
Save ahxxm/83582a243e16ad98385c95776c00a902 to your computer and use it in GitHub Desktop.
cloudflared + dufs to share files, sends URL to telegram chat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services: | |
| fileserver: | |
| image: sigoden/dufs | |
| command: /srv --allow-search --allow-archive --compress none -p 80 | |
| volumes: | |
| # dir to share | |
| - /downloads:/srv:ro | |
| tunnel: | |
| image: alpine:latest | |
| depends_on: | |
| - fileserver | |
| env_file: | |
| # should look like this | |
| # TG_BOT_TOKEN=123456:ABC | |
| # TG_CHAT_ID=123456 | |
| - .env | |
| command: | |
| # amd64 / aarch64 | |
| - /bin/sh | |
| - -c | |
| - | | |
| apk add --no-cache curl | |
| wget -q "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64" -O /usr/local/bin/cloudflared | |
| chmod +x /usr/local/bin/cloudflared | |
| last_url="" | |
| cloudflared tunnel --no-autoupdate --url http://fileserver:80 2>&1 | while read line; do | |
| echo "$$line" | |
| url=$$(echo "$$line" | grep -o 'https://[^[:space:]]*\.trycloudflare\.com' || true) | |
| if [ -n "$$url" ] && [ "$$url" != "$$last_url" ]; then | |
| curl -sf "https://api.telegram.org/bot$${TG_BOT_TOKEN}/sendMessage" \ | |
| -d "chat_id=$${TG_CHAT_ID}" \ | |
| -d "text=$$url" | |
| last_url="$$url" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment