forked from dannyti/seedbox-from-scratch
-
Notifications
You must be signed in to change notification settings - Fork 4
/
createEthereumCPPUserInstall
executable file
·58 lines (45 loc) · 1.71 KB
/
createEthereumCPPUserInstall
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
#!/bin/bash
# Hellish Tech
# No commercial usage without authorization
exec 1> >(logger -s -t $(basename $0)) 2>&1
docker pull ethereum/client-go
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-u|--username)
USERNAME="$2"
shift # past argument
;;
*)
# unknown option
;;
esac
shift # past argument or value
done
SYSTEMHOSTNAME=`cat /etc/seedbox-from-scratch/hostname.info`
PORT1=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 30304 -ep 30403)
PORT2=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 8546 -ep 8645)
USERUID=$(id -u ${USERNAME})
USERGID=$(id -g ${USERNAME})
if [ ! -d "/home/${USERNAME}/.ethereum" ]; then
mkdir -p /home/${USERNAME}/.ethereum
fi
if [ ! -d "/home/${USERNAME}/.web3" ]; then
mkdir -p /home/${USERNAME}/.web3
fi
docker pull ethereum/client-go
docker run --restart=always -d --name ${USERNAME}_ethereumcpp -h ${SYSTEMHOSTNAME} -v /home/${USERNAME}/.ethereum:/root/.ethereum -v /home/${USERNAME}/.web3:/.web3 -p ${PORT1}:30303 -p ${PORT2}:8545 ethereum/client-go
sleep 5
CHECKIFRUNNING=$(/etc/seedbox-from-scratch/sfsRunningUserDockerInfo -u ${USERNAME} -d ethereumcpp | tr -cd '[[:alnum:]]._-' )
if [[ (${CHECKIFRUNNING} == "STOPPED") || (${CHECKIFRUNNING} == "RUNNING") ]]; then
echo "SERVICE: ethereumcpp" > /home/${USERNAME}/private/ethereumcpp.serviceinfo
echo "USERNAME: $USERNAME" >> /home/${USERNAME}/private/ethereumcpp.serviceinfo
echo "PORT1: $PORT1" >> /home/${USERNAME}/private/ethereumcpp.serviceinfo
echo "PORT2: $PORT2" >> /home/${USERNAME}/private/ethereumcpp.serviceinfo
chown www-data:www-data /home/${USERNAME}/private/*.serviceinfo
fi
if [[ -n $1 ]]; then
echo "Last line of file specified as non-opt/last argument:"
tail -1 $1
fi