Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions client/html/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@
<meta name="twitter:title" content="{[{ .siteName }]}" />
<meta property="twitter:description" content="{[{ .description }]}" />
<meta property="twitter:image" content="{[{ .logo }]}" />
<meta name="software-version" content="{[{ .binaryVersion }]}" />
<link rel="shortcut icon" href="{[{ .favicon }]}" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="/resources/site.css"/>
{[{ if .brand }]}
<style type="text/css">
.watermark-brand {
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='100px' width='300px' opacity='0.05'><text transform='translate(20, 100) rotate(-25)' fill='rgb(245,45,45)' font-size='46'>{[{ .brand }]}</text></svg>");
}
.brandLink {
text-decoration: none;
color: inherit;
opacity: .3;
}
</style>
{[{ end }]}
</head>
<body class="watermark-brand">
<div id="main" class="container">
<h3 class="mt-3">{[{ .description }]}</h3>
<div id="main" class="container my-3">
<h3>{[{ .description }]}</h3>
{[{ if .logo }]}
<div class="m-3">
<img class="mini-chain-logo" src="{[{ .logo }]}" alt="logo" />
Expand Down Expand Up @@ -58,10 +62,11 @@
<div id="collapseLivePeers" class="accordion-collapse collapse show" aria-labelledby="headingLivePeers" data-bs-parent="#accordionMain">
<div class="card card-body">
{[{ if gt .livePeersCount 0 }]}
<p class="text-secondary">{[{ .livePeersCount }]} real-time live peers from our node:</p>
<div>{[{ .livePeersCount }]} live peers:</div>
<div class="text-secondary"><i>real-time data from our node</i></div>
<pre class="border p-2"><code>{[{ .livePeers }]}</code></pre>
{[{ else }]}
<h3 class="text-danger">Live peers temporary not available</h3>
<h3 class="text-danger">Live peers list is temporary not available</h3>
{[{ end }]}
</div>
</div>
Expand All @@ -76,7 +81,7 @@
<div class="card card-body">
{[{ if gt .livePeersCount 0 }]}
<p>Download: <a href="/download/addrbook.json">addrbook.json</a></p>
<pre class="border p-2"><code>wget -O addrbook.json https://{[{ .host }]}/download/addrbook.json --inet4-only
<pre class="border p-2"><code>wget -O addrbook.json https://{[{ .host }]}/download/addrbook.json
mv addrbook.json $HOME/{[{ .generalNodeHomeName }]}/config</code></pre>
{[{ else }]}
<h3 class="text-danger">Addrbook temporary not available</h3>
Expand Down Expand Up @@ -112,7 +117,7 @@ mv addrbook.json $HOME/{[{ .generalNodeHomeName }]}/config</code></pre>
<pre class="border p-2"><code>cp $HOME/{[{ .generalNodeHomeName }]}/data/priv_validator_state.json $HOME/{[{ .generalNodeHomeName }]}/priv_validator_state.json</code></pre>
<p class="text-secondary">Verify <b>`priv_validator_key.json`</b> and the backup are equals</p>
<pre class="border p-2"><code>sleep 10 &amp;&amp; cat $HOME/{[{ .generalNodeHomeName }]}/data/priv_validator_state.json &amp;&amp; cat $HOME/{[{ .generalNodeHomeName }]}/priv_validator_state.json</code></pre>
<p>Reset your node</p>
<p>Reset data of the node</p>
<pre class="border p-2"><code>{[{ .generalBinaryName }]} tendermint unsafe-reset-all --home $HOME/{[{ .generalNodeHomeName }]} --keep-addr-book</code></pre>
<p>Decompress the snapshot to your database location. Your database location under <b>`{[{ .generalNodeHomeName }]}/data`</b> or something like that, depending on the node implementation.</p>
<pre class="border p-2"><code>lz4 -c -d {[{ .snapshot.FileName }]} | tar -x -C $HOME/{[{ .generalNodeHomeName }]}/data</code></pre>
Expand Down Expand Up @@ -153,11 +158,13 @@ mv addrbook.json $HOME/{[{ .generalNodeHomeName }]}/config</code></pre>
<p class="text-warning">Do not state-sync a validator node, instead state-sync a full-node and move data to validator node. Be sure backup and restore <b>`priv_validator_key.json`</b></p>
<p>Our state-sync RPC server for {[{ .chainName }]} is</p>
<pre class="border p-2"><code>{[{ .rpcUrl }]}</code></pre>
<p>
Create a reusable shell script such as <b>`state_sync.sh`</b> with the following code.
The code will fetch important state-sync information (such as block height and trust hash)
from our server and update your <b>`config.toml`</b> file accordingly.
</p>
<div>
<div>Prepare a reusable script <b>`state_sync.sh`</b> with the following code.</div>
<div class="text-secondary">
<i>The code will fetch important state-sync information (such as block height and trust hash)
from RPC server and update your <b>`config.toml`</b> file accordingly.</i>
</div>
</div>
<pre class="border p-2"><code>#!/bin/bash

