Avoid creating duplicate entries in the URL file when adding sites
This commit is contained in:
parent
95b5303156
commit
d3df000e3a
|
@ -104,7 +104,7 @@ Input: `edie -h`
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
```
|
```
|
||||||
edie v.20220722
|
edie v.20220723
|
||||||
for creating sites:
|
for creating sites:
|
||||||
-c: create a new site (in interactive mode)
|
-c: create a new site (in interactive mode)
|
||||||
-i: display info about a created site
|
-i: display info about a created site
|
||||||
|
|
24
edie
24
edie
|
@ -4,7 +4,7 @@
|
||||||
# written by vane vander <https://letsdecentralize.org>
|
# written by vane vander <https://letsdecentralize.org>
|
||||||
# licensed under gplv3-only
|
# licensed under gplv3-only
|
||||||
|
|
||||||
VERSION=20220722
|
VERSION=20220723
|
||||||
|
|
||||||
while getopts 'lud:a:v:hci:k:' OPTION; do
|
while getopts 'lud:a:v:hci:k:' OPTION; do
|
||||||
case "$OPTION" in
|
case "$OPTION" in
|
||||||
|
@ -28,9 +28,13 @@ while getopts 'lud:a:v:hci:k:' OPTION; do
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
cat $HOME/.edie/urls | grep -v $OPTARG > /tmp/urls && mv /tmp/urls $HOME/.edie/urls
|
if cat $HOME/.edie/urls | grep $OPTARG
|
||||||
ipfs name resolve $OPTARG | xargs ipfs pin rm
|
then
|
||||||
ipfs repo gc
|
cat $HOME/.edie/urls | grep -v $OPTARG > /tmp/urls && mv /tmp/urls $HOME/.edie/urls
|
||||||
|
ipfs name resolve $OPTARG | xargs ipfs pin rm
|
||||||
|
ipfs repo gc
|
||||||
|
else echo "Not found in ~/.edie/urls"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
a)
|
a)
|
||||||
mkdir -p $HOME/.edie/
|
mkdir -p $HOME/.edie/
|
||||||
|
@ -38,8 +42,10 @@ while getopts 'lud:a:v:hci:k:' OPTION; do
|
||||||
echo "CIDv1 (hashes starting with 'bafy') not supported at this time."
|
echo "CIDv1 (hashes starting with 'bafy') not supported at this time."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
ipfs name resolve $OPTARG | xargs ipfs pin add -r
|
if cat $HOME/.edie/urls | grep $OPTARG > /dev/null
|
||||||
echo $OPTARG >> $HOME/.edie/urls
|
then echo "You've already pinned this site."
|
||||||
|
else ipfs name resolve $OPTARG | xargs ipfs pin add -r && echo $OPTARG >> $HOME/.edie/urls
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
echo $OPTARG
|
echo $OPTARG
|
||||||
|
@ -77,8 +83,10 @@ while getopts 'lud:a:v:hci:k:' OPTION; do
|
||||||
echo $OPTARG
|
echo $OPTARG
|
||||||
TEMPHASH=$(sed -n '3p' $HOME/.edie/sites/$OPTARG.txt | xargs ipfs add -r | tail -1 | awk '/Qm/' RS=" ")
|
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!"
|
echo "This next step may take a while depending on the size of the site. Hang tight!"
|
||||||
ipfs name publish --key=$OPTARG $TEMPHASH
|
if ipfs name publish --key=$OPTARG $TEMPHASH
|
||||||
echo "Site updated."
|
then echo "Site updated."
|
||||||
|
else echo "Something went wrong. File an issue at https://codeberg.org/lethe/edie/"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
echo -n "edie v."
|
echo -n "edie v."
|
||||||
|
|
Loading…
Reference in New Issue