From 6f040732b53d550d438fd96a3d9c8c7c9b18ba71 Mon Sep 17 00:00:00 2001 From: openoms <43343391+openoms@users.noreply.github.com> Date: Mon, 20 Jun 2022 11:36:20 +0100 Subject: [PATCH] fix web.api install syntax (#3171) --- home.admin/config.scripts/blitz.web.api.sh | 20 +++++------ home.admin/config.scripts/blitz.web.ui.sh | 18 ++++------ .../config.scripts/cl-plugin.cln-grpc.sh | 35 ++++++++++++------- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/home.admin/config.scripts/blitz.web.api.sh b/home.admin/config.scripts/blitz.web.api.sh index 994faaca2..2e6765608 100755 --- a/home.admin/config.scripts/blitz.web.api.sh +++ b/home.admin/config.scripts/blitz.web.api.sh @@ -18,7 +18,7 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; fi # check if started with sudo -if [ "$EUID" -ne 0 ]; then +if [ "$EUID" -ne 0 ]; then echo "error='run as root'" exit 1 fi @@ -46,21 +46,18 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then echo "# INSTALL Web API ..." rm -r /root/blitz_api 2>/dev/null - cd /root + cd /root || exit 1 # git clone https://github.com/fusion44/blitz_api.git /root/blitz_api - git clone https://github.com/${DEFAULT_GITHUB_USER}/${DEFAULT_GITHUB_REPO}.git /root/blitz_api - if [ "$?" != "0"]; then + if ! git clone https://github.com/${DEFAULT_GITHUB_USER}/${DEFAULT_GITHUB_REPO}.git /root/blitz_api; then echo "error='git clone failed'" exit 1 fi - cd blitz_api - git checkout ${DEFAULT_GITHUB_BRANCH} - if [ "$?" != "0"]; then + cd blitz_api || exit 1 + if ! git checkout ${DEFAULT_GITHUB_BRANCH}; then echo "error='git checkout failed'" exit 1 fi - pip install -r requirements.txt - if [ "$?" != "0"]; then + if ! pip install -r requirements.txt --no-deps; then echo "error='pip install failed'" exit 1 fi @@ -183,10 +180,13 @@ if [ "$1" = "update-config" ]; then # configure CL elif [ "${lightning}" == "cl" ]; then - + echo "# CONFIG Web API Lightning --> CL" sed -i "s/^ln_node=.*/ln_node=cln_grpc/g" ./.env + # make sure cln-grpc is on + /home/admin/config.scripts/cl-plugin.cln-grpc.sh on mainnet + # get hex values of pem files hexClient=$(xxd -p -c2000 /home/bitcoin/.lightning/bitcoin/client.pem) hexClientKey=$(xxd -p -c2000 /home/bitcoin/.lightning/bitcoin/client-key.pem) diff --git a/home.admin/config.scripts/blitz.web.ui.sh b/home.admin/config.scripts/blitz.web.ui.sh index 36d232911..c6db90cc5 100755 --- a/home.admin/config.scripts/blitz.web.ui.sh +++ b/home.admin/config.scripts/blitz.web.ui.sh @@ -40,16 +40,15 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then echo "# INSTALL WebUI" rm -r /root/blitz_web 2>/dev/null - cd /root + cd /root || exit 1 # git clone https://github.com/cstenglein/raspiblitz-web.git /home/admin/blitz_web git clone https://github.com/${DEFAULT_GITHUB_USER}/${DEFAULT_GITHUB_REPO}.git /root/blitz_web - if [ "$?" != "0"]; then + if ! git clone https://github.com/${DEFAULT_GITHUB_USER}/${DEFAULT_GITHUB_REPO}.git /root/blitz_web; then echo "error='git clone failed'" exit 1 fi - cd blitz_web - git checkout ${DEFAULT_GITHUB_BRANCH} - if [ "$?" != "0"]; then + cd blitz_web || exit 1 + if ! git checkout ${DEFAULT_GITHUB_BRANCH}; then echo "error='git checkout failed'" exit 1 fi @@ -57,19 +56,16 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then echo "# Compile WebUI" /home/admin/config.scripts/bonus.nodejs.sh on source <(/home/admin/config.scripts/bonus.nodejs.sh info) - npm install --global yarn - if [ "$?" != "0"]; then + if ! npm install --global yarn; then echo "error='install yarn failed'" exit 1 fi ${NODEPATH}/yarn config set --home enableTelemetry 0 - ${NODEPATH}/yarn install - if [ "$?" != "0"]; then + if ! ${NODEPATH}/yarn install; then echo "error='yarn install failed'" exit 1 fi - ${NODEPATH}/yarn build - if [ "$?" != "0"]; then + if ! ${NODEPATH}/yarn build; then echo "error='yarn build failed'" exit 1 fi diff --git a/home.admin/config.scripts/cl-plugin.cln-grpc.sh b/home.admin/config.scripts/cl-plugin.cln-grpc.sh index 2c18d082c..78d724d5c 100644 --- a/home.admin/config.scripts/cl-plugin.cln-grpc.sh +++ b/home.admin/config.scripts/cl-plugin.cln-grpc.sh @@ -36,7 +36,7 @@ function buildGRPCplugin() { sudo -u bitcoin /home/bitcoin/.cargo/bin/cargo build \ --target-dir /home/bitcoin/cl-plugins-available/cln-grpc else - echo "# - cln-grpc plugin already build/installed" + echo "# - cln-grpc plugin was already built/installed" fi } @@ -53,21 +53,30 @@ elif [ "$1" = status ]; then exit 0 elif [ "$1" = on ]; then - buildGRPCplugin + if ! "$lightningcli_alias" plugin list | grep "/home/bitcoin/${netprefix}cl-plugins-enabled/cln-grpc"; then + buildGRPCplugin - # symlink to plugin directory - sudo ln -s /home/bitcoin/cl-plugins-available/cln-grpc/debug/cln-grpc /home/bitcoin/${netprefix}cl-plugins-enabled/ - echo "# cln-grpc moved to /home/bitcoin/${netprefix}cl-plugins-enabled/" + # symlink to plugin directory + sudo ln -s /home/bitcoin/cl-plugins-available/cln-grpc/debug/cln-grpc /home/bitcoin/${netprefix}cl-plugins-enabled/ + echo "# cln-grpc moved to /home/bitcoin/${netprefix}cl-plugins-enabled/" - # blitz.conf.sh set [key] [value] [?conffile] - /home/admin/config.scripts/blitz.conf.sh set "grpc-port" "${PORT}" "${CLCONF}" "noquotes" - /home/admin/config.scripts/blitz.conf.sh set "${netprefix}clnGRPCport" "${PORT}" + # blitz.conf.sh set [key] [value] [?conffile] + /home/admin/config.scripts/blitz.conf.sh set "grpc-port" "${PORT}" "${CLCONF}" "noquotes" + /home/admin/config.scripts/blitz.conf.sh set "${netprefix}clnGRPCport" "${PORT}" - # firewall - sudo ufw allow "${PORT}" comment "${netprefix}clnGRPCport" - # Tor - /home/admin/config.scripts/tor.onion-service.sh "${netprefix}clnGRPCport" "${PORT}" "${PORT}" - echo "# cl-plugin.cln-grpc.sh on --> done" + # firewall + sudo ufw allow "${PORT}" comment "${netprefix}clnGRPCport" + # Tor + /home/admin/config.scripts/tor.onion-service.sh "${netprefix}clnGRPCport" "${PORT}" "${PORT}" + source <(/home/admin/_cache.sh get state) + if [ "${state}" == "ready" ]; then + sudo systemctl restart ${netprefix}lightningd + fi + echo "# cl-plugin.cln-grpc.sh on --> done" + + else + echo "# cl-plugin.cln-grpc.sh on --> already installed and running" + fi exit 0 elif [ "$1" = off ]; then