Skip to content
Open
Changes from all 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
30 changes: 17 additions & 13 deletions scripts/util/keystore-setup
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,25 @@ fi

$LOGGER_CMD "$(date) - starting keystore-setup"

# Create the props file if missing, so the new password can be saved
if [ ! -f "$PROPS_FILE" ]; then
$LOGGER_CMD "Props file does not exist, creating it"
touch "$PROPS_FILE"
chmod 600 "$PROPS_FILE" || $LOGGER_CMD "Cannot chmod $PROPS_FILE"
fi

# Re-use existing password or use the one provided
if [ -f "$PROPS_FILE" ]; then
$LOGGER_CMD "Previous props file exists, trying to extract password"
OLD_PASS=$(sed -n '/^keystore.passphrase/p' "$PROPS_FILE" | sed 's/^keystore.passphrase=//g')
if [ -n "${OLD_PASS// }" ]; then
KS_PASS="$OLD_PASS"
$LOGGER_CMD "Password extraction successful"
OLD_PASS=$(sed -n '/^keystore.passphrase/p' "$PROPS_FILE" | sed 's/^keystore.passphrase=//g')
if [ -n "${OLD_PASS// }" ]; then
KS_PASS="$OLD_PASS"
$LOGGER_CMD "Password extraction successful"
else
sed -i "/^keystore.passphrase.*/d" "$PROPS_FILE" 2>&1 | $LOGGER_CMD || true
echo "keystore.passphrase=$KS_PASS" >> "$PROPS_FILE"
if [ $? != 0 ]; then
$LOGGER_CMD "Could not add new password to agent.properties"
else
sed -i "/^keystore.passphrase.*/d" "$PROPS_FILE" 2>&1 | $LOGGER_CMD || true
echo "keystore.passphrase=$KS_PASS" >> "$PROPS_FILE"
if [ $? != 0 ]; then
$LOGGER_CMD "Could not add new password to agent.properties"
else
$LOGGER_CMD "New keystore password set"
fi
$LOGGER_CMD "New keystore password set"
fi
fi

Expand Down
Loading