-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.sh
More file actions
125 lines (102 loc) · 3.16 KB
/
index.sh
File metadata and controls
125 lines (102 loc) · 3.16 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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
function remove_images() {
image_repos=(
ghcr.io/vulpemventures/elements
ghcr.io/vulpemventures/electrs
ghcr.io/vulpemventures/electrs-liquid
ghcr.io/vulpemventures/esplora
ghcr.io/vulpemventures/nigiri-chopsticks
ghcr.io/getumbrel/docker-bitcoind
lightninglabs/lnd
lightninglabs/taproot-assets
elementsproject/lightningd
ghcr.io/arkade-os/arkd-wallet
ghcr.io/arkade-os/arkd
)
for repo in ${image_repos[*]}; do
matching_images=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep "^${repo}:" 2>/dev/null || true)
if [ -n "$matching_images" ]; then
echo "$matching_images" | while read -r image; do
docker rmi "$image" 1>/dev/null && echo "successfully deleted $image" || true
done
fi
done
}
##/=====================================\
##| DETECT PLATFORM |
##\=====================================/
case $OSTYPE in
darwin*) OS="darwin" ;;
linux-gnu*) OS="linux" ;;
*)
echo "OS $OSTYPE not supported by the installation script"
exit 1
;;
esac
case $(uname -m) in
amd64) ARCH="amd64" ;;
arm64) ARCH="arm64" ;;
x86_64) ARCH="amd64" ;;
*)
echo "Architecture $ARCH not supported by the installation script"
exit 1
;;
esac
OLD_BIN="$HOME/bin"
BIN="/usr/local/bin"
##/=====================================\
##| CLEAN OLD INSTALLATION |
##\=====================================/
if [ "$(command -v nigiri)" != "" ]; then
echo "Nigiri is already installed and will be deleted."
# check if Docker is running
if [ -z "$(docker info 2>&1 >/dev/null)" ]; then
:
else
echo
echo "Info: when uninstalling an old Nigiri version Docker must be running."
echo
echo "Be sure to start the Docker daemon before launching this installation script."
echo
#exit 1
fi
echo "Stopping Nigiri..."
if [ -z "$(nigiri stop --delete &>/dev/null)" ]; then
:
fi
echo "Removing Nigiri..."
sudo rm -f $BIN/nigiri
sudo rm -f $OLD_BIN/nigiri
sudo rm -rf ~/.nigiri
echo "Removing local images..."
remove_images
fi
##/=====================================\
##| FETCH LATEST RELEASE |
##\=====================================/
NIGIRI_URL="https://github.com/vulpemventures/nigiri/releases"
LATEST_RELEASE_URL="$NIGIRI_URL/latest"
echo "Fetching $LATEST_RELEASE_URL..."
TAG=$(curl -sL -H 'Accept: application/json' $LATEST_RELEASE_URL | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
echo "Latest release tag = $TAG"
RELEASE_URL="$NIGIRI_URL/download/$TAG/nigiri-$OS-$ARCH"
echo "Fetching $RELEASE_URL..."
curl -sL $RELEASE_URL >nigiri
echo "Moving binary to $BIN..."
sudo mv nigiri $BIN
echo "Setting binary permissions..."
sudo chmod +x $BIN/nigiri
echo "Checking for Docker and Docker compose..."
if [ "$(command -v docker)" == "" ]; then
echo "Warning: Nigiri uses Docker and it seems not to be installed, check the official documentation for downloading it."
if [ "$OS" = "darwin" ]; then
echo "https://docs.docker.com/v17.12/docker-for-mac/install/#download-docker-for-mac"
else
echo "https://docs.docker.com/v17.12/install/linux/docker-ce/ubuntu/"
fi
fi
echo ""
echo "🍣 Nigiri Bitcoin installed!"