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
129
130
131
132
133
134
135
136
|
// Copyright 2017 The go-ethereum Authors
// This file is part of go-ethereum.
//
// go-ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package main
import (
"fmt"
"github.com/ethereum/go-ethereum/log"
)
// deployDashboard queries the user for various input on deploying a web-service
// dashboard, after which is pushes the container.
func (w *wizard) deployDashboard() {
// Select the server to interact with
server := w.selectServer()
if server == "" {
return
}
client := w.servers[server]
// Retrieve any active dashboard configurations from the server
infos, err := checkDashboard(client, w.network)
if err != nil {
infos = &dashboardInfos{
port: 80,
host: client.server,
}
}
// Figure out which port to listen on
fmt.Println()
fmt.Printf("Which port should the dashboard listen on? (default = %d)\n", infos.port)
infos.port = w.readDefaultInt(infos.port)
// Figure which virtual-host to deploy the dashboard on
infos.host, err = w.ensureVirtualHost(client, infos.port, infos.host)
if err != nil {
log.Error("Failed to decide on dashboard host", "err", err)
return
}
// Port and proxy settings retrieved, figure out which services are available
available := make(map[string][]string)
for server, services := range w.services {
for _, service := range services {
available[service] = append(available[service], server)
}
}
listing := make(map[string]string)
for _, service := range []string{"ethstats", "explorer", "wallet", "faucet"} {
// Gather all the locally hosted pages of this type
var pages []string
for _, server := range available[service] {
client := w.servers[server]
if client == nil {
continue
}
// If there's a service running on the machine, retrieve it's port number
var port int
switch service {
case "ethstats":
if infos, err := checkEthstats(client, w.network); err == nil {
port = infos.port
}
case "faucet":
if infos, err := checkFaucet(client, w.network); err == nil {
port = infos.port
}
}
if page, err := resolve(client, w.network, service, port); err == nil && page != "" {
pages = append(pages, page)
}
}
// Promt the user to chose one, enter manually or simply not list this service
defLabel, defChoice := "don't list", len(pages)+2
if len(pages) > 0 {
defLabel, defChoice = pages[0], 1
}
fmt.Println()
fmt.Printf("Which %s service to list? (default = %s)\n", service, defLabel)
for i, page := range pages {
fmt.Printf(" %d. %s\n", i+1, page)
}
fmt.Printf(" %d. List external %s service\n", len(pages)+1, service)
fmt.Printf(" %d. Don't list any %s service\n", len(pages)+2, service)
choice := w.readDefaultInt(defChoice)
if choice < 0 || choice > len(pages)+2 {
log.Error("Invalid listing choice, aborting")
return
}
switch {
case choice <= len(pages):
listing[service] = pages[choice-1]
case choice == len(pages)+1:
fmt.Println()
fmt.Printf("Which address is the external %s service at?\n", service)
listing[service] = w.readString()
default:
// No service hosting for this
}
}
// If we have ethstats running, ask whether to make the secret public or not
var ethstats bool
if w.conf.ethstats != "" {
fmt.Println()
fmt.Println("Include ethstats secret on dashboard (y/n)? (default = yes)")
ethstats = w.readDefaultString("y") == "y"
}
// Try to deploy the dashboard container on the host
fmt.Println()
fmt.Printf("Should the dashboard be built from scratch (y/n)? (default = no)\n")
nocache := w.readDefaultString("n") != "n"
if out, err := deployDashboard(client, w.network, infos.port, infos.host, listing, &w.conf, ethstats, nocache); err != nil {
log.Error("Failed to deploy dashboard container", "err", err)
if len(out) > 0 {
fmt.Printf("%s\n", out)
}
return
}
// All ok, run a network scan to pick any changes up
w.networkStats()
}
|