New functions for creating sites

This commit is contained in:
Cetra Avaroe 2022-07-22 09:41:41 -05:00
parent d974f0d4cc
commit 95b5303156
No known key found for this signature in database
GPG Key ID: 21A3DA3DE29CB63C
2 changed files with 108 additions and 21 deletions

View File

@ -1,10 +1,8 @@
# Edie, the IPNS site pin manager
Edie is a simple Bash script to help pin and manage seeded sites hosted over IPNS, similar to Freenet's bookmark feature. It reads from a file (at `$HOME/.edie/urls`) with a list of domains set up to use DNSLink and can fetch newer versions of the underlying IPNS hash, as well as clean up old files when removing a site.
Edie is a simple Bash script to help pin and manage seeded sites hosted over IPNS, similar to Freenet's bookmark feature. It reads from a file (at `$HOME/.edie/urls`) with a list of raw peer hashes or domains set up to use DNSLink and can fetch newer versions of the underlying IPNS hash, as well as clean up old files when removing a site.
Please note that it does not yet have functionality for *creating* a new IPNS site.
Support for pinning IPNS sites without a domain (eg. /ipns/bafybeibt6ozbpel3rne5obfsofvwep6wefx7iangfpjgqh3fsbdapbm43i) will be added in a future release.
Edie currently does not support pinning IPNS sites using CIDv1 (hashes starting with 'bafy').
Edie does not run in the background. For auto-updates like in ZeroNet and Freenet, you must edit your own crontab to periodically call `edie -u`.
@ -20,13 +18,56 @@ Edie does not run in the background. For auto-updates like in ZeroNet and Freene
## Examples
### Add a new site
### Creating your own site
#### Creating a new site (interactive mode only for now)
Input: `edie -c`
Output:
```
Nickname for site (no spaces): EdieTest
Full path to site files (no spaces): /var/www/misc/
19.81 MiB / 19.81 MiB [============================] 100.00%
This next step may take a while depending on the size of the site. Hang tight!
Published to k2k4r8lzp5lprvvepogfviahclcb5cuau5afgk16zp89l8rfz7w8w5a8: /ipfs/QmdzZfoxk5KPje8qLUKpPPghyhrySzsDAw4SRJXdMWH2qD
Site created.
Keys and config backed up in ~/.edie/sites/
```
#### List info about a created site
Input: `edie -i EdieTest`
Output:
```
Site name: EdieTest
IPNS hash: /ipns/k2k4r8lzp5lprvvepogfviahclcb5cuau5afgk16zp89l8rfz7w8w5a8
Local path to site files: /var/www/misc/
```
#### Update a site
Input: `edie -k EdieTest`
Output:
```
Updating EdieTest
19.81 MiB / 19.81 MiB [============================] 100.00%
This next step may take a while depending on the size of the site. Hang tight!
Published to k2k4r8lzp5lprvvepogfviahclcb5cuau5afgk16zp89l8rfz7w8w5a8: /ipfs/QmdzZfoxk5KPje8qLUKpPPghyhrySzsDAw4SRJXdMWH2qD
Site updated.
```
### Managing pinned sites from other people
#### Add a new site to your storage
Input: `edie -a shimmy1996.com`
Output: `pinned QmXdHCZYM9oh2ZcGQD4aYFrTGNXygaGXqEiUSQWvFqu1GL recursively`
### List info about a pinned site
#### List info about a pinned site
Input: `edie -v shimmy1996.com`
@ -39,7 +80,7 @@ Size: 391MiB
Please note that the size may actually be smaller than outputted due to deduplication or compression.
### Update all pinned sites
#### Update all pinned sites
Input: `edie -u`
@ -63,12 +104,17 @@ Input: `edie -h`
Output:
```
edie v.20220720
-l: list all pinned sites
-u: update all pinned sites
-d: unpin a site and delete it from storage
-a: pin a site and add it to storage
-v: show detailed info about a pinned site
edie v.20220722
for creating sites:
-c: create a new site (in interactive mode)
-i: display info about a created site
-k: update a site
for managing pinned sites:
-l: list all pinned sites
-u: update all pinned sites
-d: unpin a site and delete it from storage
-a: pin a site and add it to storage
-v: show detailed info about a pinned site
-h: display this help
```

