Skip to content

Commit

Permalink
entrypoint: make entrypoint more generic
Browse files Browse the repository at this point in the history
 * It can listen on any port, hostnames are not hardcoded if STORJUP_WAIT_FOR is used.
 * external address of storagenodes are not forced
 * option to copy satellite-api identities to make persisted but predictable identites

Change-Id: I6e6872aeb59d5bf33d9a85b9f1bf7087394fae22
  • Loading branch information
elek authored and Storj Robot committed Oct 12, 2022
1 parent 3a929b4 commit abd16c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions pkg/recipe/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ export STORJ_NODE_IP=$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," "
#Generate identity if missing
if [ "$STORJ_IDENTITY_DIR" ]; then
if [ ! -f "$STORJ_IDENTITY_DIR/identity.key" ]; then
identity --identity-dir $STORJ_IDENTITY_DIR --difficulty 8 create .
if [ "$STORJ_USE_PREDEFINED_IDENTITY" ]; then
# use predictable, pre-generated identity
mkdir -p $(dirname $STORJ_IDENTITY_DIR)
cp -r /var/lib/storj/identities/$STORJ_USE_PREDEFINED_IDENTITY $STORJ_IDENTITY_DIR
else
identity --identity-dir $STORJ_IDENTITY_DIR --difficulty 8 create .
fi
fi
fi

for i in ${STORJ_WAIT_FOR//,/ }
do
storj-up util wait-for-port "$i"
done

if [ "$STORJ_WAIT_FOR_DB" ]; then
storj-up util wait-for-port cockroach:26257
storj-up util wait-for-port redis:6379
Expand All @@ -24,17 +35,16 @@ fi
if [ "$STORJ_ROLE" == "satellite-api" ]; then
mkdir -p /var/lib/storj/.local

#only migrate first time
if [ ! -f "/var/lib/storj/.local/migrated" ]; then
#only migrate first time, if automatic migration is not defined
if [[ ! -f "/var/lib/storj/.local/migrated" && -z "$STORJ_DATABASE_OPTIONS_MIGRATION_UNSAFE" ]]; then
satellite run migration --identity-dir $STORJ_IDENTITY_DIR
touch /var/lib/storj/.local/migrated

fi
fi

if [ "$STORJ_ROLE" == "storagenode" ]; then
#Initialize config, required only to have all the dirs created
export STORJ_CONTACT_EXTERNAL_ADDRESS=$STORJ_NODE_IP:28967
: ${STORJ_CONTACT_EXTERNAL_ADDRESS:=$STORJ_NODE_IP:28967}
if [ -f "/var/lib/storj/.local/share/storj/storagenode/config.yaml" ]; then
rm "/var/lib/storj/.local/share/storj/storagenode/config.yaml"
fi
Expand Down
2 changes: 1 addition & 1 deletion storj-base.last
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20220907-1
20221011-2

0 comments on commit abd16c2

Please sign in to comment.