Skip to content

Instantly share code, notes, and snippets.

@DrI-T
Last active July 21, 2021 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrI-T/e2daf2f97bc866405caf17a017ece611 to your computer and use it in GitHub Desktop.
Save DrI-T/e2daf2f97bc866405caf17a017ece611 to your computer and use it in GitHub Desktop.
webup.sh
## upload a website to IPFS
![bot](https://robohash.org/$qm$)
<style>img[alt=bot] { float: right; display: block; max-width: 24vw; }</style>
### initial setup
Get a simple flow to upload your website on the IPFS network
0. get a domain name
0. get IPFS running, create a websites keys : [$webkey$][1]
1. build your site w/ your usual build flow
2. run webup script
3. verify you get it correct at <$gw_url$/ipns/$webkey$/$site$>
4. add a TXT entry for \_dnslink to your domain's DNS : ``_dnslink=/ipns/$webkey$/$site$``
5. add a A record to your IPFS node
6. add a www CNAME record to our resolver
### update commande
1. run the webup script that's it !
### notes
All websites can be resolve by our resolver at :
<https://resolve.ml/>
## how doest it work ?
It create a [folder][4] named $site$ and attached it to the mutable key [websites][1],
It also add [/public/www/$site$][2] within your [mfs][3] file system.
As part of a blockRing this website refers to its [previous][5] version ($qmprev$)
[1]: https://ipfs.blockring™.ml/ipns/$webkey$
[2]: https://ipfs.blockring™.ml/ipns/$peerid$/public/www/$site$/
[3]: http://127.0.0.1:5001/webui/#/files/public/www/
[4]: $gw_url$/ipns/$webkey$/$site$/
[5]: $gw_url$/ipfs/$qmsite$/
### the script :
```sh
#
# peerid -> /root/www
# www -> /public/www
# www -> /my/websites
# /my/friends/user/websites
pwd=$$(pwd)
if top=$$(git rev-parse --show-toplevel); then
dirname=$${top##*/}
else
dirname=$${pwd##*/}
fi
site=$$dirname
intent="upload current folder or _site if present as a website $$site"
echo "--- # $${0##*/}"
peerid=$$(ipfs config Identity.PeerID)
echo "peerid: $$peerid"
symb=websites
if ! ipfs key list | grep -q -w $$symb; then
key=$$(ipfs key gen -t rsa -s 3072 $$symb --ipns-base=b58mh)
else
key=$$(ipfs key list -l --ipns-base=b58mh | grep -w $$symb | cut -d' ' -f1)
fi
echo key: $$key
echo site: $$site
if www=$$(ipfs resolve --recursive=true /ipns/$$key); then
qmwww=$${www##/ipfs/}
else
qmwww=$$(ipfs object new unixfs-dir)
www=/ipfs/$$qmwww
fi
echo qmwww: $$qmwww
cd $$top
find . -name '*~1' -delete
if [ ! -d _data ]; then mkdir _data; fi
if [ -d _site ]; then
qm=$$(ipfs add -r _site -Q)
else
qm=$$(ipfs add -r . -Q)
fi
echo qm: $$qm
ipfs ls $$www
if qmsite=$$(ipfs files stat $$www/$$site --hash 2>/dev/null); then
echo "--- # previous version for $$site" > _data/previous.yml
echo qmsite: $$qmsite >> _data/previous.yml
qmwww=$$(ipfs object patch rm-link $$qmwww $$site)
qmwww=$$(ipfs object patch add-link $$qmwww $$site $$qm)
else
qmwww=$$(ipfs object patch add-link $$qmwww $$site $$qm)
fi
if qmsite=$$(ipfs files stat /public/www/$$site --hash 2>/dev/null); then
ipfs files rm -r /public/www/$$site
fi
ipfs files cp /ipfs/$$qm /public/www/$$site
gwhost=$$(ipfs config Addresses.Gateway|cut -d'/' -f 3)
gwport=$$(ipfs config Addresses.Gateway|cut -d'/' -f 5)
gw_url="http://$$gwhost:$$gwport"
echo url: https://ipfs.blockring™.ml/ipfs/$$qmwww
echo url: $$gw_url/ipfs/$$qmwww
echo "publising on namesm.tk/$$symb"
ipfs name publish --key=$$symb /ipfs/$$qmwww
true; # $$Source: /my/shell/script/webup.sh $$ vim: syntax=sh
```
--- <br>
``$qm$``
#
symb=websites
pwd=$(pwd)
if top=$(git rev-parse --show-toplevel); then
dirname=${top##*/}
else
dirname=${pwd##*/}
fi
site=$dirname
peerid=$(ipfs config Identity.PeerID)
echo "peerid: $peerid"
gwhost=$(ipfs config Addresses.Gateway|cut -d'/' -f 3)
gwport=$(ipfs config Addresses.Gateway|cut -d'/' -f 5)
gw_url="http://$gwhost:$gwport"
webkey=$(ipfs key list -l --ipns-base=b58mh | grep -w $symb | cut -d' ' -f1)
echo "webkey: $webkey"
qmwww=$(ipfs name resolve $webkey)
qmprev=$(cat _data/previous.yml | json_xs -f yaml -t string -e '$_ = $_->{qmsite}')
tic=$(date +%s)
qm=$(ipfs add -r . -Q)
cat > meta.yml <<EOT
--- # metadata file
title: hostless website $site
tic: $tic
qm: $qm
site: $site
peerid: $peerid
webkey: $webkey
qmwww: $qmwww
qmprev: $qmprev
gw_url: $gw_url
EOT
pandoc --metadata-file meta.yml --metadata-file _data/previous.yml --template=README.md README.md |\
pandoc -s --metadata-file meta.yml -f markdown -o index.html
pandoc --metadata-file meta.yml --metadata-file _data/previous.yml --template=token.md token.md |\
pandoc -s --metadata-file meta.yml -f markdown -o token.html
qm=$(ipfs add -r . -Q)
echo url: $gw_url/ipfs/$qm
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>hostless website webup.tk</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
</head>
<body>
<header id="title-block-header">
<h1 class="title">hostless website webup.tk</h1>
</header>
<h2 id="upload-a-website-to-ipfs">upload a website to IPFS</h2>
<img src="https://robohash.org/QmbM9DTrpeZr8XYJbz4rdZQ92eWX1iWUQ5z6bWPSSCAxvy" title="fig:" alt="bot" />
<style>img[alt=bot] { float: right; display: block; max-width: 24vw; }</style>
<h3 id="initial-setup">initial setup</h3>
<p>Get a simple flow to upload your website on the IPFS network</p>
<ol start="0" type="1">
<li>get a domain name</li>
<li>get IPFS running, create a websites keys : <a href="https://ipfs.blockring™.ml/ipns/QmYwyK9VMxBKm1STUQ9jbYVz3ymAa4ULVLwpx8oHvSKAG2">QmYwyK9VMxBKm1STUQ9jbYVz3ymAa4ULVLwpx8oHvSKAG2</a></li>
<li>build your site w/ your usual build flow</li>
<li>run webup script</li>
<li>verify you get it correct at <a href="http://0.0.0.0:8390/ipns/QmYwyK9VMxBKm1STUQ9jbYVz3ymAa4ULVLwpx8oHvSKAG2/webup.tk" class="uri">http://0.0.0.0:8390/ipns/QmYwyK9VMxBKm1STUQ9jbYVz3ymAa4ULVLwpx8oHvSKAG2/webup.tk</a></li>
<li>add a TXT entry for _dnslink to your domain’s DNS : <code>_dnslink=/ipns/QmYwyK9VMxBKm1STUQ9jbYVz3ymAa4ULVLwpx8oHvSKAG2/webup.tk</code></li>
<li>add a A record to your IPFS node</li>
<li>add a www CNAME record to our resolver</li>
</ol>
<h3 id="update-commande">update commande</h3>
<ol type="1">
<li>run the webup script that’s it !</li>
</ol>
<h3 id="notes">notes</h3>
<p>All websites can be resolve by our resolver at :</p>
<p><a href="https://resolve.ml/" class="uri">https://resolve.ml/</a></p>
<h2 id="how-doest-it-work">how doest it work ?</h2>
<p>It create a <a href="http://0.0.0.0:8390/ipns/QmYwyK9VMxBKm1STUQ9jbYVz3ymAa4ULVLwpx8oHvSKAG2/webup.tk/">folder</a> named webup.tk and attached it to the mutable key <a href="https://ipfs.blockring™.ml/ipns/QmYwyK9VMxBKm1STUQ9jbYVz3ymAa4ULVLwpx8oHvSKAG2">websites</a>, It also add <a href="https://ipfs.blockring™.ml/ipns/QmcfHufAK9ErQ9ZKJF7YX68KntYYBJngkGDoVKcZEJyRve/public/www/webup.tk/">/public/www/webup.tk</a> within your <a href="http://127.0.0.1:5001/webui/#/files/public/www/">mfs</a> file system. As part of a blockRing this website refers to its <a href="http://0.0.0.0:8390/ipfs/QmeMgu8D4GHuYNQSqC1RbVqCaURzmcqXLE92ZKyVSE54b2/">previous</a> version (QmeMgu8D4GHuYNQSqC1RbVqCaURzmcqXLE92ZKyVSE54b2)</p>
<h3 id="the-script">the script :</h3>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true"></a><span class="co">#</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true"></a></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true"></a><span class="co"># peerid -&gt; /root/www</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true"></a><span class="co"># www -&gt; /public/www</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true"></a><span class="co"># www -&gt; /my/websites</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true"></a><span class="co"># /my/friends/user/websites</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true"></a><span class="va">pwd=$(</span><span class="bu">pwd</span><span class="va">)</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true"></a><span class="kw">if</span> <span class="va">top=$(</span><span class="fu">git</span> rev-parse --show-toplevel<span class="va">)</span>; <span class="kw">then</span></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true"></a><span class="va">dirname=${top##</span>*/<span class="va">}</span></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true"></a><span class="kw">else</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true"></a><span class="va">dirname=${pwd##</span>*/<span class="va">}</span></span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true"></a><span class="kw">fi</span></span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true"></a></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true"></a><span class="va">site=$dirname</span></span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true"></a><span class="va">intent=</span><span class="st">&quot;upload current folder or _site if present as a website </span><span class="va">$site</span><span class="st">&quot;</span></span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true"></a></span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true"></a><span class="bu">echo</span> <span class="st">&quot;--- # </span><span class="va">${0##</span>*/<span class="va">}</span><span class="st">&quot;</span></span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true"></a><span class="va">peerid=$(</span><span class="ex">ipfs</span> config Identity.PeerID<span class="va">)</span></span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true"></a><span class="bu">echo</span> <span class="st">&quot;peerid: </span><span class="va">$peerid</span><span class="st">&quot;</span></span>
<span id="cb1-20"><a href="#cb1-20" aria-hidden="true"></a></span>
<span id="cb1-21"><a href="#cb1-21" aria-hidden="true"></a><span class="va">symb=</span>websites</span>
<span id="cb1-22"><a href="#cb1-22" aria-hidden="true"></a><span class="kw">if</span> ! <span class="ex">ipfs</span> key list <span class="kw">|</span> <span class="fu">grep</span> -q -w <span class="va">$symb</span><span class="kw">;</span> <span class="kw">then</span></span>
<span id="cb1-23"><a href="#cb1-23" aria-hidden="true"></a> <span class="va">key=$(</span><span class="ex">ipfs</span> key gen -t rsa -s 3072 <span class="va">$symb</span> --ipns-base=b58mh<span class="va">)</span></span>
<span id="cb1-24"><a href="#cb1-24" aria-hidden="true"></a><span class="kw">else</span></span>
<span id="cb1-25"><a href="#cb1-25" aria-hidden="true"></a> <span class="va">key=$(</span><span class="ex">ipfs</span> key list -l --ipns-base=b58mh <span class="kw">|</span> <span class="fu">grep</span> -w <span class="va">$symb</span> <span class="kw">|</span> <span class="fu">cut</span> -d<span class="st">&#39; &#39;</span> -f1<span class="va">)</span></span>
<span id="cb1-26"><a href="#cb1-26" aria-hidden="true"></a><span class="kw">fi</span></span>
<span id="cb1-27"><a href="#cb1-27" aria-hidden="true"></a><span class="bu">echo</span> key: <span class="va">$key</span></span>
<span id="cb1-28"><a href="#cb1-28" aria-hidden="true"></a></span>
<span id="cb1-29"><a href="#cb1-29" aria-hidden="true"></a><span class="bu">echo</span> site: <span class="va">$site</span></span>
<span id="cb1-30"><a href="#cb1-30" aria-hidden="true"></a><span class="kw">if</span> <span class="va">www=$(</span><span class="ex">ipfs</span> resolve --recursive=true /ipns/<span class="va">$key)</span>; <span class="kw">then</span></span>
<span id="cb1-31"><a href="#cb1-31" aria-hidden="true"></a><span class="va">qmwww=${www##</span>/ipfs/<span class="va">}</span></span>
<span id="cb1-32"><a href="#cb1-32" aria-hidden="true"></a><span class="kw">else</span></span>
<span id="cb1-33"><a href="#cb1-33" aria-hidden="true"></a> <span class="va">qmwww=$(</span><span class="ex">ipfs</span> object new unixfs-dir<span class="va">)</span></span>
<span id="cb1-34"><a href="#cb1-34" aria-hidden="true"></a> <span class="va">www=</span>/ipfs/<span class="va">$qmwww</span></span>
<span id="cb1-35"><a href="#cb1-35" aria-hidden="true"></a><span class="kw">fi</span></span>
<span id="cb1-36"><a href="#cb1-36" aria-hidden="true"></a><span class="bu">echo</span> qmwww: <span class="va">$qmwww</span></span>
<span id="cb1-37"><a href="#cb1-37" aria-hidden="true"></a></span>
<span id="cb1-38"><a href="#cb1-38" aria-hidden="true"></a><span class="bu">cd</span> <span class="va">$top</span></span>
<span id="cb1-39"><a href="#cb1-39" aria-hidden="true"></a><span class="fu">find</span> . -name <span class="st">&#39;*~1&#39;</span> -delete</span>
<span id="cb1-40"><a href="#cb1-40" aria-hidden="true"></a><span class="kw">if</span><span class="bu"> [</span> <span class="ot">!</span> <span class="ot">-d</span> _data<span class="bu"> ]</span>; <span class="kw">then</span> <span class="fu">mkdir</span> _data<span class="kw">;</span> <span class="kw">fi</span></span>
<span id="cb1-41"><a href="#cb1-41" aria-hidden="true"></a><span class="kw">if</span><span class="bu"> [</span> <span class="ot">-d</span> _site<span class="bu"> ]</span>; <span class="kw">then</span></span>
<span id="cb1-42"><a href="#cb1-42" aria-hidden="true"></a> <span class="va">qm=$(</span><span class="ex">ipfs</span> add -r _site -Q<span class="va">)</span></span>
<span id="cb1-43"><a href="#cb1-43" aria-hidden="true"></a><span class="kw">else</span> </span>
<span id="cb1-44"><a href="#cb1-44" aria-hidden="true"></a> <span class="va">qm=$(</span><span class="ex">ipfs</span> add -r . -Q<span class="va">)</span></span>
<span id="cb1-45"><a href="#cb1-45" aria-hidden="true"></a><span class="kw">fi</span></span>
<span id="cb1-46"><a href="#cb1-46" aria-hidden="true"></a><span class="bu">echo</span> qm: <span class="va">$qm</span></span>
<span id="cb1-47"><a href="#cb1-47" aria-hidden="true"></a><span class="ex">ipfs</span> ls <span class="va">$www</span></span>
<span id="cb1-48"><a href="#cb1-48" aria-hidden="true"></a><span class="kw">if</span> <span class="va">qmsite=$(</span><span class="ex">ipfs</span> files stat <span class="va">$www</span>/<span class="va">$site</span> --hash <span class="op">2&gt;</span>/dev/null<span class="va">)</span>; <span class="kw">then</span></span>
<span id="cb1-49"><a href="#cb1-49" aria-hidden="true"></a> <span class="bu">echo</span> <span class="st">&quot;--- # previous version for </span><span class="va">$site</span><span class="st">&quot;</span> <span class="op">&gt;</span> _data/previous.yml</span>
<span id="cb1-50"><a href="#cb1-50" aria-hidden="true"></a> <span class="bu">echo</span> qmsite: <span class="va">$qmsite</span> <span class="op">&gt;&gt;</span> _data/previous.yml</span>
<span id="cb1-51"><a href="#cb1-51" aria-hidden="true"></a> <span class="va">qmwww=$(</span><span class="ex">ipfs</span> object patch rm-link <span class="va">$qmwww</span> <span class="va">$site)</span></span>
<span id="cb1-52"><a href="#cb1-52" aria-hidden="true"></a> <span class="va">qmwww=$(</span><span class="ex">ipfs</span> object patch add-link <span class="va">$qmwww</span> <span class="va">$site</span> <span class="va">$qm)</span></span>
<span id="cb1-53"><a href="#cb1-53" aria-hidden="true"></a><span class="kw">else</span></span>
<span id="cb1-54"><a href="#cb1-54" aria-hidden="true"></a> <span class="va">qmwww=$(</span><span class="ex">ipfs</span> object patch add-link <span class="va">$qmwww</span> <span class="va">$site</span> <span class="va">$qm)</span></span>
<span id="cb1-55"><a href="#cb1-55" aria-hidden="true"></a><span class="kw">fi</span> </span>
<span id="cb1-56"><a href="#cb1-56" aria-hidden="true"></a><span class="kw">if</span> <span class="va">qmsite=$(</span><span class="ex">ipfs</span> files stat /public/www/<span class="va">$site</span> --hash <span class="op">2&gt;</span>/dev/null<span class="va">)</span>; <span class="kw">then</span></span>
<span id="cb1-57"><a href="#cb1-57" aria-hidden="true"></a><span class="ex">ipfs</span> files rm -r /public/www/<span class="va">$site</span></span>
<span id="cb1-58"><a href="#cb1-58" aria-hidden="true"></a><span class="kw">fi</span></span>
<span id="cb1-59"><a href="#cb1-59" aria-hidden="true"></a><span class="ex">ipfs</span> files cp /ipfs/<span class="va">$qm</span> /public/www/<span class="va">$site</span> </span>
<span id="cb1-60"><a href="#cb1-60" aria-hidden="true"></a></span>
<span id="cb1-61"><a href="#cb1-61" aria-hidden="true"></a><span class="va">gwhost=$(</span><span class="ex">ipfs</span> config Addresses.Gateway<span class="kw">|</span><span class="fu">cut</span> -d<span class="st">&#39;/&#39;</span> -f 3<span class="va">)</span></span>
<span id="cb1-62"><a href="#cb1-62" aria-hidden="true"></a><span class="va">gwport=$(</span><span class="ex">ipfs</span> config Addresses.Gateway<span class="kw">|</span><span class="fu">cut</span> -d<span class="st">&#39;/&#39;</span> -f 5<span class="va">)</span></span>
<span id="cb1-63"><a href="#cb1-63" aria-hidden="true"></a><span class="va">gw_url=</span><span class="st">&quot;http://</span><span class="va">$gwhost</span><span class="st">:</span><span class="va">$gwport</span><span class="st">&quot;</span></span>
<span id="cb1-64"><a href="#cb1-64" aria-hidden="true"></a></span>
<span id="cb1-65"><a href="#cb1-65" aria-hidden="true"></a><span class="bu">echo</span> url: https://ipfs.blockring™.ml/ipfs/<span class="va">$qmwww</span></span>
<span id="cb1-66"><a href="#cb1-66" aria-hidden="true"></a><span class="bu">echo</span> url: <span class="va">$gw_url</span>/ipfs/<span class="va">$qmwww</span></span>
<span id="cb1-67"><a href="#cb1-67" aria-hidden="true"></a></span>
<span id="cb1-68"><a href="#cb1-68" aria-hidden="true"></a></span>
<span id="cb1-69"><a href="#cb1-69" aria-hidden="true"></a><span class="bu">echo</span> <span class="st">&quot;publising on namesm.tk/</span><span class="va">$symb</span><span class="st">&quot;</span></span>
<span id="cb1-70"><a href="#cb1-70" aria-hidden="true"></a><span class="ex">ipfs</span> name publish --key=<span class="va">$symb</span> /ipfs/<span class="va">$qmwww</span></span>
<span id="cb1-71"><a href="#cb1-71" aria-hidden="true"></a></span>
<span id="cb1-72"><a href="#cb1-72" aria-hidden="true"></a></span>
<span id="cb1-73"><a href="#cb1-73" aria-hidden="true"></a><span class="fu">true</span><span class="kw">;</span> # <span class="va">$Source</span>: <span class="ex">/my/shell/script/webup.sh</span> $ vim&#x3A; syntax=sh</span></code></pre></div>
<p>— <br> <code>QmbM9DTrpeZr8XYJbz4rdZQ92eWX1iWUQ5z6bWPSSCAxvy</code></p>
</body>
</html>
--- # metadata file
title: hostless website webup.tk
tic: 1620790793
qm: QmbM9DTrpeZr8XYJbz4rdZQ92eWX1iWUQ5z6bWPSSCAxvy
site: webup.tk
peerid: QmcfHufAK9ErQ9ZKJF7YX68KntYYBJngkGDoVKcZEJyRve
webkey: QmYwyK9VMxBKm1STUQ9jbYVz3ymAa4ULVLwpx8oHvSKAG2
qmwww: /ipfs/QmPAb4sM97WT7utfnMCWrCUnSJ8B4VfvEYmcM6AVH1u855
qmprev: QmeMgu8D4GHuYNQSqC1RbVqCaURzmcqXLE92ZKyVSE54b2
gw_url: http://0.0.0.0:8390

Tasks (TODOs)

  • make a token that list the discoverable site ...
#
# peerid -> /root/www
# www -> /public/www
# www -> /my/websites
# /my/friends/user/websites
pwd=$(pwd)
if top=$(git rev-parse --show-toplevel); then
dirname=${top##*/}
else
dirname=${pwd##*/}
fi
site=$dirname
intent="upload current folder or _site if present as a website $site"
echo "--- # ${0##*/}"
peerid=$(ipfs config Identity.PeerID)
echo "peerid: $peerid"
symb=websites
if ! ipfs key list | grep -q -w $symb; then
key=$(ipfs key gen -t rsa -s 3072 $symb --ipns-base=b58mh)
else
key=$(ipfs key list -l --ipns-base=b58mh | grep -w $symb | cut -d' ' -f1)
fi
echo key: $key
echo site: $site
if www=$(ipfs resolve --recursive=true /ipns/$key); then
qmwww=${www##/ipfs/}
else
qmwww=$(ipfs object new unixfs-dir)
www=/ipfs/$qmwww
fi
echo qmwww: $qmwww
cd $top
find . -name '*~1' -delete
if [ ! -d _data ]; then mkdir _data; fi
if [ -d _site ]; then
qm=$(ipfs add -r _site -Q)
else
qm=$(ipfs add -r . -Q)
fi
echo qm: $qm
ipfs ls $www | sed -e 's/ -/:/'
if qmsite=$(ipfs files stat $www/$site --hash 2>/dev/null); then
echo "--- # previous version for $site" > _data/previous.yml
echo qmsite: $qmsite >> _data/previous.yml
qmwww=$(ipfs object patch rm-link $qmwww $site)
qmwww=$(ipfs object patch add-link $qmwww $site $qm)
else
qmwww=$(ipfs object patch add-link $qmwww $site $qm)
fi
if qmsite=$(ipfs files stat /public/www/$site --hash 2>/dev/null); then
ipfs files rm -r /public/www/$site
fi
ipfs files cp /ipfs/$qm /public/www/$site
gwhost=$(ipfs config Addresses.Gateway|cut -d'/' -f 3)
gwport=$(ipfs config Addresses.Gateway|cut -d'/' -f 5)
gw_url="http://$gwhost:$gwport"
echo url: https://ipfs.blockring™.ml/ipfs/$qmwww
echo url: $gw_url/ipfs/$qmwww
echo "publising on namesm.tk/$symb"
ipfs name publish --key=$symb /ipfs/$qmwww
true; # $Source: /my/shell/script/webup.sh $ vim: syntax=sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment