forked from Snipa22/xmr-node-proxy
-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·46 lines (36 loc) · 1.35 KB
/
update.sh
File metadata and controls
executable file
·46 lines (36 loc) · 1.35 KB
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
#!/bin/bash
set -euo pipefail
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
if [[ ! -f "$ROOT_DIR/package.json" || ! -f "$ROOT_DIR/proxy.js" ]]; then
echo "Run update.sh from an xmr-node-proxy checkout."
exit 1
fi
cd "$ROOT_DIR"
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "update.sh expects a git checkout."
exit 1
fi
OLD_REV=$(git rev-parse --short HEAD)
echo "Resetting local checkout to origin/master and removing untracked files."
git fetch --prune origin
# This script is intentionally destructive: it hard-resets tracked files and removes untracked repo files
# so the checkout matches origin/master before dependencies are reinstalled and tests are rerun.
git reset --hard origin/master
git clean -fd
rm -f package-lock.json
npm install --no-audit --no-fund --no-package-lock
npm test
NEW_REV=$(git rev-parse --short HEAD)
if [[ "$OLD_REV" == "$NEW_REV" ]]; then
echo "Proxy is already up to date at $NEW_REV."
else
echo "Proxy updated from $OLD_REV to $NEW_REV."
fi
echo "Update verification passed."
if command -v pm2 >/dev/null 2>&1; then
echo "Restart the running proxy with the correct PM2 process name, for example:"
echo " pm2 restart xnp"
echo "Use 'pm2 list' if your process name is different."
else
echo "Restart the running proxy with your usual service manager or shell command."
fi