mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-16 06:58:18 +02:00
Add publish-to-ipfs.ps1
This commit is contained in:
parent
e6d93b5c08
commit
47f084b2d4
@ -152,6 +152,7 @@ play-mp3.ps1, plays the given sound file (MP3 file format)
|
|||||||
play-super-mario.ps1, plays the Super Mario Intro
|
play-super-mario.ps1, plays the Super Mario Intro
|
||||||
play-the-imperial-march.ps1, plays the Imperial March (Star Wars)
|
play-the-imperial-march.ps1, plays the Imperial March (Star Wars)
|
||||||
poweroff.ps1, halts the local computer (needs admin rights)
|
poweroff.ps1, halts the local computer (needs admin rights)
|
||||||
|
publish-to-ipfs.ps1, publishes the given files or directory to IPFS
|
||||||
pull-repo.ps1, pulls updates for the current/given Git repository (including submodules)
|
pull-repo.ps1, pulls updates for the current/given Git repository (including submodules)
|
||||||
pull-repos.ps1, pulls updates for all Git repositories under the current/given directory (including submodules)
|
pull-repos.ps1, pulls updates for all Git repositories under the current/given directory (including submodules)
|
||||||
query-smart-data.ps1, queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory
|
query-smart-data.ps1, queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory
|
||||||
|
|
@ -132,6 +132,7 @@ Mega Collection of PowerShell Scripts
|
|||||||
* [list-workdir.ps1](Scripts/list-workdir.ps1) - lists the current working directory
|
* [list-workdir.ps1](Scripts/list-workdir.ps1) - lists the current working directory
|
||||||
* [make-install.ps1](Scripts/make-install.ps1) - installs built executables and libs to the installation directory
|
* [make-install.ps1](Scripts/make-install.ps1) - installs built executables and libs to the installation directory
|
||||||
* [MD5.ps1](Scripts/MD5.ps1) - prints the MD5 checksum of the given file
|
* [MD5.ps1](Scripts/MD5.ps1) - prints the MD5 checksum of the given file
|
||||||
|
* [publish-to-ipfs.ps1](Scripts/publish-to-ipfs.ps1) - publishes the given files or directory to IPFS
|
||||||
* [remove-empty-dirs.ps1](Scripts/remove-empty-dirs.ps1) - removes empty subfolders within the given directory tree
|
* [remove-empty-dirs.ps1](Scripts/remove-empty-dirs.ps1) - removes empty subfolders within the given directory tree
|
||||||
* [search-filename.ps1](Scripts/search-filename.ps1) - searches the directory tree for filenames by given pattern
|
* [search-filename.ps1](Scripts/search-filename.ps1) - searches the directory tree for filenames by given pattern
|
||||||
* [search-files.ps1](Scripts/search-files.ps1) - searches the given pattern in the given files
|
* [search-files.ps1](Scripts/search-files.ps1) - searches the given pattern in the given files
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Syntax: ./ipfs-publish <dir-tree>
|
|
||||||
# Description: publishes the given directory tree to IPFS
|
|
||||||
# Author: Markus Fleschutz
|
|
||||||
# Source: github.com/fleschutz/PowerShell
|
|
||||||
# License: CC0
|
|
||||||
# NOTE: requires <ipfs> and <hashdeep>
|
|
||||||
|
|
||||||
DIR=$1
|
|
||||||
IPFS_HASHES="IPFS_hash_list.txt"
|
|
||||||
DF_HASHES="checksum_list.xml"
|
|
||||||
|
|
||||||
echo "Publishing folder $DIR to IPFS"
|
|
||||||
echo "(1/3) Removing Thumbs.db in subfolders ..."
|
|
||||||
nice find "$DIR" -name Thumbs.db -exec rm -rf {} \;
|
|
||||||
|
|
||||||
echo "(2/3) Adding $DIR to IPFS ..."
|
|
||||||
nice ipfs add -r "$DIR" > $IPFS_HASHES
|
|
||||||
|
|
||||||
echo "(3/3) Calculating digital forensics hashes to $DF_HASHES ..."
|
|
||||||
nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$DIR" > $DF_HASHES
|
|
||||||
|
|
||||||
echo "OK - to publish the content execute: ipfs name publish <HASH>"
|
|
||||||
exit 0
|
|
45
Scripts/publish-to-ipfs.ps1
Executable file
45
Scripts/publish-to-ipfs.ps1
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
publish-to-ipfs.ps1 [<file(s)/dir>] [<to-hash-list>]
|
||||||
|
.DESCRIPTION
|
||||||
|
Publishes the given files or directory to IPFS
|
||||||
|
.EXAMPLE
|
||||||
|
PS> .\publish-to-ipfs.ps1 C:\MyFile.txt
|
||||||
|
.LINK
|
||||||
|
https://github.com/fleschutz/PowerShell
|
||||||
|
.NOTES
|
||||||
|
Author: Markus Fleschutz / License: CC0
|
||||||
|
#>
|
||||||
|
|
||||||
|
param([string]$Files = "", [string]$HashList = "IPFS_hashes.txt", [string]$DF_Hashes = "checksum_list.txt")
|
||||||
|
|
||||||
|
try {
|
||||||
|
& ipfs --version
|
||||||
|
if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" }
|
||||||
|
|
||||||
|
if ($Files -eq "") { $Files = read-host "Enter file(s) or directory tree to publish" }
|
||||||
|
|
||||||
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
$Files = (get-childItem "$Files")
|
||||||
|
[int]$Count = $Files.Count
|
||||||
|
foreach ($File in $Files) {
|
||||||
|
if (test-path "$File" -pathType container) {
|
||||||
|
"Adding directory tree $File to IPFS..."
|
||||||
|
ipfs add -r "$File" > $HashList
|
||||||
|
|
||||||
|
echo "Calculating digital forensics hashes to $DF_HASHES ..."
|
||||||
|
nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$File" > $DF_Hashes
|
||||||
|
} else {
|
||||||
|
"Adding file $File to IPFS..."
|
||||||
|
ipfs add "$File" > $HashList
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
|
"✔️ published $Count files(s)/directory to IPFS in $Elapsed sec"
|
||||||
|
" NOTE: to publish it to IPNS execute: ipfs name publish <HASH>"
|
||||||
|
exit 0
|
||||||
|
} catch {
|
||||||
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
exit 1
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user