web.api: fix sed syntax and format (#3749)

This commit is contained in:
openoms 2023-04-13 11:05:23 +01:00 committed by GitHub
parent 4f93dee697
commit 3b52569be5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,7 +33,7 @@ if [ "$1" = "update-config" ]; then
fi
# prepare config update
cd /home/blitzapi/blitz_api
cd /home/blitzapi/blitz_api || exit 1
secret=$(cat ./.env 2>/dev/null | grep "secret=" | cut -d "=" -f2)
cp ./.env_sample ./.env
dateStr=$(date)
@ -44,7 +44,7 @@ if [ "$1" = "update-config" ]; then
# configure access token secret
if [ "${secret}" == "" ] || [ "${secret}" == "please_please_update_me_please" ]; then
echo "# init secret ..."
secret=$(dd if=/dev/urandom bs=256 count=1 2> /dev/null | shasum -a256 | cut -d " " -f1)
secret=$(dd if=/dev/urandom bs=256 count=1 2>/dev/null | shasum -a256 | cut -d " " -f1)
else
echo "# use existing secret"
fi
@ -78,13 +78,13 @@ if [ "$1" = "update-config" ]; then
sed -i "s/^lnd_grpc_ip=.*/lnd_grpc_ip=127.0.0.1/g" ./.env
sed -i "s/^lnd_macaroon=.*/lnd_macaroon=${adminMacaroon}/g" ./.env
sed -i "s/^lnd_cert=.*/lnd_cert=${tlsCert}/g" ./.env
if [ "${chain}" == "main" ];then
if [ "${chain}" == "main" ]; then
L2rpcportmod=0
portprefix=""
elif [ "${chain}" == "test" ];then
elif [ "${chain}" == "test" ]; then
L2rpcportmod=1
portprefix=1
elif [ "${chain}" == "sig" ];then
elif [ "${chain}" == "sig" ]; then
L2rpcportmod=3
portprefix=3
fi
@ -96,7 +96,7 @@ if [ "$1" = "update-config" ]; then
echo "# CONFIG Web API Lightning --> CL"
sed -i "s/^ln_node=.*/ln_node=cln_jrpc/g" ./.env
sed -i "s/^cln_jrpc_path=.*/cln_jrpc_path="/mnt/hdd/app-data/.lightning/bitcoin/lightning-rpc"/g" ./.env
sed -i "s#^cln_jrpc_path=.*#cln_jrpc_path=\"/mnt/hdd/app-data/.lightning/bitcoin/lightning-rpc\"#g" ./.env
# make sure cln-grpc is on
# sudo /home/admin/config.scripts/cl-plugin.cln-grpc.sh on mainnet
@ -330,7 +330,7 @@ if [ "$1" = "update-code" ]; then
echo "# Update Web API CODE"
systemctl stop blitzapi
sudo chown -R blitzapi:blitzapi /home/blitzapi/blitz_api
cd /home/blitzapi/blitz_api
cd /home/blitzapi/blitz_api || exit 1
if [ "$currentBranch" == "" ]; then
currentBranch=$(sudo -u blitzapi git rev-parse --abbrev-ref HEAD)
fi