-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugins/clnrest: simple wrapper to handle missing python3.
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 <[email protected]> Signed-off-by: Rusty Russell <[email protected]> Changelog-Fixed: Plugins: `clnrest` now correctly self-disables if Python not present at all.
- Loading branch information
1 parent
7d8c723
commit c4edec8
Showing
3 changed files
with
30 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#! /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 |
This file contains 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