PowerShell/Scripts/ipfs-publish.sh

26 lines
731 B
Bash
Raw Normal View History

2020-05-31 11:27:37 +02:00
#!/bin/sh
# Syntax: ./ipfs-publish <dir-tree>
2021-03-08 18:57:00 +01:00
# Description: publishes the given directory tree to IPFS
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
# NOTE: requires <ipfs> and <hashdeep>
2020-05-31 11:27:37 +02:00
DIR=$1
2020-06-19 14:34:43 +02:00
IPFS_HASHES="IPFS_hash_list.txt"
DF_HASHES="checksum_list.xml"
2020-05-31 11:27:37 +02:00
2021-03-08 18:57:00 +01:00
echo "Publishing folder $DIR to IPFS"
echo "(1/3) Removing Thumbs.db in subfolders ..."
2020-05-31 11:27:37 +02:00
nice find "$DIR" -name Thumbs.db -exec rm -rf {} \;
2021-03-08 18:57:00 +01:00
echo "(2/3) Adding $DIR to IPFS ..."
2020-05-31 11:27:37 +02:00
nice ipfs add -r "$DIR" > $IPFS_HASHES
2021-03-08 18:57:00 +01:00
echo "(3/3) Calculating digital forensics hashes to $DF_HASHES ..."
2020-09-27 11:43:06 +02:00
nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$DIR" > $DF_HASHES
2020-05-31 11:27:37 +02:00
2021-03-08 18:57:00 +01:00
echo "OK - to publish the content execute: ipfs name publish <HASH>"
2020-05-31 11:27:37 +02:00
exit 0