-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·68 lines (49 loc) · 1.69 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#/bin/bash -x
source ~/.nvm/nvm.sh
GODEBUG="netdns=go"
COMMIT_HASH="${COMMIT:-main}"
IPFS_BIN=/usr/local/bin/ifps
## Download IPFS binary
if [[ ! -f "$IPFS_BIN" ]]; then
wget https://dist-ipfs-tech.ipns.dweb.link/kubo/v0.14.0/kubo_v0.14.0_linux-amd64.tar.gz -O kubo.tar.gz
tar -xzvf kubo.tar.gz
kubo/install.sh
rm kubo.tar.gz
rm -rf kubo
fi
[ ! -d "./repo" ] && git clone --bare ${REPO} repo
cd repo
git checkout ${COMMIT_HASH}
## TODO: CHECK THE COMMIT HASH
# CURRENT_HASH=$(git rev-parse HEAD)
# [${CURRENT_HASH} != ${COMMIT_HASH} ]
## Upload to IPFS
git update-server-info
mv objects/pack/*.pack .
git unpack-objects < *.pack
rm -f *.pack objects/pack/*
ipfs --api=/dns/ipfs.dappnode/tcp/5001 add -r . --quiet | tee ../listHashes
REPO_IPFS_HASH=$(tail -1 ../listHashes)
curl --connect-timeout 5 \
--max-time 10 \
--retry 5 \
--retry-delay 0 \
--retry-max-time 40 \
-X POST "http://my.dappnode/data-send?key=RepoIPFSHash&data=http://ipfs.dappnode:8080/ipfs/${REPO_IPFS_HASH}" \
|| { echo "[ERROR] failed to post IPFS HASH to dappmanager"; }
npm i -g yarn
## Install dependencies
yarn
## Build static
yarn build:static
## Upload the UI to IPFS the
ipfs --api=/dns/ipfs.dappnode/tcp/5001 add -r out --quiet | tee ../listHashesUI
UI_IPFS_HASH=$(ipfs cid base32 $(tail -1 ../listHashesUI))
curl --connect-timeout 5 \
--max-time 10 \
--retry 5 \
--retry-delay 0 \
--retry-max-time 40 \
-X POST "http://my.dappnode/data-send?key=IPFS_URL&data=http://${UI_IPFS_HASH}.ipfs.ipfs.dappnode:8080/" \
|| { echo "[ERROR] failed to post the UI_IPFS_HASH IPFS to dappmanager"; }
yarn serve:static