caddy -version)?Caddy 0.11.0
… and really HEAD.
caddy in my CI to test a plugin, but with a closed stdin.caddy, and the console is no TTY.bind 0.0.0.0:<random port>
Just a minimal Caddyfile to get to the prompt. I know I could run this with a two-liner *:<random port>\nroot /…/….
For example, with a closed stdin:
<&- ./caddy -conf /etc/Caddyfile
—
Caddy doing its thing.
Activating privacy features...
Your sites will be served over HTTPS automatically using Let's Encrypt.
By continuing, you agree to the Let's Encrypt Subscriber Agreement at:
https://letsencrypt…
Please enter your email address to signify agreement and to be notified
in case of issues. You can leave it blank, but we don't recommend it.
Email address: 2018/06/13 16:57:53 reading email address: read /dev/stdin: resource temporarily unavailable
See commands above.
Caddy does not check if stdin is open and available. It assumes the operator is at the keyboard and able to answer questions.
Do something like this before any and all prompts:
if f, err := os.Stdin.Stat(); err != nil {
return // no questions will be answered
} else {
if !(f.Mode()&os.ModeCharDevice) {
return // no dice either
}
}
// Swell, ask away.
… or similar; I improvised the code above and didn't really check it.
@wmark Would you like to create a PR?
I won't have time for this.
It should be easy enough for someone new to Caddy or even Go, with rudimentary knowledge of how Linux works.
From my notes:
caddy from stdin could've been discontinued recently. If so, then the CL might contain another example of how to detect what kind of input is on stdin. If not, then the safeguards there could be expanded to address this issue.We actually have to check also if os.ModeCharDevice works well on windows and with Cygwin just in case.
Looking at the code there is a flag allowPrompts that is used to skip prompts. I wonder if it's a good idea to use an unattended config instead of this?
Most helpful comment
We actually have to check also if
os.ModeCharDeviceworks well on windows and with Cygwin just in case.