Friday, February 1, 2019

ipfs


windows install


unzip ( ipfs.exe), you need this directory in your path (environmental variable)

system path
user path

add:  path=F:\ipfs

reboot not required, it should effect immediately.

BUT

sometime it doesn't work.

temporary run ipfs.exe in itself folder.







.........................change  ipfs_repo from default .../your-user/.ipfs (hidden folder)................ 

environmental path set: (windows use \, if you use / invalid, Mac use / )

IPFS_PATH=F:\ipfs_repo

----------------------
cmd,  manually set

         F:\ipfs>set IPFS_PATH=F:\ipfs_repo


verify:

         F:\ipfs>echo %IPFS_PATH%
         F:\ipfs_repo


now,

         F:\ipfs>ipfs init
         initializing IPFS node at F:\ipfs_repo        

it should use your custom repo, not use default .../your-user/.ipfs

-------------------


ipfs-desktop-0.6.1 ("C:\Program Files\IPFS Desktop\IPFS Desktop.exe") for all user

ipfs-desktop-0.7.0 ("C:\Users\52406\AppData\Local\Programs\ipfs-desktop") for only you






--------------------------------

C:\Users\engcid299\AppData\Roaming\IPFS Desktop\config.json

ipfs desktop, before 0.6.1, need update config.json the new ipfs_repo
after 0.7, no need update here, because desktop will use whatever ipfs daemon use ipfs_repo path



The configuration file and logs are located on ~/Library/Application Support/IPFS Desktop on macOS and %appdata%/IPFS Desktop on Windows. For quick access to this folders, just right-click on your tray icon and then 'Logs Directory' or 'Configuration File', depending on what you want.

--------------------------------





+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

mac install


1) install ipfs

Error:

bills-mac-mini:~ Bill$ cd go-ipfs
bills-mac-mini:go-ipfs Bill$ ls
LICENSE        README.md    build-log    install.sh    ipfs
bills-mac-mini:go-ipfs Bill$ ./install.sh
We cannot install ./ipfs in one of the directories /usr/local/bin /usr/bin
It seems that we do not have the necessary write permissions.
Perhaps try running this script as a privileged user:

    sudo ./install.sh


=======================

reason is you do not have /usr/local/bin folder, you need manually create one, then run again.

or you could just manually copy ipfs.exe to /usr/local/bin.
open install.sh, see, it copy over file with mv.......

cd /
cd usr/local
sudo mkdir bin

another terminal,  
bills-mac-mini:~ Bill$ cd go-ipfs
bills-mac-mini:go-ipfs Bill$ ./install.sh

success.

 2) install ipfs desktop for mac

unzip,

open, you see ipfs icon show at task bar

But on windows, ipfs icon do not show on task bar, but you can see ipfs process at task manager.



3) localhost:5001/webui

done.

**************************************************************************

When run


    ipfs add -r ..... You must shut down ipfs daemon, because it will slow down the ipfs add process.


ipfs add -r and ipfs daemon can NOT both run at same time.
Because they will slow down each other, conflict. 




++++++++++++++++++++++++++++++++++++++++++++++++++++++

Once you've added a directory, you can get the hashes of the files in the directory by running either:

ipfs files stat --hash /ipfs/DIR_HASH/path/to/file` to get the hash of an individual file.
ipfs ls /ipfs/DIR_HASH` to list the hashes/names of all the files in a directory.

