forked from Someguy123/steem-rpc-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·127 lines (114 loc) · 5.63 KB
/
run.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
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
126
127
#!/usr/bin/env bash
#############################################################################
# #
# Production runner script for: #
# #
# Hive/Steem RPC Scanner #
# (C) 2020 Someguy123. GNU AGPL v3 #
# #
# Someguy123 Blog: https://peakd.com/@someguy123 #
# Privex Site: https://www.privex.io/ #
# #
# Github Repo: https://github.com/Someguy123/steem-rpc-scanner #
# #
#############################################################################
BOLD="" RED="" GREEN="" YELLOW="" BLUE="" MAGENTA="" CYAN="" WHITE="" RESET=""
if [ -t 1 ]; then BOLD="$(tput bold)" RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" RESET="$(tput sgr0)"; fi
OUR_APP="Hive/Steem RPC Scanner" GH_REPO="https://github.com/Someguy123/steem-rpc-scanner"
# Error handling function for ShellCore
_sc_fail() { echo >&2 -e "\n${BOLD}${RED} [!!!] Failed to load or install Privex ShellCore...${RESET}\n\n" && exit 1; }
# Run ShellCore auto-install if we can't detect an existing ShellCore load.sh file.
[[ -f "${HOME}/.pv-shcore/load.sh" ]] || [[ -f "/usr/local/share/pv-shcore/load.sh" ]] ||
{
echo -e "${GREEN} >>> Auto-installing Privex ShellCore ( https://github.com/Privex/shell-core ) ...${RESET}"
curl -fsS https://cdn.privex.io/github/shell-core/install.sh | bash >/dev/null
echo -e "${BOLD}${GREEN} [+++] ShellCore successfully installed :)${RESET}"
} || _sc_fail
# Attempt to load the local install of ShellCore first, then fallback to global install if it's not found.
[[ -d "${HOME}/.pv-shcore" ]] && source "${HOME}/.pv-shcore/load.sh" ||
source "/usr/local/share/pv-shcore/load.sh" || _sc_fail
# Quietly automatically update Privex ShellCore every 14 days (default)
autoupdate_shellcore
######
# Directory where the script is located, so we can source files regardless of where PWD is
######
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:${PATH}"
export PATH="${HOME}/.local/bin:${PATH}"
export PYTHONUNBUFFERED=1 PIPENV_VERBOSITY=-1
cd "$DIR"
[[ -f .env ]] && source .env || true
# Override these defaults inside of `.env`
#: ${HOST='127.0.0.1'}
#: ${PORT='8484'}
#: ${GU_WORKERS='10'} # Number of Gunicorn worker processes
[[ -f "${DIR}/nodes.conf" ]] || {
msg green " >> Copying example.nodes.conf -> nodes.conf"
cp -v "${DIR}/example.nodes.conf" "${DIR}/nodes.conf"
} >&2
case "$1" in
health | HEALTH | check | CHECK)
pipenv run ./health.py "${@:2}"
exit $?
;;
scan | SCAN | list | LIST | rpcs | RPCS | all | ALL)
pipenv run ./app.py "${@:2}"
exit $?
;;
api | test_meth | testmeth | test-meth | meth | method | testmethod | test_method | test-method)
pipenv run ./health.py test_method "${@:2}"
exit $?
;;
apis | test_meths | testmeths | test-meths | meths | methods | testmethods | test_methods | test-methods)
pipenv run ./health.py test_methods "${@:2}"
exit $?
;;
update | upgrade)
msg ts bold green " >> Updating files from Github"
git pull
msg ts bold green " >> Updating Python packages"
pipenv update --ignore-pipfile
msg ts bold green " +++ Finished"
echo
;;
install | setup | init)
msg ts bold green " >> Updating files from Github"
git pull
msg ts bold green " >> Installing any missing packages"
pkg_not_found python3 python3.8
pkg_not_found python3 python3.7
pkg_not_found python3 python3
pkg_not_found pip3 python3.8-pip
pkg_not_found pip3 python3.7-pip
pkg_not_found pip3 python3-pip
if not has_command pipenv; then
PY_VER=""
[ -z "$PY_VER" ] && has_binary python3.8 && PY_VER="python3.8" || true
[ -z "$PY_VER" ] && has_binary python3.7 && PY_VER="python3.7" || true
[ -z "$PY_VER" ] && PY_VER="python3" || true
sudo -H "$PY_VER" -m pip install -U pipenv
fi
msg ts bold green " >> Creating virtualenv / Installing Python packages"
pipenv install --ignore-pipfile
[[ -f "${DIR}/nodes.conf" ]] || {
msg ts green " >> Copying example.nodes.conf -> nodes.conf"
cp -v "${DIR}/example.nodes.conf" "${DIR}/nodes.conf"
}
msg
msg ts bold green " +++ Finished"
echo
;;
*)
echo "Runner script for Someguy123's $OUR_APP"
echo ""
msg bold red "Unknown command.\n"
msg bold green "$OUR_APP - (C) 2020 Someguy123 / Privex Inc."
msg bold green " Website: https://www.privex.io/ \n Source: ${GH_REPO}\n"
msg green "Available run.sh commands:\n"
msg yellow "\t health [-q|-v] [scan|list] [-d] (rpc) - Return health data for an individual RPC, " \
"or all RPCs listed in the node list config file"
msg yellow "\t scan|list [-q|-v|--plugins] [-f nodes.conf] - Scan all RPCs in the node list config, " \
"outputting their status information with a pretty printed colourful table."
msg
;;
esac