From 3076cae8c29d5681cdc9c66a5bbad1fcfea85979 Mon Sep 17 00:00:00 2001 From: b0xxer Date: Sun, 18 Feb 2024 10:27:42 -0600 Subject: [PATCH] created utility script to create run from clightning. sorted out location and permissions for rtl to access. --- hosts | 1 + main.yml | 1 - roles/apps/tasks/rtl.yml | 12 +++++++ roles/apps/templates/rtl/RTL-Config.json.j2 | 7 +++-- roles/apps/templates/rtl/checkrunes.sh.j2 | 31 +++++++++++++++++++ .../apps/templates/rtl/rtl-node.container.j2 | 1 - 6 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 roles/apps/templates/rtl/checkrunes.sh.j2 diff --git a/hosts b/hosts index f3c5c89..13a9ad4 100644 --- a/hosts +++ b/hosts @@ -37,6 +37,7 @@ bitcoin_rpcpassword=8BaOf-luoLM-5zA8V0ozLOtqzZZch2knK9gWIBfafDw bitcoin_rpcauth=n0xb0x:413f1f82906117464e662853bce33577$80a039d800184a1cffd1de5468b5b2a7442ab1d368a13782e5283e575a9f57b2 electrs_version=0.10.2 rtl_version=0.15.0 +rtl_password=n0xb0x lnbits_version=0.12.1 zerotier_network= #Update wariness - 1 = very reluctant to update, 0 = eager to update diff --git a/main.yml b/main.yml index aca88d2..6ddbfb7 100644 --- a/main.yml +++ b/main.yml @@ -1,6 +1,5 @@ --- -- name: main - hosts: n0xb0x roles: diff --git a/roles/apps/tasks/rtl.yml b/roles/apps/tasks/rtl.yml index 5ffc885..a0ff71e 100644 --- a/roles/apps/tasks/rtl.yml +++ b/roles/apps/tasks/rtl.yml @@ -30,6 +30,18 @@ notify: rebuild_rtl tags: [apps,rtl] +- name: rtl - Copy checkrunes.sh + ansible.builtin.template: + src: rtl/checkrunes.sh.j2 + dest: ~/containers/rtl/checkrunes.sh + mode: '0700' + tags: [apps,rtl] + +- name: rtl - Run checkrunes.sh + ansible.builtin.command: + cmd: ~/containers/rtl/checkrunes.sh + creates: ~/vol/rtl/data/rtl.macaroon + - name: rtl - Copy rtl-node.container file ansible.builtin.template: src: rtl/rtl-node.container.j2 diff --git a/roles/apps/templates/rtl/RTL-Config.json.j2 b/roles/apps/templates/rtl/RTL-Config.json.j2 index f4212ef..b73fa0a 100644 --- a/roles/apps/templates/rtl/RTL-Config.json.j2 +++ b/roles/apps/templates/rtl/RTL-Config.json.j2 @@ -13,11 +13,11 @@ "lnNode": "Core Lightning Testnet # 1", "lnImplementation": "CLN", "Authentication": { - "runePath": "/RTL/.lightning/bitcoin" + "runePath": "/RTL/data/rtl.macaroon" }, "Settings": { "userPersona": "OPERATOR", - "themeMode": "DAY", + "themeMode": "NIGHT", "themeColor": "PURPLE", "bitcoindConfigPath": "", "logLevel": "INFO", @@ -27,5 +27,6 @@ } } ], - "multiPass": "n0xb0x" + "multiPass": "{{rtl_password}}" } + diff --git a/roles/apps/templates/rtl/checkrunes.sh.j2 b/roles/apps/templates/rtl/checkrunes.sh.j2 new file mode 100644 index 0000000..6adfd27 --- /dev/null +++ b/roles/apps/templates/rtl/checkrunes.sh.j2 @@ -0,0 +1,31 @@ +#!/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 \ No newline at end of file diff --git a/roles/apps/templates/rtl/rtl-node.container.j2 b/roles/apps/templates/rtl/rtl-node.container.j2 index a804d34..d6a3be9 100644 --- a/roles/apps/templates/rtl/rtl-node.container.j2 +++ b/roles/apps/templates/rtl/rtl-node.container.j2 @@ -8,7 +8,6 @@ PodmanArgs=--pod bitcoin-pod # Use volume Volume=/home/{{ansible_user}}/vol/rtl/data:/RTL/data:Z Volume=/home/{{ansible_user}}/vol/rtl/RTL-Config.json:/RTL/RTL-Config.json:Z -Volume=/home/{{ansible_user}}/vol/clightning:/RTL/:ro,Z [Service] # Restart service when sleep finishes