Skip to content

Commit 36da77a

Browse files
committed
[BACK-593] Improvements to the entrypoint script
1 parent 71a74ab commit 36da77a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

entrypoint.sh

+11-10
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,22 @@ if [[ -z "${BASE_DIR}" ]]; then
66
BASE_DIR="/app"
77
fi
88

9-
if [[ -z "${PROXY_LIST_URL}" ]]; then
9+
if [[ -n "${BRIGHT_DATA_API_TOKEN}" && -n "${BRIGHT_DATA_USERNAME}" && -n "${BRIGHT_DATA_PASSWORD}" && -n "${BRIGHT_DATA_ZONE}" ]]; then
10+
BRIGHT_DATA_URL="https://api.brightdata.com/zone/route_ips?zone=$BRIGHT_DATA_ZONE"
11+
echo "Downloading proxy list from $BRIGHT_DATA_URL"
12+
curl -s -H "Authorization: Bearer $BRIGHT_DATA_API_TOKEN" "$BRIGHT_DATA_URL" > $BASE_DIR/proxy-list.txt
13+
echo "Correctly formatting proxy list file"
14+
# Builds the URL with the username, password and the endpoint of Bright Data
15+
SUBSTITUTION_PATTERN="s/^.*/http:\/\/${BRIGHT_DATA_USERNAME}-ip-&:${BRIGHT_DATA_PASSWORD}@brd.superproxy.io:22225/"
16+
sed -i $SUBSTITUTION_PATTERN $BASE_DIR/proxy-list.txt
17+
echo " ---> Done"
18+
elif [[ -z "${PROXY_LIST_URL}" ]]; then
1019
echo "Using mounted proxy list"
1120
touch $BASE_DIR/proxy-list.txt
1221
echo " ---> Done"
13-
elif [[ -z "${BRIGHT_DATA_API_TOKEN}"]]; then
14-
echo "Downloading proxy list from $PROXY_LIST_URL"
15-
curl -s $PROXY_LIST_URL > $BASE_DIR/proxy-list.txt
16-
echo " ---> Done"
1722
else
1823
echo "Downloading proxy list from $PROXY_LIST_URL"
19-
curl -s -H "Authorization: Bearer $BRIGHT_DATA_API_TOKEN" "$PROXY_LIST_URL" > $BASE_DIR/proxy-list.txt
20-
echo "Correctly formatting proxy list file"
21-
# Builds the URL with the username, password and the endpoint of Bright Data
22-
SUBSTITUTION_PATTERN="s/^.*/http:\/\/${BRIGHT_DATA_USERNAME}-ip-&:${BRIGHT_DATA_PASSWORD}@brd.superproxy.io:22225/"
23-
sed -i $SUBSTITUTION_PATTERN $BASE_DIR/proxy-list.txt
24+
curl -s $PROXY_LIST_URL > $BASE_DIR/proxy-list.txt
2425
echo " ---> Done"
2526
fi
2627

0 commit comments

Comments
 (0)