Note: If you're adding a massive directory, you'll need to enable (directory sharding](https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#directory-sharding--hamt) (which is an experimental feature).



+++++++++++++++++++++++++++++++++++++++++++++++
for Mac only,

/users/bill/.bash_profile

edit this file,

sudo nano .bash_profile



export IPFS_PATH=/Volumes/ipfs1/ipfs_repo
sudo launchctl limit maxfiles 65536 200000




when finish edit, ctrl+x, Y, Enter

+++++++++++++++++++++++++++++++++++++++++

By default,  ipfs daemon will create a hidden folder repo folder at
your-user-home/.ipfs

if you want it change to D drive, D volume,
You have to set  (windows)  IPFS_PATH=D:/ipfs_repo
(mac) export IPFS_PATH=/Volumes/ipfs1/ipfs_repo


If you want ipfs-desktop use new ipfs_repo, you have to do following


...............
Windows:

ipfs repo
          will list all help

ipfs repo stat
       
           will list current repo path ( which read from IPFS_PATH=D:/ipfs_repo environment variable)
            default is (c:/users/you/.ipfs)



Before you run ipfs daemon or ipfs desktop, you need to set ipfs repo(block, datastore etc)
run
ipfs init
           will use your current ipfs_path as repo location.


Now you are ready to run ipfs daemon,

 Because of bug of ipfs desktop, you need to manually config new repo_path, othewise, it always use default \.ipfs


I can manually update config.json file, let it point to customized ipfs repo directory.
It works fine.

On windows,
C:\Users\your-user-name-here\AppData\Roaming\IPFS Desktop

open config.json

```
          update the path
```
"ipfsConfig": {
"type": "go",
"path": "D:\ipfs_repo",
"flags": [
"--migrate=true",
"--routing=dhtclient"
],
"keysize": 2048
},




On Mac:

(library is hidden directory, cmd+shift+. to show hidden)

$your-user-home/Library/Application Support/IPFS Desktop

Edit config.json

"path": "/Volumes/ipfs-1tb/ipfs_repo",




------------


NOTE : ipfs-desktop

  • IPFS_PATH is only used the first time IPFS Desktop runs. After that, its configuration is its source of truth.
  • We're using ipfsd-ctl which takes care of that. Also, we have tests for custom IPFS_PATH and they're passing on macOS.


***************************************************************

Where is the configuration and logs?

The configuration file and logs are located on ~/Library/Application Support/IPFS Desktop on macOS and %appdata%/IPFS Desktop on Windows. For quick access to this folders, just right-click on your tray icon and then 'Logs Directory' or 'Configuration File', depending on what you want.

How do we select the IPFS repo location?

We use ipfsd-ctl, which, in default conditions, will check IPFS_PATH environment variable. If not set, we fallback to $HOME/.ipfs. As soon as the first run has succeded, we save the information about the repository location in the configuration file, which becomes the source of truth.

Which version of IPFS are we running?

Since we're using ipfsd-ctl, we have our own embedded IPFS binary. We try to always have the latest version.

Which flags do we use to boot IPFS?

By default we use the flags --migrate=true --routing=dhtclient ----enable-gc=true when running the IPFS daemon. They can be changed via the configuration file, which can be easily accessed as mentioned above.

***************************************************************







.................. note ................................................................................
when  ipfs runing, repo.lock file will show in ipfs_repo directory,
if ipfs is down, repo.lock will disappear.

but some time, a old repo.lock file in ipfs repository folder will cause error, failed to start ipfs daemon
To remove repo.lock file

ipfs repo (list help)
ipfs repo fsck ( will remove the repo.lock file)
.................................................................................







++++++++++++++++++++++++++++++++++++++++++++++

change ipfs repo to other disk:


ipfs daemon, will look for IPFS_PATH environment variable, to decide where put ipfs repository.

If no IPFS_PATH found, by default, location is:

Mac:
$user\.ifps   (show hidden files, command + shift + .)

Windows:
\user\.ipfs    (show hidden directory)

.........................................
Customize ipfs repo to another disk, by set IPFS_PATH environment variable.

Windows,
                       add system environment variable
                       IPFS_PATH=D:\ipfs_repo

Mac,

      terminal run 'env'  or 'printenv'           
                  will list all environment variable,
      if no IPFS_PATH=/Volumes/d/ipfs_repo
      you need to set.

      for 1 time temporary , cmd run
      export IPFS_PATH=/Volumes/d/ipfs_repo

      If you want permanent set this, do this:
             Mac uses bash shell, so the environment variables can be added to the .bash_profile directory, for the current user
             This file at :    user$ ~/.bash_profile
               Open and edit this file:
                                       user$ nano .bash_profile

               write:  export IPFS_PATH=/Volumes/d/ipfs_repo
         
     
Press ctrl+X to exit the editor. Press ‘Y’ for saving the buffer, Press "Enter" to return cmd. 









-------------------------------------------------------


Add directory by:



             1)             ipfs add -r fileRestAPI



added QmcXbRoSrnmqwVFms3t9iX6DZMtKfUB9PJj6j8HQp59Ubj fileRestAPI

Your hash ID is above


              2)            ipfs name publish QmcXbRoSrnmqwVFms3t9iX6DZMtKfUB9PJj6j8HQp59Ubj


Published to QmbX1mn42J9Fh7ascyaX2txtqRxRNFg3NWMXFr8k6HqKBj: /ipfs/QmcXbRoSrnmqwVFms3t9iX6DZMtKfUB9PJj6j8HQp59Ubj


You get your peer ID above


Test by name resolve below:
     
            3)       ipfs name resolve QmbX1mn42J9Fh7ascyaX2txtqRxRNFg3NWMXFr8k6HqKBj
/ipfs/QmcXbRoSrnmqwVFms3t9iX6DZMtKfUB9PJj6j8HQp59Ubj


you can test web site at
           https://ipfs.io/ipns/
           https://ipfs.io/ipns/QmbX1mn42J9Fh7ascyaX2txtqRxRNFg3NWMXFr8k6HqKBj



5. Bind IPNS to domain by adding a DNS TXT record of the form

Yes, it works for me after 1 hour.  try and fail.

Let me summarize the working sample.

working sample:

