Skip to content

Instantly share code, notes, and snippets.

@TownLake
Created December 27, 2019 17:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TownLake/3a759ad0f05291e2d60fda418813ac8f to your computer and use it in GitHub Desktop.
Save TownLake/3a759ad0f05291e2d60fda418813ac8f to your computer and use it in GitHub Desktop.
Shell script that will switch to your blog directory, start a testing Hugo server, wait for it to begin, and then connect it to the Internet via a free Cloudflare Argo Tunnel.
#!/bin/bash
trap "exit" INT TERM ERR
trap "kill 0" EXIT
# These lines make sure that the Hugo server and the Argo Tunnel processes are killed when you ctrl+c the terminal window.
cd /Users/samrhea/blog-samrhea
# This changes the directory to where my blog lives. Replace this with your own by running `pwd` in your blog directory and adding the output here.
hugo server -D &
# This starts a web server on port 1313 that runs the current edition of my Hugo blog.
sleep 3s
# This prevents a race condition where the tunnel would attempt to connect before the Hugo server was ready
cloudflared tunnel --url localhost:1313 &
# This creates a free Argo Tunnel and proxies requests to that port.
wait
# Make sure that you make this file executable first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment