-
Notifications
You must be signed in to change notification settings - Fork 30
/
install.sh
executable file
·83 lines (71 loc) · 1.76 KB
/
install.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
# shellcheck disable=SC2016
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Installs Bitcoin scripts."
echo "Usage: $(basename "$0")"
exit
fi
PREFIX="/opt/bitcoin-scripts"
if [[ "$(whoami)" == "root" ]]; then
sudo=""
else
sudo="sudo"
fi
cd "$(dirname "$0")" || exit 1
$sudo mkdir -p "$PREFIX"
echo -n "Installing inc.common.sh..."
$sudo install -p -t "$PREFIX" -m 644 ./inc.common.sh
echo ""
DOC_LIST="
donation-address.txt.asc
README.md
"
for doc in $DOC_LIST; do
echo -n "Installing $doc..."
$sudo cp "$doc" "$PREFIX"
echo ""
done
SCRIPT_LIST="
blockheightat
checktransaction
estimatesmartfee
fake-coinjoin
listpossiblecjtxids
randbtc
ricochet-send-from
ricochet-send
timetoblocks
whitepaper
"
for script in $SCRIPT_LIST; do
echo -n "Installing bc-$script..."
$sudo install -p -t "$PREFIX" "./$script.sh"
$sudo ln -f -s "$PREFIX/$script.sh" "/usr/local/bin/bc-$script"
echo ""
done
echo -n "Creating bc-scripts-uninstall..."
$sudo bash -c 'cat <<EOF > '"$PREFIX/bc-scripts-uninstall.sh"'
#!/usr/bin/env bash
if [[ "\$(whoami)" == "root" ]]; then
sudo=""
else
sudo="sudo"
fi
PREFIX="'"$PREFIX"'"
SCRIPT_LIST="'"$SCRIPT_LIST"'"
read -n 1 -p "This will uninstall bitcoin-scripts from \$PREFIX. Are you sure? (y/N) "
echo ""
if [[ \${REPLY} =~ y|Y ]]; then
for script in \$SCRIPT_LIST; do
echo -n "Uninstalling bc-\$script..."
\$sudo unlink /usr/local/bin/bc-\$script
echo ""
done
echo "Clean up rest..."
\$sudo rm -rf "\$PREFIX" 2> /dev/null
echo "Done."
fi
EOF'
$sudo chmod +x "$PREFIX/bc-scripts-uninstall.sh"
$sudo ln -f -s "$PREFIX/bc-scripts-uninstall.sh" /usr/local/sbin/bc-scripts-uninstall
echo "Done."