-
Notifications
You must be signed in to change notification settings - Fork 8
/
entrypoint.sh
executable file
·128 lines (105 loc) · 3.13 KB
/
entrypoint.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
128
#!/usr/bin/env bash
sudo chown -R node:node /home/node
sudo chown -R node:node /usr/src/app
sudo ln -s /usr/src/app /home/node/app/validator
sleep 10;
echo "Install PM2"
npm i -g pm2
echo "/home/node/.pm2/logs/*.log /home/node/app/cli/build/logs/*.log {
daily
rotate 7
compress
delaycompress
missingok
notifempty
create 0640 user group
sharedscripts
postrotate
pm2 reloadLogs
endscript
}" | sudo tee /etc/logrotate.d/pm2
# Pull latest versions of the CLI and GUI
# Pull latest versions of the CLI and GUI from gui-updates branch
git clone https://github.com/shardeum/validator-cli.git cli
echo "Install the CLI"
cd cli
npm i --silent && npm link
cd ..
git clone https://github.com/shardeum/validator-gui.git gui
echo "Install the GUI"
cd gui
npm i --silent
npm run build
#openssl req -x509 -nodes -days 99999 -newkey rsa:2048 -keyout ./selfsigned.key -out selfsigned.crt -subj "/C=US/ST=Texas/L=Dallas/O=Shardeum/OU=Shardeum/CN=shardeum.org"
# if CA.cnf does not exist, create it
if [ ! -f "CA.cnf" ]; then
echo "[ req ]
prompt = no
distinguished_name = req_distinguished_name
[ req_distinguished_name ]
C = XX
ST = Localzone
L = localhost
O = Certificate Authority Local Validator Node
OU = Develop
CN = mynode-sphinx.sharedum.local
emailAddress = [email protected]" > CA.cnf
fi
# if CA.key does not exist, create it
if [ ! -f "CA_key.pem" ]; then
openssl req -nodes -new -x509 -keyout CA_key.pem -out CA_cert.pem -days 1825 -config CA.cnf
fi
# if selfsigned.cnf does not exist, create it
if [ ! -f "selfsigned.cnf" ]; then
echo "[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
req_extensions = req_ext
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
countryName = XX
stateOrProvinceName = Localzone
localityName = Localhost
organizationName = Shardeum Sphinx 1.x Validator Cert.
commonName = localhost
[req_ext]
subjectAltName = @alt_names
[v3_req]
subjectAltName = @alt_names
[alt_names]
IP.1 = $SERVERIP
IP.2 = $LOCALLANIP
DNS.1 = localhost" > selfsigned.cnf
fi
# if csr file does not exist, create it
if [ ! -f "selfsigned.csr" ]; then
openssl req -sha256 -nodes -newkey rsa:4096 -keyout selfsigned.key -out selfsigned.csr -config selfsigned.cnf
fi
# if selfsigned.crt does not exist, create it
if [ ! -f "selfsigned_node.crt" ]; then
openssl x509 -req -days 398 -in selfsigned.csr -CA CA_cert.pem -CAkey CA_key.pem -CAcreateserial -out selfsigned_node.crt -extensions req_ext -extfile selfsigned.cnf
fi
# if selfsigned.crt does not exist, create it
if [ ! -f "selfsigned.crt" ]; then
cat selfsigned_node.crt CA_cert.pem > selfsigned.crt
fi
cd ../..
# Start GUI if configured to in env file
echo $RUNDASHBOARD
if [ "$RUNDASHBOARD" == "y" ]
then
echo "Starting operator gui"
# Call the CLI command to set the GUI password
operator-cli gui set password -h $DASHPASS
# Call the CLI command to set the GUI port
operator-cli gui set port $DASHPORT
# Call the CLI command to start the GUI
operator-cli gui start
fi
# Deprecated
# operator-cli set external_port $SHMEXT
# operator-cli set internal_port $SHMINT
echo "done";
# Keep container running
tail -f /dev/null