SNAP_RPC="{[{ .rpcUrl }]}"
Expand All @@ -175,7 +182,7 @@ s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/{[{ .gener
{[{ end }]}
<p>Stop the node</p>
<pre class="border p-2"><code>sudo systemctl stop {[{ .generalBinaryName }]}</code></pre>
<p>Reset the node</p>
<p>Reset data of the node</p>
<pre class="border p-2"><code>{[{ .generalBinaryName }]} tendermint unsafe-reset-all --home $HOME/{[{ .generalNodeHomeName }]} --keep-addr-book</code></pre>
<p>Execute the script</p>
<pre class="border p-2"><code>sh state_sync.sh</code></pre>
Expand All @@ -186,6 +193,13 @@ s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/{[{ .gener
</div>
</div>
</div>
<footer class="container mb-3 d-flex align-items-center justify-content-center">
{[{ if eq .brand "Valoper.io" }]}
<div><a class="brandLink" href="{[{ .brandLink }]}">Operating by {[{ .brand }]} with 🛡 and 💛️</a></div>
{[{ else }]}
<div><a class="brandLink" href="{[{ .brandLink }]}">Powered by {[{ .brand }]}</a></div>
{[{ end }]}
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion client/statik/statik.go

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion services/web_server/handle_web_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package web_server

import (
"fmt"
"github.com/bcdevtools/node-management/constants"
webtypes "github.com/bcdevtools/node-management/services/web_server/types"
"github.com/bcdevtools/node-management/types"
"github.com/bcdevtools/node-management/utils"
Expand All @@ -23,7 +24,7 @@ func HandleWebIndex(c *gin.Context) {
var livePeers string
var livePeersCount int

peers, err := getLivePeers(w.Config())
peers, err := getLivePeers(cfg)
if err != nil {
utils.PrintlnStdErr("ERR: failed to get live peers:", err)
} else {
Expand All @@ -37,6 +38,10 @@ func HandleWebIndex(c *gin.Context) {

snapshotInfo := getSnapshotInfo(cfg)

if snapshotInfo.Error != nil && cfg.Debug {
utils.PrintlnStdErr("ERR: failed to get snapshot info:", snapshotInfo.Error)
}

var chainDescriptionLines []string
if cfg.ChainDescription != "" {
chainDescriptionLines = strings.Split(cfg.ChainDescription, "\\n")
Expand All @@ -48,6 +53,7 @@ func HandleWebIndex(c *gin.Context) {
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"host": c.Request.Host,
"brand": cfg.Brand,
"brandLink": fmt.Sprintf("https://%s", strings.TrimPrefix(strings.TrimPrefix(strings.TrimPrefix(cfg.Brand, "://"), "http://"), "https://")),
"title": fmt.Sprintf("%s snapshot by %s", cfg.ChainName, cfg.Brand),
"description": fmt.Sprintf("Snapshot data, live-peers, addrbook for %s by %s", cfg.ChainName, cfg.Brand),
"chainName": cfg.ChainName,
Expand All @@ -64,6 +70,7 @@ func HandleWebIndex(c *gin.Context) {
"generalNodeHomeName": cfg.GeneralNodeHomeName,
"generalBinaryName": cfg.GeneralBinaryName,
"snapshot": snapshotInfo,
"binaryVersion": constants.VERSION,
})
}

Expand Down