local gateway 
http://127.0.0.1:8080/ipfs/QmcXbRoSrnmqwVFms3t9iX6DZMtKfUB9PJj6j8HQp59Ubj
http://127.0.0.1:8080/ipns/QmbX1mn42J9Fh7ascyaX2txtqRxRNFg3NWMXFr8k6HqKBj

publick gateway
https://ipfs.io/ipfs/QmcXbRoSrnmqwVFms3t9iX6DZMtKfUB9PJj6j8HQp59Ubj
https://ipfs.io/ipns/QmbX1mn42J9Fh7ascyaX2txtqRxRNFg3NWMXFr8k6HqKBj


Now I bind domain 'pdfbay.org' DNS txt record 

@ means current domain pdfbay.org
TXT: type
1m:  1 second ( default is 1 hour, but I set it as 1m for quick)

@ | TXT | 1m | "dnslink=/ipns/QmbX1mn42J9Fh7ascyaX2txtqRxRNFg3NWMXFr8k6HqKBj"


To verify  on terminal, I try ipfs name resolve, it works fine, 

D:\>ipfs name resolve -r pdfbay.org
/ipfs/QmcXbRoSrnmqwVFms3t9iX6DZMtKfUB9PJj6j8HQp59Ubj


To verify on DNS txt lookup tool, you can verify you DNS TXT record is correctly configured.
https://mxtoolbox.com/SuperTool.aspx
put your domain, pdfbay.org, then choose TXT lookup. 
you should see 1 record below:
TXT | pdfbay.org | 60 sec | dnslink=/ipns/QmbX1mn42J9Fh7ascyaX2txtqRxRNFg3NWMXFr8k6HqKBj



Even you config correctly ,
it need some time, may be up to 1 hours to have ipfs bind works, 

The final working sample is: 
http://localhost:8080/ipns/pdfbay.org
https://ipfs.io/ipns/pdfbay.org









.........................
ipfs chrome extension
https://github.com/ipfs-shipyard/ipfs-companion#ipfs-companion


IPFS Addressing in Web Browsers
https://github.com/ipfs/in-web-browsers/blob/master/ADDRESSING.md



ipfs://{immutable-root}/path/to/resourceA → /ipfs/{immutable-root}/path/to/resourceA
ipns://{mutable-root}/path/to/resourceB → /ipns/{mutable-root}/path/to/resourceB


ipfs://QmcXbRoSrnmqwVFms3t9iX6DZMtKfUB9PJj6j8HQp59Ubj
public gateway
https://ipfs.io/ipfs/QmcXbRoSrnmqwVFms3t9iX6DZMtKfUB9PJj6j8HQp59Ubj





ipns://QmbX1mn42J9Fh7ascyaX2txtqRxRNFg3NWMXFr8k6HqKBj
local gateway
http://127.0.0.1:8080/ipns/QmbX1mn42J9Fh7ascyaX2txtqRxRNFg3NWMXFr8k6HqKBj

.................................................................


























+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

mac install


1) install ipfs

Error:

bills-mac-mini:~ Bill$ cd go-ipfs
bills-mac-mini:go-ipfs Bill$ ls
LICENSE        README.md    build-log    install.sh    ipfs
bills-mac-mini:go-ipfs Bill$ ./install.sh
We cannot install ./ipfs in one of the directories /usr/local/bin /usr/bin
It seems that we do not have the necessary write permissions.
Perhaps try running this script as a privileged user:

    sudo ./install.sh


=======================

reason is you do not have /usr/local/bin folder, you need manually create one, then run again.

or you could just manually copy ipfs.exe to /usr/local/bin.
open install.sh, see, it copy over file with mv.......

cd /
cd usr/local
sudo mkdir bin

another terminal,    
bills-mac-mini:~ Bill$ cd go-ipfs
bills-mac-mini:go-ipfs Bill$ ./install.sh

success.

 2) install ipfs desktop for mac

unzip,

open, you see ipfs icon show at task bar

But on windows, ipfs icon do not show on task bar, but you can see ipfs process at task manager.



3) localhost:5001/webui

done.

=====================================================



too many open files mac



Configuring Your New File Limits

Once you’ve logged in, you should once again open Terminal. In Terminal, type the following command:
sudo nano /Library/LaunchDaemons/limit.maxfiles.plist
Copy and paste the following content into the text editor that’s opened in your Terminal window. Provide your user password, if prompted.
 

 
 
 Label
 limit.maxfiles
 ProgramArguments
 
 launchctl
 limit
 maxfiles
 64000
 524288
 
 RunAtLoad
 
 ServiceIPC
 
 
Note that to do this, you likely won’t be able to use the keyboard shortcut. Instead, right-click inside the Terminal window and choose paste. Then, press Control-X to save and close the text editor.
You’ll notice two numbers there: 64000 and 524288. The first is a soft limit, at which point your Mac will start preparing to stop allowing new file opens but still let them go. When the second number is reached, that’s the hard limit – at that point, you’ll get the “Too many files open in system” error.


No comments: