nix-bitcoin/secrets/generate_secrets.sh

26 lines
873 B
Bash
Raw Normal View History

#!/bin/sh
2018-11-22 15:51:16 -08:00
SECRETSFILE=secrets/secrets.nix
if [ -e "$SECRETSFILE" ]; then
echo $SECRETSFILE already exists. No new secrets were generated.
2018-11-22 15:51:16 -08:00
exit 1
fi
2018-12-01 08:36:07 -08:00
echo Write secrets to $SECRETSFILE
{
echo \{
echo " bitcoinrpcpassword = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
echo " lightning-charge-api-token = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
2018-12-03 14:33:21 -08:00
echo " liquidrpcpassword = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
2018-12-10 08:34:41 -08:00
echo " spark-wallet-password = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
2018-12-01 08:36:07 -08:00
echo \}
} >> $SECRETSFILE
2018-11-22 15:51:16 -08:00
echo Done
2019-04-26 02:09:55 -07:00
echo Generate Self-Signed Cert
openssl genrsa -out secrets/ssl_certificate_key.key 2048
openssl req -new -key secrets/ssl_certificate_key.key -out secrets/ssl_certificate.csr -subj "/C=KN"
openssl x509 -req -days 1825 -in secrets/ssl_certificate.csr -signkey secrets/ssl_certificate_key.key -out secrets/ssl_certificate.crt
echo Done