-
Notifications
You must be signed in to change notification settings - Fork 3
/
reset_env.sh
92 lines (76 loc) · 2.4 KB
/
reset_env.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
#!/bin/sh
# Variables
DataDIR=/tmp/data
ConfigDIR=/tmp/config
LogFile=/tmp/nodeos.log
# Show script info when launched
InfoMessage() {
echo "> Starting a fresh nodeos"
if grep -q Microsoft /proc/version; then
dir="$(where.exe README.md | sed 's=\\=\\\\=g'| sed 's/README.md/\src\:\/home\/src/' | sed 's/\r//')"
echo "Ubuntu on Windows: $dir"
else
dir="`pwd`/src:/home/src"
echo "native Linux: $dir"
fi
}
# Remove data and configuration files are used by local nodeos (not docker version)
RemoveLocalFiles() {
rm -fr $DataDIR
rm -fr $ConfigDIR
rm -f $LogFile
}
# Run local instance of keosd and nodeos
RunLocal() {
# Remove local files before go further
RemoveLocalFiles
# Kill already running keosd
pkill keosd
# Kill already running nodeos
pkill nodeos
# Start a new instance of keosd
keosd --http-server-address=0.0.0.0:5555 &
# Start a new instance of nodeos
nodeos -e -p eosio \
--plugin eosio::producer_plugin \
--plugin eosio::chain_api_plugin \
--plugin eosio::http_plugin \
--plugin eosio::history_plugin \
--plugin eosio::history_api_plugin \
--data-dir $DataDIR \
--config-dir $ConfigDIR/tmp/config \
--access-control-allow-origin=* \
--contracts-console \
--http-validate-host=false \
--http-server-address=0.0.0.0:7777 \
--filter-on='*' >> $LogFile 2>&1 &
}
# Run docker instance of keosd and nodeos
RunDocked() {
echo "Starting local"
# Stop running eosio docker container
docker stop eosio
# Remove eosio docker container
docker rm -f eosio
# Pull eosio image or a repository from a registry
docker pull eosio/eos:v1.5.0
# Run keosd and nodeos inside the docker environment
docker run --name eosio \
--publish 7777:7777 \
--volume "${dir}" \
--detach \
eosio/eos:v1.5.0 \
/bin/bash -c \
"keosd --http-server-address=0.0.0.0:5555 & exec nodeos -e -p eosio --plugin eosio::producer_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_plugin --plugin eosio::history_api_plugin --plugin eosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config --http-server-address=0.0.0.0:7777 --access-control-allow-origin=* --contracts-console --http-validate-host=false --filter-on='*'"
}
# Show program info message
InfoMessage
RunLocal
# For some reason the options fail, skipping them
# Restart keosd and nodeos using local instance or docked instance
# while getopts "ld" opts; do
# case ${opts} in
# l) RunLocal ;;
# d) RunDocked ;;
# esac
# done