2
0

fix(install): Fix secret key gen on BSD (#338)

Fixes #330.
This commit is contained in:
Burak Yigit Kaya 2020-01-10 12:34:36 +03:00 committed by GitHub
parent bc23448141
commit d6951a2c32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,7 +86,9 @@ ensure_file_from_example $SENTRY_EXTRA_REQUIREMENTS
echo "" echo ""
echo "Generating secret key..." echo "Generating secret key..."
# This is to escape the secret key to be used in sed below # This is to escape the secret key to be used in sed below
SECRET_KEY=$(head /dev/urandom | tr -dc "a-z0-9@#%^&*(-_=+)" | head -c 50 | sed -e 's/[\/&]/\\&/g') # Note the need to set LC_ALL=C due to BSD tr and sed always trying to decode
# whatever is passed to them. Kudos to https://stackoverflow.com/a/23584470/90297
SECRET_KEY=$(export LC_ALL=C; head /dev/urandom | tr -dc "a-z0-9@#%^&*(-_=+)" | head -c 50 | sed -e 's/[\/&]/\\&/g')
sed -i -e 's/^system.secret-key:.*$/system.secret-key: '"'$SECRET_KEY'"'/' $SENTRY_CONFIG_YML sed -i -e 's/^system.secret-key:.*$/system.secret-key: '"'$SECRET_KEY'"'/' $SENTRY_CONFIG_YML
echo "Secret key written to $SENTRY_CONFIG_YML" echo "Secret key written to $SENTRY_CONFIG_YML"