2019-03-25 13:29:05 +00:00
|
|
|
#!/bin/sh
|
2018-11-22 23:51:16 +00:00
|
|
|
|
2019-11-27 13:04:30 +00:00
|
|
|
opensslConf=${1:-openssl.cnf}
|
|
|
|
secretsFile=secrets.nix
|
2018-11-22 23:51:16 +00:00
|
|
|
|
2019-11-27 13:04:30 +00:00
|
|
|
if [ ! -e "$secretsFile" ]; then
|
|
|
|
echo Write secrets to $secretsFile
|
2019-11-27 13:04:28 +00:00
|
|
|
makepw="apg -m 20 -x 20 -M Ncl -n 1"
|
2019-08-22 17:23:53 +00:00
|
|
|
{
|
|
|
|
echo \{
|
2019-11-27 13:04:28 +00:00
|
|
|
echo " bitcoinrpcpassword = \"$($makepw)\";"
|
|
|
|
echo " lnd-wallet-password = \"$($makepw)\";"
|
|
|
|
echo " lightning-charge-api-token = \"$($makepw)\";"
|
|
|
|
echo " liquidrpcpassword = \"$($makepw)\";"
|
|
|
|
echo " spark-wallet-password = \"$($makepw)\";"
|
2019-08-22 17:23:53 +00:00
|
|
|
echo \}
|
2019-11-27 13:04:30 +00:00
|
|
|
} >> $secretsFile
|
2019-08-22 17:23:53 +00:00
|
|
|
echo Done
|
|
|
|
else
|
2019-11-27 13:04:30 +00:00
|
|
|
echo $secretsFile already exists. Skipping.
|
2018-11-22 23:51:16 +00:00
|
|
|
fi
|
|
|
|
|
2019-11-27 13:04:29 +00:00
|
|
|
if [ ! -e nginx.key ] || [ ! -e nginx.cert ]; then
|
2019-08-22 17:23:53 +00:00
|
|
|
echo Generate Nginx Self-Signed Cert
|
2019-11-27 13:04:29 +00:00
|
|
|
openssl genrsa -out nginx.key 2048
|
|
|
|
openssl req -new -key nginx.key -out nginx.csr -subj "/C=KN"
|
|
|
|
openssl x509 -req -days 1825 -in nginx.csr -signkey nginx.key -out nginx.cert
|
|
|
|
rm nginx.csr
|
2019-08-22 17:23:53 +00:00
|
|
|
echo Done
|
|
|
|
else
|
|
|
|
echo Nginx Cert already exists. Skipping.
|
|
|
|
fi
|
2019-08-05 08:44:38 +00:00
|
|
|
|
2019-11-27 13:04:29 +00:00
|
|
|
if [ ! -e lnd.key ] || [ ! -e lnd.cert ]; then
|
2019-08-22 17:23:53 +00:00
|
|
|
echo Generate LND compatible TLS Cert
|
2019-11-27 13:04:29 +00:00
|
|
|
openssl ecparam -genkey -name prime256v1 -out lnd.key
|
2019-11-27 13:04:30 +00:00
|
|
|
openssl req -config $opensslConf -new -sha256 -key lnd.key -out lnd.csr -subj '/CN=localhost/O=lnd'
|
|
|
|
openssl req -config $opensslConf -x509 -sha256 -days 1825 -key lnd.key -in lnd.csr -out lnd.cert
|
2019-11-27 13:04:29 +00:00
|
|
|
rm lnd.csr
|
2019-08-22 17:23:53 +00:00
|
|
|
echo Done
|
|
|
|
else
|
|
|
|
echo LND cert already exists. Skipping.
|
|
|
|
fi
|