#!/bin/bash
if [[ ! $(ipfs p2p ls | grep x/ssh-12D3KooWLr49P2rvpN8UgGPDWW8d38JdXcn26uYc3utzbusTmdLm) ]]; then
    ipfs --timeout=10s ping -n 4 /p2p/12D3KooWLr49P2rvpN8UgGPDWW8d38JdXcn26uYc3utzbusTmdLm
    [[ $? == 0 ]] \
        && ipfs p2p forward /x/ssh-12D3KooWLr49P2rvpN8UgGPDWW8d38JdXcn26uYc3utzbusTmdLm /ip4/127.0.0.1/tcp/22130 /p2p/12D3KooWLr49P2rvpN8UgGPDWW8d38JdXcn26uYc3utzbusTmdLm \
        && ssh \$USER@127.0.0.1 -p 22130 \
        || echo "CONTACT IPFSNODEID FAILED - ERROR -"
fi

