forked from PeerAssets/pacli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre_pacli_env
executable file
·54 lines (43 loc) · 1.56 KB
/
pre_pacli_env
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
#!/bin/bash -i
. pacli_env_config
#silently starting slimcoind
eval "$slm &>/dev/null"
wait
sleep 1
#starting pacli shel itself
echo " Welcome to the PACLI shell! "
while read -e -s -p 'pacli > ' line
do
#what to do in case "exit" command
if [[ $line == "exit" ]]; then
eval "$slm stop" &>/dev/null
wait
sleep 1
killall restart_stuck_slimcoind &> /dev/null
exit 1
fi
#prepending of the path to pacli and pacli command to the inputted command
line=$path_to_pacli" "$line
#checking whehter slimcoind has been started if not after 15 seconds it's beeing started again
running_slimcoind=$(eval "$slm getinfo 2>&1")
i=1
while [[ "$running_slimcoind" == "error: couldn't connect to server" ]]
do
sleep $i
if [[ $i -eq 5 ]]; then
eval "$slm &>/dev/null && wait && sleep 5"
break
fi
((i++))
running_slimcoind=$(eval "$slm getinfo 2>&1")
done
#executing the prepended command
eval "$line"
#controlling whether slimcoind is stuck
case "$line" in *"send"*[0-9]* | *"burn"*[0-9]* | *"claim"*[0-9]* )
eval "./restart_stuck_slimcoind $slm &"
#dettaching ./restart_stuck_sllimcoind in order to possibly kill it later on the closing of pacli without any output:
disown -r
;;
esac
done