Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions docker-compose/local/lps-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,27 @@ if [ "$FAIL" = true ]; then
fi

rm -f cookie_jar.txt
MANAGEMENT_PWD=$(docker exec lps01 cat /tmp/management_password.txt)
CSRF_TOKEN=$(curl -s -c cookie_jar.txt -H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: http://localhost:8080' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: same-origin' \

PASSWORD_FILE_PATH="/tmp/management_password.txt"

echo "Checking for management_password.txt..."
if ! docker exec lps01 test -f "$PASSWORD_FILE_PATH"; then
echo "management_password.txt not found. Skipping configuration steps"
exit 0
fi

echo "management_password.txt found. Proceeding with configuration."

MANAGEMENT_PWD=$(docker exec lps01 cat "$PASSWORD_FILE_PATH")

CSRF_TOKEN=$(curl -s -c cookie_jar.txt \
-H 'Accept: */*' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: http://localhost:8080' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: same-origin' \
"http://localhost:8080/management" | sed -n 's/.*name="csrf"[^>]*value="\([^"]*\)".*/\1/p')

CSRF_TOKEN=${CSRF_TOKEN//+/+}
Expand All @@ -202,7 +214,6 @@ curl -s -b cookie_jar.txt -c cookie_jar.txt "http://localhost:8080/management/lo
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: http://localhost:8080' \
-H 'Referer: http://localhost:8080/management' \
-H 'Sec-Fetch-Dest: empty' \
Expand All @@ -211,15 +222,14 @@ curl -s -b cookie_jar.txt -c cookie_jar.txt "http://localhost:8080/management/lo
--data "{
\"username\": \"admin\",
\"password\": \"$MANAGEMENT_PWD\"
}"
}" || { echo "Error: login to Management UI failed"; exit 1; }

echo "Setting up general regtest configuration"
curl -s -b cookie_jar.txt 'http://localhost:8080/configuration' \
curl -sfS -b cookie_jar.txt 'http://localhost:8080/configuration' \
-H "X-CSRF-Token: $CSRF_TOKEN" \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: http://localhost:8080' \
-H 'Referer: http://localhost:8080/management' \
-H 'Sec-Fetch-Dest: empty' \
Expand All @@ -243,15 +253,14 @@ curl -s -b cookie_jar.txt 'http://localhost:8080/configuration' \
},
"publicLiquidityCheck": true
}
}'
}' || { echo "Error in configuring general regtest configuration"; exit 1; }

echo "Setting up pegin regtest configuration"
curl -s -b cookie_jar.txt 'http://localhost:8080/pegin/configuration' \
curl -sfS -b cookie_jar.txt 'http://localhost:8080/pegin/configuration' \
-H "X-CSRF-Token: $CSRF_TOKEN" \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: http://localhost:8080' \
-H 'Referer: http://localhost:8080/management' \
-H 'Sec-Fetch-Dest: empty' \
Expand All @@ -266,15 +275,14 @@ curl -s -b cookie_jar.txt 'http://localhost:8080/pegin/configuration' \
"maxValue": "10000000000000000000",
"minValue": "600000000000000000"
}
}'
}' || { echo "Error in configuring pegin regtest configuration"; exit 1; }

echo "Setting up pegout regtest configuration"
curl -s -b cookie_jar.txt 'http://localhost:8080/pegout/configuration' \
curl -sfS -b cookie_jar.txt 'http://localhost:8080/pegout/configuration' \
-H "X-CSRF-Token: $CSRF_TOKEN" \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: http://localhost:8080' \
-H 'Referer: http://localhost:8080/management' \
-H 'Sec-Fetch-Dest: empty' \
Expand All @@ -291,4 +299,4 @@ curl -s -b cookie_jar.txt 'http://localhost:8080/pegout/configuration' \
"expireBlocks": 500,
"bridgeTransactionMin": "1500000000000000000"
}
}'
}' || { echo "Error in configuring pegout regtest configuration"; exit 1; }
2 changes: 1 addition & 1 deletion sample-config.env
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ DISABLE_CAPTCHA=true
CAPTCHA_URL="https://www.google.com/recaptcha/api/siteverify"

# Management api env
ENABLE_MANAGEMENT_API=false
ENABLE_MANAGEMENT_API=true
MANAGEMENT_AUTH_KEY=a2fbac02d66202e8468d2a4f1deba4fa5c2491f592e0e22e32fe1e6acac25923
MANAGEMENT_ENCRYPTION_KEY=9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
MANAGEMENT_TOKEN_AUTH_KEY=c5ff177a86e82441f93e3772da700d5f6838157fa1bfdc0bb689d7f7e55e7aba
Expand Down
Loading