This repository has been archived by the owner on Oct 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-new-network.sh
103 lines (81 loc) · 3.93 KB
/
run-new-network.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
#/bin/bash
#set -xv
clear
DATETIME="`date '+%Y%m%d%H%M%S'`"
DEV_LOGS=/tmp/baby-fleming-logs-for-devs
TEST_RUN_LOG=$DEV_LOGS-$DATETIME
WD=/home/$USER/.safe/vault
SAFE_AUTH_PASSWORD="aaaaa"
SAFE_AUTH_PASSPHRASE="aaaaa"
VAULT_RUN_CMD="safe vault run-baby-fleming"
echo "==================================================================================="
echo "= ="
echo "= This will set up a new Baby Fleming network on your computer. ="
echo "= ="
echo "= Existing logs will be timestamped and archived and the old vaults DELETED ="
echo "= ="
read -p "= Are you entirely sure about this? (y/N) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
then
# Save existing logs, if any
if [[ ! -e $DEV_LOGS ]]; then
mkdir -p $DEV_LOGS
elif [[ ! -d $DEV_LOGS ]]; then
echo $DEV_LOGS " already exists but is not a directory" 1>&2
fi
read -p "= Do you require enhanced logging? (y/N) " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
VAULT_RUN_CMD="safe vault run-baby-fleming -y"
fi
echo ""
# set up the destination for this test run logs
mkdir -p $TEST_RUN_LOG
# copy the individual vault logs
for i in genesis 2 3 4 5 6 7
do
cp /home/$USER/.safe/vault/baby-fleming-vaults/safe-vault-$i/safe_vault.log $TEST_RUN_LOG/safe-vault${DATETIME}-$i.log
done
# copy the auth log and store it beside the vault logs
#cp /home/$USER/.safe/authd/logs/safe-authd.* $TEST_RUN_LOG/
echo " Existing logs (if any) Have been backed up to /tmp "
# create login creds
cd $WD
echo "{ \"passphrase\":\"$SAFE_AUTH_PASSPHRASE\", \"password\":\"$SAFE_AUTH_PASSWORD\" }" > $WD/myconfig.json
# Clean up
safe vault killall
rm -rf baby-fleming-vaults
#rm -v ../authd/logs/safe-authd.out
#rm -v ../authd/logs/safe-authd.err
# OK Do stuff .......
# -y &&
echo "=============================================================================="
echo "Waiting for the network to initialise - won't be long :-)"
echo ""
echo ""
echo "=============================================================================="
$VAULT_RUN_CMD &&
sleep 10s && #let the section start up properly before doing anything else
echo "=============================================================================="
echo " ok thats long enough - get on with it then"
echo "=============================================================================="
safe networks add my-network &&
safe networks switch my-network &&
safe auth restart &&
safe auth create-acc --test-coins -c $WD/myconfig.json &&
safe auth login --self-auth -c $WD/myconfig.json &&
safe auth status
# TODO: error checking here
# if we got this far, it's probably worked - report success
# Not necessarily true yet :-(
echo "==================================================================================="
echo "= ="
echo "= Your new Baby Fleming test network is running ="
echo "= ="
echo "= Logs from the previous run are saved in a timestamped directory in /tmp ="
echo "= ="
echo "= Have fun !! ="
echo "= ="
echo "==================================================================================="
fi