mirror of https://github.com/lukechilds/umbrel.git
nolim1t
5 years ago
8 changed files with 144 additions and 159 deletions
@ -1,36 +1,21 @@ |
|||||
This is free and unencumbered software released into the public domain. |
The MIT License |
||||
|
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or |
Copyright (c) 2020 Umbrel. https://getumbrel.com |
||||
distribute this software, either in source code form or as a compiled |
|
||||
binary, for any purpose, commercial or non-commercial, and by any |
|
||||
means. |
|
||||
|
|
||||
In jurisdictions that recognize copyright laws, the author or authors |
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software dedicate any and all copyright interest in the |
of this software and associated documentation files (the "Software"), to deal |
||||
software to the public domain. We make this dedication for the benefit |
in the Software without restriction, including without limitation the rights |
||||
of the public at large and to the detriment of our heirs and |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
successors. We intend this dedication to be an overt act of |
copies of the Software, and to permit persons to whom the Software is |
||||
relinquishment in perpetuity of all present and future rights to this |
furnished to do so, subject to the following conditions: |
||||
software under copyright law. |
|
||||
|
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
The above copyright notice and this permission notice shall be included in |
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
all copies or substantial portions of the Software. |
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
||||
OTHER DEALINGS IN THE SOFTWARE. |
|
||||
|
|
||||
For more information, please refer to <https://unlicense.org> |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
#### ENDS LICENSE |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
### Add the below to any code (commented obviously) |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
THE SOFTWARE. |
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
||||
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
||||
# OTHER DEALINGS IN THE SOFTWARE. |
|
@ -1,11 +0,0 @@ |
|||||
FROM alpine:3.10 |
|
||||
|
|
||||
RUN apk add --no-cache curl jq |
|
||||
|
|
||||
RUN mkdir /lnd/ |
|
||||
|
|
||||
COPY unlock.sh /bin/unlock |
|
||||
|
|
||||
RUN chmod +x /bin/unlock |
|
||||
|
|
||||
ENTRYPOINT ["unlock"] |
|
@ -1,57 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
|
|
||||
HOST=localhost:8080 |
|
||||
TLS_CERT=/lnd/tls.cert |
|
||||
LNDPASSWORD_PATH=/secrets/lnd-password.txt |
|
||||
MACAROON_PATH=/lnd/data/chain/bitcoin/mainnet/admin.macaroon |
|
||||
|
|
||||
lncurl() { |
|
||||
MACAROON="$(xxd -p /lnd/data/chain/bitcoin/mainnet/admin.macaroon | tr -d '\n')" |
|
||||
url_path=$1 |
|
||||
data=$2 |
|
||||
|
|
||||
curl --fail --silent --show-error \ |
|
||||
--cacert "${TLS_CERT}" \ |
|
||||
--header "Grpc-Metadata-macaroon: ${MACAROON}" \ |
|
||||
--data "${data}" \ |
|
||||
"https://${HOST}/v1/${url_path}" |
|
||||
} |
|
||||
|
|
||||
while true; do |
|
||||
# First make sure that port is open |
|
||||
while ! nc -z localhost 8080; do |
|
||||
>&2 echo "Waiting for ${HOST} port to open…" |
|
||||
sleep 3 |
|
||||
done |
|
||||
>&2 echo "Port ${HOST} is open" |
|
||||
|
|
||||
# Wait a bit more in case the port was just opened |
|
||||
sleep 1 |
|
||||
if [[ -f $LNDPASSWORD_PATH ]]; then |
|
||||
if [[ -f $MACAROON_PATH ]]; then |
|
||||
>&2 echo "Password and macaroon file file exists" |
|
||||
PASS="$(cat /secrets/lnd-password.txt | tr -d '\n' | base64 | tr -d '\n')" |
|
||||
UNLOCK_PAYLOAD="$(jq -nc --arg wallet_password ${PASS} '{$wallet_password}')" |
|
||||
# Try getinfo then unlock |
|
||||
>&2 echo "Trying ${HOST}/getinfo…" |
|
||||
INFO=$(lncurl getinfo) |
|
||||
if [ "$?" = "0" ]; then |
|
||||
>&2 echo "Response: ${INFO}" |
|
||||
alias="$(echo "${INFO}" | jq '.alias')" |
|
||||
>&2 echo "Wallet for ${alias} unlocked!" |
|
||||
exit 0 |
|
||||
fi |
|
||||
>&2 echo "${HOST}/getinfo FAILED, out=${INFO}" |
|
||||
|
|
||||
>&2 echo "Trying ${HOST}/unlockwallet…" |
|
||||
RESULT=$(lncurl unlockwallet "${UNLOCK_PAYLOAD}") |
|
||||
>&2 echo "${HOST}/unlockwallet completed with: exit-code=$?, out=${RESULT}" |
|
||||
else |
|
||||
>&2 echo "macaroon file doesn't exist" |
|
||||
fi |
|
||||
else |
|
||||
>&2 echo "password file doesn't exist" |
|
||||
fi |
|
||||
|
|
||||
sleep 30 |
|
||||
done |
|
@ -1,17 +1,20 @@ |
|||||
server { |
server { |
||||
listen 80 default_server; |
listen 80 default_server; |
||||
listen [::]:80 default_server; |
listen [::]:80 default_server; |
||||
server_name _; |
server_name _; |
||||
root /etc/nginx/www; |
|
||||
index index.html; |
|
||||
|
|
||||
location / { |
|
||||
index index.html; |
|
||||
try_files $uri $uri/ /index.html; |
|
||||
} |
|
||||
|
|
||||
location /api/ { |
location /api/ { |
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; |
||||
proxy_pass http://localhost:3005/; |
proxy_pass http://localhost:3005/; |
||||
} |
} |
||||
} |
|
||||
|
location /manager-api/ { |
||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; |
||||
|
proxy_pass http://localhost:3006/; |
||||
|
} |
||||
|
|
||||
|
location / { |
||||
|
add_header Access-Control-Allow-Origin *; |
||||
|
proxy_pass http://localhost:3004/; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue