#!/bin/sh RUNEFILE=~/vol/rtl/data/rtl.macaroon running=$(podman ps --filter "name=systemd-clightning-node" --format json | jq -r .[].State) if [ -e $RUNEFILE ]; then echo "Macaroon $RUNEFILE already exist" exit 1 fi if [ "$running" == "running" ] then # Its running checkrune=$(podman exec -it systemd-clightning-node lightning-cli showrunes | jq -r .runes[0].unique_id) if [ "$checkrune" -eq 0 ]; then # Rune exist, get it and output to $RUNEFILE rune=$(podman exec -it systemd-clightning-node lightning-cli showrunes | jq -r .runes[0].rune) else # Rune doesn't exist, create it and output to $RUNEFILE rune=$(podman exec -it systemd-clightning-node lightning-cli createrune | jq -r .runes[0].rune) fi echo "LIGHTNING_RUNE=\"$rune\"" > $RUNEFILE exit 0 else echo "Can't find systemd-clightning-node running." # exit 1 fi