mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-24 15:10:51 +01:00
Apparently NixOS didn't have Python (sometimes!) so let's not assume. By reusing the JSON "parsing" code from cowsay, we can self-disable to handle this case. Reported-by: Shahana Farooqui <shahana.farooqui@gmail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Fixed: Plugins: `clnrest` now correctly self-disables if Python not present at all.
16 lines
539 B
Bash
Executable file
16 lines
539 B
Bash
Executable file
#! /bin/sh
|
|
# clrest.py neatly exits if we don't have dependencies, but what if we don't
|
|
# have Python itself?
|
|
|
|
if ! type python3 > /dev/null 2>&1; then
|
|
# No python3 binary.
|
|
# Fortunately, CLN gives us JSON in a very standard way, so we can assume:
|
|
# Eg. {"jsonrpc":"2.0","id":2,"method":"getmanifest","params":{}}\n\n
|
|
read -r JSON
|
|
read -r _
|
|
id=$(echo "$JSON" | sed 's/.*"id" *: *\([^,]*\),.*/\1/')
|
|
echo '{"jsonrpc":"2.0","id":'"$id"',"result":{"disable":"No python3 binary found"}}'
|
|
exit 1
|
|
fi
|
|
|
|
exec "$0".py
|