Ubuntu 22.04 IPFS

From CompleteNoobs
Revision as of 19:13, 11 May 2023 by Noob (talk | contribs) (Created page with "Moved from 'IPFS Basics' This page is going to be just about IPFS on/for Ubuntu 22.04 Redo from scratch, below is for notes and placeholder from old page. ==Introduction to IPFS== Note that this guide was unsuccessful on a home network but worked on a Vultr VPS. IPFS requires ports 4001 TCP and UDP to be open on the router. Tested on an Ubuntu 22.04 server. Download Linux Binary from https://dist.ipfs.tech/#go-ipfs Assuming you already have LXD set up (it doesn't ha...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Please Select a Licence from the LICENCE_HEADERS page
And place at top of your page
If no Licence is Selected/Appended, Default will be CC0

Default Licence IF there is no Licence placed below this notice! When you edit this page, you agree to release your contribution under the CC0 Licence

LICENCE: More information about the cc0 licence can be found here:
https://creativecommons.org/share-your-work/public-domain/cc0

The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.

You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Licence:

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others.

For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following:

   the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;
   moral rights retained by the original author(s) and/or performer(s);
   publicity and privacy rights pertaining to a person's image or likeness depicted in a Work;
   rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below;
   rights protecting the extraction, dissemination, use and reuse of data in a Work;
   database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and
   other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose.

4. Limitations and Disclaimers.

   No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document.
   Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law.
   Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.
   Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.

Moved from 'IPFS Basics' This page is going to be just about IPFS on/for Ubuntu 22.04 Redo from scratch, below is for notes and placeholder from old page.

Introduction to IPFS

Note that this guide was unsuccessful on a home network but worked on a Vultr VPS. IPFS requires ports 4001 TCP and UDP to be open on the router.

Tested on an Ubuntu 22.04 server.

Download Linux Binary from https://dist.ipfs.tech/#go-ipfs

Assuming you already have LXD set up (it doesn't have to be in a container): Check https://dist.ipfs.tech/kubo/ for the latest version.

apt update && apt upgrade -y
wget https://dist.ipfs.tech/kubo/v0.18.1/kubo_v0.18.1_linux-amd64.tar.gz
tar xvf kubo_v0.18.1_linux-amd64.tar.gz
bash kubo/install.sh
ipfs init

You may encounter an error that looks like this:

ERROR provider.queue queue/queue.go:125 Failed to enqueue cid: leveldb: closed

This error does not impact the installation.

Now, create a simple text file. Replace $EDITOR with your preferred terminal text editor.

$EDITOR helloworld.txt

Add the following content to the file:

Hello there, I wonder how many devices I can see this on.

To share the file, you need to add and pin it:

ipfs add helloworld.txt

The command will return a CID, which looks like this:
QmQTnvc5eV7NdPfQ8zLVCr6gBrXaDAUKUd1SGDAfsPFnoh.
Now, pin the file:

ipfs pin add QmQTnvc5eV7NdPfQ8zLVCr6gBrXaDAUKUd1SGDAfsPFnoh

Connect to the network:

ipfs daemon

You can use CTRL+z to send the IPFS daemon to the background and run ipfs swarm peers to see connections. To bring the IPFS daemon back to the foreground, use bg to see background processes and then fg 1.

Note: ipfs.io is a third-party service and cannot handle data-heavy content. For heavy content, such as videos, download using IPFS to view.

To view the file in a web browser, simply add https://ipfs.io/ipfs/ to the beginning of the CID:

https://ipfs.io/ipfs/QmQTnvc5eV7NdPfQ8zLVCr6gBrXaDAUKUd1SGDAfsPFnoh

IPFS Desktop

https://github.com/ipfs/ipfs-desktop/releases

Download and share

$HASH is placeholder for the hash of the ipfs file.
To download a file:
ipfs get $HASH
To share/host you need to pin:
ipfs pin $HASH
To view pinned items
ipfs pin ls
or
ipfs pin ls --type=recursive

add directory

ipfs add --recursive /path/to/directory
each file in directory (recursive) will be uploaded and each given a hash.

unpin

ipfs pin rm $HASH

Clear cache

ipfs repo gc

View on web browser

Note: ipfs.io is a third party service, and can not handle data heavy content. For heavy content such as videos, download using ipfs to view.
Use web site/service ipfs.io
https://ipfs.io/ipfs/$HASH

Host on Server

wget https://dist.ipfs.tech/kubo/v0.18.1/kubo_v0.18.1_linux-amd64.tar.gz
tar xvf kubo_v0.18.1_linux-amd64.tar.gz
bash kubo/install.sh
ipfs init --profile server

systemd

$EDITOR /etc/systemd/system/ipfs.service

[Unit]
Description =Start ipfs daemon

[Service]
Type=simple
ExecStart=/usr/local/bin/ipfs daemon

[Install]
WantedBy=multi-user.target

systemctl enable ipfs.service
systemctl start ipfs


Note: will tidy later

NOTE: should of checked the licence first,The MIT open course ware is CC BY-NC-SA 4.0 and can not be used on this website! deleteing, leaving this here for note on how to pin mass of files.
In this example i will be uploading an MIT cc-by course to ipfs.

files in a directory called mit-test-course
ipfs add --recursive /path/to/directory
will add all the files but not pin them.

root@ipfs-test:~# tree mit-test-course/
mit-test-course/
├── 1
│   ├── 920cc911b6eb5747f2ccd431bbc4306b_lec1.py
│   ├── MIT6_0001F16_Lecture_01_300k.mp4
│   └── e921a690079369751bcce3e34da6c6ee_MIT6_0001F16_Lec1.pdf
├── 10
│   ├── 066eba6ea6d56a88e56ae325940d4c4c_MIT6_0001F16_Lec10.pdf
│   ├── MIT6_0001F16_Lecture_10_300k.mp4
│   └── bfa32fd241d88ae02cd3157aed232bac_lec10_complexity_part1.py
├── 11
│   ├── MIT6_0001F16_Lecture_11_300k.mp4
│   ├── bb953fb81d4afa3bc837c16eba613955_MIT6_0001F16_Lec11.pdf
│   └── bdf800867e6762c6758ecd2230178f41_lec11_complexity_part2.py
├── 12
│   ├── 310536cd5f5aa1fc0c11726ce13c565e_lec12_sorting.py
│   ├── 6425d0dabb1cea1a076b8c46c0ae2da6_MIT6_0001F16_Lec12.pdf
│   └── MIT6_0001F16_Lecture_12_300k.mp4
├── 2
│   ├── MIT6_0001F16_Lecture_02_300k.mp4
│   ├── ba2947b25b1580e4a84df0ec5dbe5cdd_MIT6_0001F16_Lec2.pdf
│   └── d6ee838ee4c85ace93a4e170cfd83c03_lec2_branch_loops.py
├── 3
│   ├── 88de925a1fb925e46a08bc5f34d029bd_lec3_strings_algos.py
│   ├── MIT6_0001F16_Lecture_03_300k.mp4
│   └── b9b9a82a29e8746db1facfbd30c07940_MIT6_0001F16_Lec3.pdf
├── 4
│   ├── 6ba59859535f1566dd57a7279aeba5d1_MIT6_0001F16_Lec4.pdf
│   ├── 9e8439a27af18817e046ac37333d03f6_lec4_functions.py
│   └── MIT6_0001F16_Lecture_04_300k.mp4
├── 5
│   ├── 1776670e271578eeb99fc25975f20586_MIT6_0001F16_Lec5.pdf
│   ├── MIT6_0001F16_Lecture_05_300k.mp4
│   └── cdf5f8e7f109952655f4d253ed955555_lec5_tuples_lists.py
├── 6
│   ├── 706228e592761d9c7c1c073f8ba7a6cc_lec6_recursion_dictionaries.py
│   ├── 876348c652c5353daccc96e1b7d577bb_MIT6_0001F16_Lec6.pdf
│   └── MIT6_0001F16_Lecture_06_300k.mp4
├── 7
│   ├── 51bdde43dfd773ba20747ce5d89119ac_MIT6_0001F16_Lec7.pdf
│   ├── MIT6_0001F16_Lecture_07_300k.mp4
│   └── abdd1d61892ccce9be2ad84e52004e07_lec7_debug_except.py
├── 8
│   ├── 0705ac9dcc7e637a0e8e9d97eb258a26_lec8_classes.py
│   ├── 7a6f85d03f132dcd9d7592bc4643be1c_MIT6_0001F16_Lec8.pdf
│   └── MIT6_0001F16_Lecture_08_300k.mp4
├── 9
│   ├── 2dd6c75e7b4bd6bd135078e6f3701201_MIT6_0001F16_Lec9.pdf
│   ├── MIT6_0001F16_Lecture_09_300k.mp4
│   └── bf8e8195044d5f6aefc1a455968e2f3e_lec9_inheritance.py
└── Introduction to Computer Science and Programming in Python.txt

12 directories, 37 files


ipfs add --recursive /path/to/mit-test-course > mit.txt
will upload and create a file called mit.txt with the following output:

root@ipfs-test:~# cat mit.txt 
added QmengUgSy9oY9qMXJC6ujKy7mMpunb5sG5Uo8RpFX4G5g9 mit-test-course/1/920cc911b6eb5747f2ccd431bbc4306b_lec1.py
added QmaTdTMxWdz6ySLbx258zQU5McpJTo4ZEVJ63GSKmVEyeM mit-test-course/1/MIT6_0001F16_Lecture_01_300k.mp4
added QmemB25bVuN2fuiAq3JaDM4J5MYit6HfCCsU3EFTWL7wpF mit-test-course/1/e921a690079369751bcce3e34da6c6ee_MIT6_0001F16_Lec1.pdf
added QmbyP59ttPKGe5ZNADsgqTsgBF3oYGzhZXFfBhszG2nuPm mit-test-course/10/066eba6ea6d56a88e56ae325940d4c4c_MIT6_0001F16_Lec10.pdf
added QmQNooq1g25LFp1Fxj2tfpKKMKi8NbutkhuXNf5Ppo7t5f mit-test-course/10/MIT6_0001F16_Lecture_10_300k.mp4
added QmUtgXQXjj2C3qb2UXFrPmKHkFdEjmehk4ZLQhcZ37rEmw mit-test-course/10/bfa32fd241d88ae02cd3157aed232bac_lec10_complexity_part1.py
added QmR7Ned6iZytjpVHVN6W53EZ5Qg4Zd6EkEcXxn8DjYMgrd mit-test-course/11/MIT6_0001F16_Lecture_11_300k.mp4
added QmNPjN3616QdmEWLPokwuTkLL1vrzcLVRSFLWUcukqtxZL mit-test-course/11/bb953fb81d4afa3bc837c16eba613955_MIT6_0001F16_Lec11.pdf
added QmdpwFTFkwnkqWW3CozBBAfeYHchDeVAV7ArkA1dUqbUZ4 mit-test-course/11/bdf800867e6762c6758ecd2230178f41_lec11_complexity_part2.py
added QmbV8ct8DEQyRGRDSX4PaQBXk8r8ryYLDNwTa2buC7kcP5 mit-test-course/12/310536cd5f5aa1fc0c11726ce13c565e_lec12_sorting.py
added QmToP68Knz71euVuntRWtz6UshRoiRssELJNFMeP1f2sR5 mit-test-course/12/6425d0dabb1cea1a076b8c46c0ae2da6_MIT6_0001F16_Lec12.pdf
added QmPWidAv5mBrgEcKDVqWe62JaAiwBWs8KZc1S8r3bbJsvY mit-test-course/12/MIT6_0001F16_Lecture_12_300k.mp4
added QmTFdkMJnzUcwgs1hdoF7qtADE2NqTJVaF9CfgULbzSuA9 mit-test-course/2/MIT6_0001F16_Lecture_02_300k.mp4
added QmNiZvEh6UmpHLTxw4saN7WdojzBokp2JCbucYzrekoQBK mit-test-course/2/ba2947b25b1580e4a84df0ec5dbe5cdd_MIT6_0001F16_Lec2.pdf
added QmPjEzEu56mqeE19Vth9AkDbAxz7wAWg9zMVvF9FZ1UBvK mit-test-course/2/d6ee838ee4c85ace93a4e170cfd83c03_lec2_branch_loops.py
added QmYppDgGMptihHA7ixFw2GHvspN8Bw1HY21HtUpQNxi23i mit-test-course/3/88de925a1fb925e46a08bc5f34d029bd_lec3_strings_algos.py
added QmTTCsuhbnjXWuigZLSgKAt4DjFsm78MANo3KUMGcK98s1 mit-test-course/3/MIT6_0001F16_Lecture_03_300k.mp4
added QmP2AZfUx8RTqCGamJtPyodFU8dHG8QrBHYKkP79YepEe9 mit-test-course/3/b9b9a82a29e8746db1facfbd30c07940_MIT6_0001F16_Lec3.pdf
added QmP1p4h21ogMxWeeX2PiDibQbHqWer7ABCsMrfMxEx7QBW mit-test-course/4/6ba59859535f1566dd57a7279aeba5d1_MIT6_0001F16_Lec4.pdf
added QmNtPQncXMYNBnX4NoNfx2ifetrfvrATamdrsjx4u9iQ7c mit-test-course/4/9e8439a27af18817e046ac37333d03f6_lec4_functions.py
added QmQuc5zpaJdMfRYxTLyZc5DQuota1FjuJiqgWf8ctGmRsU mit-test-course/4/MIT6_0001F16_Lecture_04_300k.mp4
added QmSdxg2inPbK1FSynNdPUka6CUZtEGG6sdPZgxaAgb46GE mit-test-course/5/1776670e271578eeb99fc25975f20586_MIT6_0001F16_Lec5.pdf
added Qmco5sKKQfnWUNP9ZUxLkDhoV6jfjv8L4AdzES7En41AzP mit-test-course/5/MIT6_0001F16_Lecture_05_300k.mp4
added QmThDori5ETa3U27DFpndU7RmsLgG7zjpqGVxAncCupSuc mit-test-course/5/cdf5f8e7f109952655f4d253ed955555_lec5_tuples_lists.py
added QmaGhNYnR5yUMYZf4q7qLsNwEW6B7pbLbgJokJBTNSA2FT mit-test-course/6/706228e592761d9c7c1c073f8ba7a6cc_lec6_recursion_dictionaries.py
added QmQAqSGJAeoypUMyUnb7hRrziDyRAwymcTGdcaydT5i73s mit-test-course/6/876348c652c5353daccc96e1b7d577bb_MIT6_0001F16_Lec6.pdf
added QmVzK3PVETv69Y27UKDfaQQM5um8ByMdYQS3TzD2EkoR42 mit-test-course/6/MIT6_0001F16_Lecture_06_300k.mp4
added QmcqZoeVrsfBv4Ri6M8KtiLdy3VpKnyznDFhX8zvfd3Qrs mit-test-course/7/51bdde43dfd773ba20747ce5d89119ac_MIT6_0001F16_Lec7.pdf
added QmUyiqpAUA91w4Xm2Dz2wPr6kE6wTzA1apwJziTdBysRLw mit-test-course/7/MIT6_0001F16_Lecture_07_300k.mp4
added QmeVKCB6ponYr4f72MuNwegukX9t42NTywNHpDPgyNi9ae mit-test-course/7/abdd1d61892ccce9be2ad84e52004e07_lec7_debug_except.py
added QmQCaZZA75UQ5pAKy8zhcz6Ci8yY13UVHUvsuXmid86GUH mit-test-course/8/0705ac9dcc7e637a0e8e9d97eb258a26_lec8_classes.py
added QmdccChFuYBCiLmufEmk6oXCHybaUQiPXajD3c3xMupiaC mit-test-course/8/7a6f85d03f132dcd9d7592bc4643be1c_MIT6_0001F16_Lec8.pdf
added QmZFSSPndvRfPT2vyehuyEQitfb8CzdYkA7orFAKyvhA4u mit-test-course/8/MIT6_0001F16_Lecture_08_300k.mp4
added QmbaJFk4mFRmCbtQybK94etyfRA2LcM22Kfvjbvdf6X8Gw mit-test-course/9/2dd6c75e7b4bd6bd135078e6f3701201_MIT6_0001F16_Lec9.pdf
added QmdENonCipE7TK99i7dFz9paqDUSefR4PFdveEmVi5oXAb mit-test-course/9/MIT6_0001F16_Lecture_09_300k.mp4
added QmQ7UB4PaGBRHvHfDshrASwynvansFVXrp3RNULwhThUsC mit-test-course/9/bf8e8195044d5f6aefc1a455968e2f3e_lec9_inheritance.py
added Qmdw2XaaX99t7eNzRNXdHEHYzwiH5qhg1iBLDpekCXj5am mit-test-course/Introduction to Computer Science and Programming in Python.txt
added QmQM6QEJK9kJGzxe1ntDKrE7nLtB9CPqupjQZvsEze6rkK mit-test-course/1
added QmX7ZEHg2WipkSbwani5iSwxtBPgghajtGP1QqJQ6jQAAE mit-test-course/10
added QmaUyBU3M5zFpeHrMdZbapSLf73SUHZaookrCRCRm87Jwb mit-test-course/11
added QmP3Xx9cUp9Ly44bP1TXQHziVpLpNuZDnH7nRhdQTJPk5w mit-test-course/12
added QmYQQLN4pEdKi7S8GJJLFtw4LCEiZPkUzRjyNJqNcrU7kS mit-test-course/2
added QmZvUavbLwZ5PjiadoGSvB8nURGaeDiTyNivZq9tsPN1dD mit-test-course/3
added QmWf7uJtJmBhLB4sAsWUDWGwPyz24yboHYqxZGpEAwP4Gx mit-test-course/4
added QmPAApNSDbgZnr1tVe77zPx8bz3USsP4UZxA6nCCSMEbRx mit-test-course/5
added QmPMEUkViQsT7XwfPxwque3EfmPs1kaVJCU5Bc8AujYfej mit-test-course/6
added QmWnzp23vzhx8rX5z7W9WZVWGq2H8j18GmqddbHRa79jX1 mit-test-course/7
added QmRnosvcFPgEZSGMyRw9uuTyDzcQf6Q2ffEXADYEFvqtsN mit-test-course/8
added QmeUE3L3gwNvK3BvcutttWxSJPn7RusxNZHzTQeYUNGzjw mit-test-course/9
added QmY965P9FuqBum5Ppy7QWUf1HBRVdqDbMFVDStBdjNnjqk mit-test-course

Now we are going to use awk to just print out the hashes.
cat mit.txt | awk '{print $2}' >hash.txt
cat hash.txt will return:

root@ipfs-test:~# cat hash.txt 
QmengUgSy9oY9qMXJC6ujKy7mMpunb5sG5Uo8RpFX4G5g9
QmaTdTMxWdz6ySLbx258zQU5McpJTo4ZEVJ63GSKmVEyeM
QmemB25bVuN2fuiAq3JaDM4J5MYit6HfCCsU3EFTWL7wpF
QmbyP59ttPKGe5ZNADsgqTsgBF3oYGzhZXFfBhszG2nuPm
QmQNooq1g25LFp1Fxj2tfpKKMKi8NbutkhuXNf5Ppo7t5f
QmUtgXQXjj2C3qb2UXFrPmKHkFdEjmehk4ZLQhcZ37rEmw
QmR7Ned6iZytjpVHVN6W53EZ5Qg4Zd6EkEcXxn8DjYMgrd
QmNPjN3616QdmEWLPokwuTkLL1vrzcLVRSFLWUcukqtxZL
QmdpwFTFkwnkqWW3CozBBAfeYHchDeVAV7ArkA1dUqbUZ4
QmbV8ct8DEQyRGRDSX4PaQBXk8r8ryYLDNwTa2buC7kcP5
QmToP68Knz71euVuntRWtz6UshRoiRssELJNFMeP1f2sR5
QmPWidAv5mBrgEcKDVqWe62JaAiwBWs8KZc1S8r3bbJsvY
QmTFdkMJnzUcwgs1hdoF7qtADE2NqTJVaF9CfgULbzSuA9
QmNiZvEh6UmpHLTxw4saN7WdojzBokp2JCbucYzrekoQBK
QmPjEzEu56mqeE19Vth9AkDbAxz7wAWg9zMVvF9FZ1UBvK
QmYppDgGMptihHA7ixFw2GHvspN8Bw1HY21HtUpQNxi23i
QmTTCsuhbnjXWuigZLSgKAt4DjFsm78MANo3KUMGcK98s1
QmP2AZfUx8RTqCGamJtPyodFU8dHG8QrBHYKkP79YepEe9
QmP1p4h21ogMxWeeX2PiDibQbHqWer7ABCsMrfMxEx7QBW
QmNtPQncXMYNBnX4NoNfx2ifetrfvrATamdrsjx4u9iQ7c
QmQuc5zpaJdMfRYxTLyZc5DQuota1FjuJiqgWf8ctGmRsU
QmSdxg2inPbK1FSynNdPUka6CUZtEGG6sdPZgxaAgb46GE
Qmco5sKKQfnWUNP9ZUxLkDhoV6jfjv8L4AdzES7En41AzP
QmThDori5ETa3U27DFpndU7RmsLgG7zjpqGVxAncCupSuc
QmaGhNYnR5yUMYZf4q7qLsNwEW6B7pbLbgJokJBTNSA2FT
QmQAqSGJAeoypUMyUnb7hRrziDyRAwymcTGdcaydT5i73s
QmVzK3PVETv69Y27UKDfaQQM5um8ByMdYQS3TzD2EkoR42
QmcqZoeVrsfBv4Ri6M8KtiLdy3VpKnyznDFhX8zvfd3Qrs
QmUyiqpAUA91w4Xm2Dz2wPr6kE6wTzA1apwJziTdBysRLw
QmeVKCB6ponYr4f72MuNwegukX9t42NTywNHpDPgyNi9ae
QmQCaZZA75UQ5pAKy8zhcz6Ci8yY13UVHUvsuXmid86GUH
QmdccChFuYBCiLmufEmk6oXCHybaUQiPXajD3c3xMupiaC
QmZFSSPndvRfPT2vyehuyEQitfb8CzdYkA7orFAKyvhA4u
QmbaJFk4mFRmCbtQybK94etyfRA2LcM22Kfvjbvdf6X8Gw
QmdENonCipE7TK99i7dFz9paqDUSefR4PFdveEmVi5oXAb
QmQ7UB4PaGBRHvHfDshrASwynvansFVXrp3RNULwhThUsC
Qmdw2XaaX99t7eNzRNXdHEHYzwiH5qhg1iBLDpekCXj5am
QmQM6QEJK9kJGzxe1ntDKrE7nLtB9CPqupjQZvsEze6rkK
QmX7ZEHg2WipkSbwani5iSwxtBPgghajtGP1QqJQ6jQAAE
QmaUyBU3M5zFpeHrMdZbapSLf73SUHZaookrCRCRm87Jwb
QmP3Xx9cUp9Ly44bP1TXQHziVpLpNuZDnH7nRhdQTJPk5w
QmYQQLN4pEdKi7S8GJJLFtw4LCEiZPkUzRjyNJqNcrU7kS
QmZvUavbLwZ5PjiadoGSvB8nURGaeDiTyNivZq9tsPN1dD
QmWf7uJtJmBhLB4sAsWUDWGwPyz24yboHYqxZGpEAwP4Gx
QmPAApNSDbgZnr1tVe77zPx8bz3USsP4UZxA6nCCSMEbRx
QmPMEUkViQsT7XwfPxwque3EfmPs1kaVJCU5Bc8AujYfej
QmWnzp23vzhx8rX5z7W9WZVWGq2H8j18GmqddbHRa79jX1
QmRnosvcFPgEZSGMyRw9uuTyDzcQf6Q2ffEXADYEFvqtsN
QmeUE3L3gwNvK3BvcutttWxSJPn7RusxNZHzTQeYUNGzjw
QmY965P9FuqBum5Ppy7QWUf1HBRVdqDbMFVDStBdjNnjqk

Can do in terminal but will make bash script.
$EDITOR pin-hash.sh

#!/bin/bash
while read p; do
        ipfs pin add $p
done <hash.txt


bash pin-hash.sh

root@ipfs-test:~# bash pin-hash.sh 
pinned QmengUgSy9oY9qMXJC6ujKy7mMpunb5sG5Uo8RpFX4G5g9 recursively
pinned QmaTdTMxWdz6ySLbx258zQU5McpJTo4ZEVJ63GSKmVEyeM recursively
pinned QmemB25bVuN2fuiAq3JaDM4J5MYit6HfCCsU3EFTWL7wpF recursively
pinned QmbyP59ttPKGe5ZNADsgqTsgBF3oYGzhZXFfBhszG2nuPm recursively
pinned QmQNooq1g25LFp1Fxj2tfpKKMKi8NbutkhuXNf5Ppo7t5f recursively
pinned QmUtgXQXjj2C3qb2UXFrPmKHkFdEjmehk4ZLQhcZ37rEmw recursively
pinned QmR7Ned6iZytjpVHVN6W53EZ5Qg4Zd6EkEcXxn8DjYMgrd recursively
pinned QmNPjN3616QdmEWLPokwuTkLL1vrzcLVRSFLWUcukqtxZL recursively
pinned QmdpwFTFkwnkqWW3CozBBAfeYHchDeVAV7ArkA1dUqbUZ4 recursively
pinned QmbV8ct8DEQyRGRDSX4PaQBXk8r8ryYLDNwTa2buC7kcP5 recursively
pinned QmToP68Knz71euVuntRWtz6UshRoiRssELJNFMeP1f2sR5 recursively
pinned QmPWidAv5mBrgEcKDVqWe62JaAiwBWs8KZc1S8r3bbJsvY recursively
pinned QmTFdkMJnzUcwgs1hdoF7qtADE2NqTJVaF9CfgULbzSuA9 recursively
pinned QmNiZvEh6UmpHLTxw4saN7WdojzBokp2JCbucYzrekoQBK recursively
pinned QmPjEzEu56mqeE19Vth9AkDbAxz7wAWg9zMVvF9FZ1UBvK recursively
pinned QmYppDgGMptihHA7ixFw2GHvspN8Bw1HY21HtUpQNxi23i recursively
pinned QmTTCsuhbnjXWuigZLSgKAt4DjFsm78MANo3KUMGcK98s1 recursively
pinned QmP2AZfUx8RTqCGamJtPyodFU8dHG8QrBHYKkP79YepEe9 recursively
pinned QmP1p4h21ogMxWeeX2PiDibQbHqWer7ABCsMrfMxEx7QBW recursively
pinned QmNtPQncXMYNBnX4NoNfx2ifetrfvrATamdrsjx4u9iQ7c recursively
pinned QmQuc5zpaJdMfRYxTLyZc5DQuota1FjuJiqgWf8ctGmRsU recursively
pinned QmSdxg2inPbK1FSynNdPUka6CUZtEGG6sdPZgxaAgb46GE recursively
pinned Qmco5sKKQfnWUNP9ZUxLkDhoV6jfjv8L4AdzES7En41AzP recursively
pinned QmThDori5ETa3U27DFpndU7RmsLgG7zjpqGVxAncCupSuc recursively
pinned QmaGhNYnR5yUMYZf4q7qLsNwEW6B7pbLbgJokJBTNSA2FT recursively
pinned QmQAqSGJAeoypUMyUnb7hRrziDyRAwymcTGdcaydT5i73s recursively
pinned QmVzK3PVETv69Y27UKDfaQQM5um8ByMdYQS3TzD2EkoR42 recursively
pinned QmcqZoeVrsfBv4Ri6M8KtiLdy3VpKnyznDFhX8zvfd3Qrs recursively
pinned QmUyiqpAUA91w4Xm2Dz2wPr6kE6wTzA1apwJziTdBysRLw recursively
pinned QmeVKCB6ponYr4f72MuNwegukX9t42NTywNHpDPgyNi9ae recursively
pinned QmQCaZZA75UQ5pAKy8zhcz6Ci8yY13UVHUvsuXmid86GUH recursively
pinned QmdccChFuYBCiLmufEmk6oXCHybaUQiPXajD3c3xMupiaC recursively
pinned QmZFSSPndvRfPT2vyehuyEQitfb8CzdYkA7orFAKyvhA4u recursively
pinned QmbaJFk4mFRmCbtQybK94etyfRA2LcM22Kfvjbvdf6X8Gw recursively
pinned QmdENonCipE7TK99i7dFz9paqDUSefR4PFdveEmVi5oXAb recursively
pinned QmQ7UB4PaGBRHvHfDshrASwynvansFVXrp3RNULwhThUsC recursively
pinned Qmdw2XaaX99t7eNzRNXdHEHYzwiH5qhg1iBLDpekCXj5am recursively
pinned QmQM6QEJK9kJGzxe1ntDKrE7nLtB9CPqupjQZvsEze6rkK recursively
pinned QmX7ZEHg2WipkSbwani5iSwxtBPgghajtGP1QqJQ6jQAAE recursively
pinned QmaUyBU3M5zFpeHrMdZbapSLf73SUHZaookrCRCRm87Jwb recursively
pinned QmP3Xx9cUp9Ly44bP1TXQHziVpLpNuZDnH7nRhdQTJPk5w recursively
pinned QmYQQLN4pEdKi7S8GJJLFtw4LCEiZPkUzRjyNJqNcrU7kS recursively
pinned QmZvUavbLwZ5PjiadoGSvB8nURGaeDiTyNivZq9tsPN1dD recursively
pinned QmWf7uJtJmBhLB4sAsWUDWGwPyz24yboHYqxZGpEAwP4Gx recursively
pinned QmPAApNSDbgZnr1tVe77zPx8bz3USsP4UZxA6nCCSMEbRx recursively
pinned QmPMEUkViQsT7XwfPxwque3EfmPs1kaVJCU5Bc8AujYfej recursively
pinned QmWnzp23vzhx8rX5z7W9WZVWGq2H8j18GmqddbHRa79jX1 recursively
pinned QmRnosvcFPgEZSGMyRw9uuTyDzcQf6Q2ffEXADYEFvqtsN recursively
pinned QmeUE3L3gwNvK3BvcutttWxSJPn7RusxNZHzTQeYUNGzjw recursively
pinned QmY965P9FuqBum5Ppy7QWUf1HBRVdqDbMFVDStBdjNnjqk recursively


bash script to pin recursive directory to IPFS

to use script.sh /path/to/directory

#!/bin/bash

# Check if directory argument is provided
if [ -z "$1" ]; then
  echo "Usage: script.sh /path/to/directory"
  exit 1
fi

# Check if IPFS is installed
if ! command -v ipfs &> /dev/null; then
  echo "IPFS is not installed. Please install it first."
  exit 1
fi

# Set directory path and filenames
dir_path="$1"
ipfs_list="/tmp/ipfs_$(date +'%Y%m%d%H%M%S').list"
ipfs_hash="/tmp/ipfs_$(date +'%Y%m%d%H%M%S').hash"

# Add directory to IPFS and save output to temporary file
ipfs add --recursive "$dir_path" > "$ipfs_list"

# Extract IPFS hashes from list and save to temporary file
cat "$ipfs_list" | awk '{print $2}' > "$ipfs_hash"

# Pin each hash from temporary file
while read -r hash; do
  ipfs pin add "$hash"
done < "$ipfs_hash"

# Clean up temporary files
rm "$ipfs_list" "$ipfs_hash"

Here's how the script works:

It first checks if a directory path argument is provided. If not, it prints the usage instructions and exits.
It checks if IPFS is installed by checking if the ipfs command is available. If not, it prints an error message and exits.
It sets the directory path and temporary filenames for the IPFS list and hash.
It adds the specified directory to IPFS recursively using the ipfs add command and saves the output to the temporary IPFS list file.
It extracts the IPFS hashes from the list file and saves them to the temporary IPFS hash file.
It loops through each hash in the temporary hash file and pins it using the ipfs pin add command.
Finally, it cleans up the temporary files.

Note that this script will create new temporary files with a timestamp appended to the filename each time it is run. This is to avoid overwriting any existing temporary files with the same name.