Skip to content

Commit

Permalink
docs: updated snapshot generation steps
Browse files Browse the repository at this point in the history
- use updated extract_zim tool
- switch to CIDv1

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
  • Loading branch information
lidel committed Jan 20, 2020
1 parent 2106f78 commit 3acbd1a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store
.cache
*.zim
out
IPFS_PATH
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,18 @@ First, download the latest wiki lists using `bash getzim.sh cache_update`
After that create a download command using `bash getzim.sh choose`

### Step 2: Unpack the ZIM snapshot
Unpack the ZIM snapshot using https://github.com/dignifiedquire/zim/commit/a283151105ab4c1905d7f5cb56fb8eb2a854ad67

Unpack the ZIM snapshot using `extract_zim` from https://github.com/dignifiedquire/zim:

```sh
$ extract_zim --skip-link wikipedia_tr_all_maxi_2019-10.zim --out ./out
Extracting file: wikipedia_tr_all_maxi_2019-10.zim to ./out

Creating map
Extracting entries: 4808
Spawning 4808 tasks across 16 threads
Extraction done in 47453ms
```

### Step 3: Enable Directory Sharding on your IPFS Node
Configure your IPFS node to enable directory sharding
Expand All @@ -74,10 +85,10 @@ $ ipfs config --json 'Experimental.ShardingEnabled' true
```

### Step 4: Add the data to IPFS
Add all the data to your node using `ipfs add`. Use the following command, replacing `$unpacked_wiki` with the path to the unpacked ZIM snapshot that you created in Step 2. **Don't share the hash yet.**
Add all the data to your node using `ipfs add`. Use the following command, replacing `$unpacked_wiki` with the path to the unpacked ZIM snapshot that you created in Step 2 (`./out`). **Don't share the hash yet.**

```sh
$ ipfs add -w -r --raw-leaves $upacked_wiki
$ ipfs add -w -r --cid-version 1 $unpacked_wiki
```

Save the last hash of the output from that process. You will use that in the next step.
Expand Down
12 changes: 6 additions & 6 deletions execute-changes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,27 @@ NEW_BODYJS=$(
cat - <(sed -e 's/{{SEARCH_CID}}/'"$SEARCH"'/' scripts/search-shim.js)
else
cat -
fi | ipfs add -Q
fi | ipfs add --cid-version 1 -Q
)

ipfs-replace "-/j/body.js" "/ipfs/$NEW_BODYJS"
ipfs-replace "I/s/Wikipedia-logo-v2-200px-transparent.png" \
"/ipfs/$(ipfs add -q assets/wikipedia-on-ipfs-small-flat-cropped-offset-min.png)"
"/ipfs/$(ipfs add --cid-version 1 -q assets/wikipedia-on-ipfs-small-flat-cropped-offset-min.png)"
ipfs-replace "I/s/wikipedia-on-ipfs.png" \
"/ipfs/$(ipfs add -Q assets/wikipedia-on-ipfs-100px.png)"
"/ipfs/$(ipfs add --cid-version 1 -Q assets/wikipedia-on-ipfs-100px.png)"

if [ -n "$SEARCH" ]; then
ipfs-replace "-/j/search.js" "/ipfs/$(ipfs add -Q scripts/search.js)"
ipfs-replace "-/j/search.js" "/ipfs/$(ipfs add --cid-version 1 -Q scripts/search.js)"
fi

# comment out some debug stuff in head.js
HEAD_JS_LOCATION="$(ipfs files stat --hash "$ROOT")/-/j/head.js"
HEAD_JS_HASH="$(ipfs cat "$HEAD_JS_LOCATION" | sed -e "s|^\tdocument.getElementsByTagName( 'head' )|//\0|" | ipfs add -Q)"
HEAD_JS_HASH="$(ipfs cat "$HEAD_JS_LOCATION" | sed -e "s|^\tdocument.getElementsByTagName( 'head' )|//\0|" | ipfs add --cid-version 1 -Q)"

ipfs-replace "-/j/head.js" "/ipfs/$HEAD_JS_HASH"

ipfs-replace "/wiki/index.html" "$ROOT/wiki/$MAIN"
ipfs-replace "/index.html" "/ipfs/$(ipfs add -Q redirect-page/index_root.html)"
ipfs-replace "/index.html" "/ipfs/$(ipfs add --cid-version 1 -Q redirect-page/index_root.html)"

ipfs files flush "$ROOT"
echo "We are done !!!"
Expand Down

0 comments on commit 3acbd1a

Please sign in to comment.