mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-23 06:08:36 +01:00
Update publish-to-ipfs.ps1
This commit is contained in:
parent
49126fd1b4
commit
7ecccd8305
@ -1,8 +1,8 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
publish-to-ipfs.ps1 [<file(s)/dir>] [<to-hash-list>]
|
||||
publish-to-ipfs.ps1 [<FilePattern>] [<to-hash-list>]
|
||||
.DESCRIPTION
|
||||
Publishes the given files and folders to IPFS.
|
||||
Publishes the given files & folders to IPFS
|
||||
.EXAMPLE
|
||||
PS> .\publish-to-ipfs.ps1 C:\MyFile.txt
|
||||
.NOTES
|
||||
@ -11,34 +11,34 @@
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
param([string]$Files = "", [string]$HashList = "IPFS_hashes.txt", [string]$DF_Hashes = "file_checksums.xml")
|
||||
param([string]$FilePattern = "", [string]$HashList = "IPFS_hashes.txt", [string]$DF_Hashes = "file_checksums.xml")
|
||||
|
||||
try {
|
||||
if ($Files -eq "") { $Files = read-host "Enter file(s) or directory tree to publish" }
|
||||
if ($FilePattern -eq "") { $FilePattern = read-host "Enter file(s)/directories to publish" }
|
||||
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
""
|
||||
"Step 1/3: Searching for IPFS..."
|
||||
"Step 1/3: Searching IPFS executable..."
|
||||
& ipfs --version
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" }
|
||||
|
||||
if (test-path "$Files" -pathType container) {
|
||||
if (test-path "$FilePattern" -pathType container) {
|
||||
""
|
||||
"Step 2/3: Publishing folder $Files/ to IPFS..."
|
||||
& ipfs add -r "$Files" > $HashList
|
||||
"Step 2/3: Publishing folder $FilePattern/..."
|
||||
& ipfs add -r "$FilePattern" > $HashList
|
||||
[int]$Count = 1
|
||||
""
|
||||
echo "Step 3/3: Calculating digital forensics hashes to $DF_HASHES ..."
|
||||
& nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$Files" > $DF_Hashes
|
||||
& nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$FilePattern" > $DF_Hashes
|
||||
} else {
|
||||
$FileList = (get-childItem "$Files")
|
||||
$FileList = (get-childItem "$FilePattern")
|
||||
foreach ($File in $FileList) {
|
||||
if (test-path "$Files" -pathType container) {
|
||||
"Step 2/3: Publishing folder $File/ to IPFS..."
|
||||
if (test-path "$FilePattern" -pathType container) {
|
||||
"Step 2/3: Publishing folder $File/..."
|
||||
& ipfs add -r "$File" >> $HashList
|
||||
} else {
|
||||
"Step 2/3: Publishing file $File to IPFS..."
|
||||
"Step 2/3: Publishing file $File..."
|
||||
& ipfs add "$File" >> $HashList
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user