57
edie
View File

@ -4,9 +4,9 @@
# written by vane vander <https://letsdecentralize.org>
# licensed under gplv3-only
VERSION=20220720
VERSION=20220722
while getopts 'lud:a:v:h' OPTION; do
while getopts 'lud:a:v:hci:k:' OPTION; do
case "$OPTION" in
l)
for OUTPUT in $(cat $HOME/.edie/urls)
@ -34,8 +34,12 @@ while getopts 'lud:a:v:h' OPTION; do
;;
a)
mkdir -p $HOME/.edie/
echo $OPTARG >> $HOME/.edie/urls
if [[ $OPTARG == *"bafy"* ]]; then
echo "CIDv1 (hashes starting with 'bafy') not supported at this time."
exit 1
fi
ipfs name resolve $OPTARG | xargs ipfs pin add -r
echo $OPTARG >> $HOME/.edie/urls
;;
v)
echo $OPTARG
@ -44,14 +48,51 @@ while getopts 'lud:a:v:h' OPTION; do
echo -n "Size: "
ipfs name resolve $OPTARG | xargs ipfs object stat | grep CumulativeSize | sed -e 's/CumulativeSize: //g' | xargs numfmt --to=iec-i --suffix=B
;;
c)
echo -n "Nickname for site (no spaces): "
read sitename
mkdir -p $HOME/.edie/sites/
echo $sitename >> $HOME/.edie/sites/$sitename.txt
ipfs key gen --type=rsa --size=2048 $sitename >> $HOME/.edie/sites/$sitename.txt
ipfs key export $sitename -o $HOME/.edie/sites/$sitename.key
echo -n "Full path to site files (no spaces): "
read sitepath
echo $sitepath >> $HOME/.edie/sites/$sitename.txt
TEMPHASH=$(ipfs add -r $sitepath | tail -1 | awk '/Qm/' RS=" ")
echo "This next step may take a while depending on the size of the site. Hang tight!"
ipfs name publish --key=$sitename $TEMPHASH
echo "Site created."
echo "Keys and config backed up in ~/.edie/sites/"
;;
i)
echo -n "Site name: "
sed -n '1p' $HOME/.edie/sites/$OPTARG.txt
echo -n "IPNS hash: /ipns/"
sed -n '2p' $HOME/.edie/sites/$OPTARG.txt
echo -n "Local path to site files: "
sed -n '3p' $HOME/.edie/sites/$OPTARG.txt
;;
k)
echo -n "Updating "
echo $OPTARG
TEMPHASH=$(sed -n '3p' $HOME/.edie/sites/$OPTARG.txt | xargs ipfs add -r | tail -1 | awk '/Qm/' RS=" ")
echo "This next step may take a while depending on the size of the site. Hang tight!"
ipfs name publish --key=$OPTARG $TEMPHASH
echo "Site updated."
;;
h)
echo -n "edie v."
echo $VERSION
echo "-l: list all pinned sites"
echo "-u: update all pinned sites"
echo "-d: unpin a site and delete it from storage"
echo "-a: pin a site and add it to storage"
echo "-v: show detailed info about a pinned site"
echo "for creating sites:"
echo " -c: create a new site (in interactive mode)"
echo " -i: display info about a created site"
echo " -k: update a site"
echo "for managing pinned sites:"
echo " -l: list all pinned sites"
echo " -u: update all pinned sites"
echo " -d: unpin a site and delete it from storage"
echo " -a: pin a site and add it to storage"
echo " -v: show detailed info about a pinned site"
echo "-h: display this help"
;;
esac