forked from mempool/mempool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmempool-upgrade-all
executable file
·75 lines (62 loc) · 2.13 KB
/
mempool-upgrade-all
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
67
68
69
70
71
72
73
74
75
#!/usr/local/bin/zsh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$HOME/bin
HOSTNAME=$(hostname)
LOCKFILE="${HOME}/lock"
REF=$(echo "${1:=origin/master}"|sed -e 's!:!/!')
if [ -f "${LOCKFILE}" ];then
echo "upgrade already running? check lockfile ${LOCKFILE}"
exit 1
fi
trap 'rm -f "${LOCKFILE}"; exit $?' INT TERM EXIT
touch "${LOCKFILE}"
echo "Upgrading mempool to ${REF}" | wall
update_repo()
{
local site="$1"
echo "[*] Upgrading ${site} to ${REF}"
cd "$HOME/${site}" || exit 1
git fetch origin || exit 1
for remote in mempool MiguelMedeiros knorrium;do
git remote add "${remote}" "https://github.com/${remote}/mempool" >/dev/null 2>&1
git fetch "${remote}" || exit 1
done
if [ $(git tag -l "${REF}") ];then
git reset --hard "tags/${REF}" || exit 1
else
git reset --hard "${REF}" || exit 1
fi
export HASH=$(git rev-parse HEAD)
}
build_frontend()
{
local site="$1"
echo "[*] Building frontend for ${site}"
[ -z "${HASH}" ] && exit 1
cd "$HOME/${site}/frontend" || exit 1
npm install --no-optional || exit 1
npm run build || exit 1
}
build_backend()
{
local site="$1"
echo "[*] Building backend for ${site}"
[ -z "${HASH}" ] && exit 1
cd "$HOME/${site}/backend" || exit 1
npm install --no-optional || exit 1
npm run build || exit 1
}
ship_frontend()
{
local site="$1"
cd "$HOME/${site}/frontend" || exit 1
rsync -av ./dist/mempool/browser/* "${HOME}/public_html/${site}/" || exit 1
}
export NVM_DIR="${HOME}/.nvm"
source "${NVM_DIR}/nvm.sh"
for target in mainnet liquid bisq testnet signet;do update_repo "${target}";done
for target in mainnet liquid bisq testnet signet;do build_backend "${target}";done
for target in mainnet liquid bisq;do build_frontend "${target}";done
for target in mainnet liquid bisq;do ship_frontend "${target}";done
echo "${HOSTNAME} updated to \`${REF}\` @ \`${HASH}\`" | /usr/local/bin/keybase chat send --nonblock --channel general mempool.dev
echo "${HOSTNAME} updated to \`${REF}\` @ \`${HASH}\`" | /usr/local/bin/keybase chat send --nonblock --channel general mempool.ops
exit 0