11#! /bin/bash
2- current_shell () {
3- currentShell=$( readlink /proc/" ${$} " /exe)
4- printf " using shell: %s\n" " ${currentShell} "
5- version=$( " ${currentShell} " --version)
6- printf " shell version: %s\n" " ${version} "
7- }
8- current_shell
9-
10- # show all available shells
11- cat /etc/shells
122set -eo pipefail
133
144# imports
155source ' ./utils.sh'
166
17- # get the name of an IPFS Cluster pod
18- crdName=' ipfs-sample-1'
19- labelValue=" ipfs-cluster-${crdName} "
20- labelName=' app.kubernetes.io/name'
21- ipfsClusterPodName=$( kubectl get pod -n " ${NAMESPACE} " -l " ${labelName} =${labelValue} " -o jsonpath=' {.items[0].metadata.name}' )
22-
23- # write a file to the ipfs-cluster container in the pod
24- log " writing a file to ${ipfsClusterPodName} "
25- kubectl exec -n " ${NAMESPACE} " " ${ipfsClusterPodName} " -c ipfs-cluster -- sh -c ' echo "hello from ${HOSTNAME} at $(date)" > /tmp/testfile.txt'
26- myCID=$( kubectl exec -n " ${NAMESPACE} " " ${ipfsClusterPodName} " -c ipfs-cluster -- sh -c ' ipfs-cluster-ctl add /tmp/testfile.txt' | awk ' {print $2}' )
27-
28- # read the value
29- ipfsClusterPodname2=$( kubectl get pod -n " ${NAMESPACE} " -l " ${labelName} =${labelValue} " -o jsonpath=' {.items[1].metadata.name}' )
30- log " reading a file from ${ipfsClusterPodname2} "
31- ipfsCommand=" ipfs get --output /tmp/myfile.txt -- ${myCID} "
32- kubectl exec -n " ${NAMESPACE} " " ${ipfsClusterPodname2} " -c ipfs -- sh -c " ${ipfsCommand} "
7+ main () {
8+ # get the name of an IPFS Cluster pod
9+ crdName=' ipfs-sample-1'
10+ labelValue=" ipfs-cluster-${crdName} "
11+ labelName=' app.kubernetes.io/name'
12+ ipfsClusterPodName=$( kubectl get pod -n " ${NAMESPACE} " -l " ${labelName} =${labelValue} " -o jsonpath=' {.items[0].metadata.name}' )
13+
14+ # write a file to the ipfs-cluster container in the pod
15+ log " writing a file to ${ipfsClusterPodName} "
16+ kubectl exec -n " ${NAMESPACE} " " ${ipfsClusterPodName} " -c ipfs-cluster -- sh -c ' echo "hello from ${HOSTNAME} at $(date)" > /tmp/testfile.txt'
17+ myCID=$( kubectl exec -n " ${NAMESPACE} " " ${ipfsClusterPodName} " -c ipfs-cluster -- sh -c ' ipfs-cluster-ctl add /tmp/testfile.txt' | awk ' {print $2}' )
18+
19+ # read the value
20+ ipfsClusterPodname2=$( kubectl get pod -n " ${NAMESPACE} " -l " ${labelName} =${labelValue} " -o jsonpath=' {.items[1].metadata.name}' )
21+ log " reading a file from ${ipfsClusterPodname2} "
22+ ipfsCommand=" ipfs get --output /tmp/myfile.txt -- ${myCID} "
23+ kubectl exec -n " ${NAMESPACE} " " ${ipfsClusterPodname2} " -c ipfs -- sh -c " ${ipfsCommand} "
24+ }
0 commit comments