Skip to content

Instantly share code, notes, and snippets.

@kaz-tk
Created March 1, 2021 00:11
Show Gist options
  • Save kaz-tk/05765b993856a04f0a5e722f4c6dc3ab to your computer and use it in GitHub Desktop.
Save kaz-tk/05765b993856a04f0a5e722f4c6dc3ab to your computer and use it in GitHub Desktop.
#!/bin/bash
ARGS=$1
d=$(date +%Y%m%d-%H%M%S-%3N)
export > /tmp/calico-${d}-env
echo $@ > /tmp/calico-${d}-args
buf=""
if [ -p /dev/stdin ];then
buf=$(cat -)
echo $buf > /tmp/calico-${d}-stdin
echo $buf | /opt/cni/bin/calico
else
/opt/cni/bin/calico
fi
#!/bin/bash
ARGS=$1
d=$(date +%Y%m%d-%H%M%S-%3N)
export > /tmp/logger-${d}-env
echo $@ > /tmp/logger-${d}-args
if [ -p /dev/stdin ]; then
cat - >/tmp/logger-${d}-stdin
else
:
fi
count=1
if [ "$CNI_COMMAND" == "ADD" ]; then
echo '{"cniVersion":"0.4.0","interfaces":['$interfaces'],"ips":['$ips'],"dns":{}}'
fi
if [ "$CNI_COMMAND" == "DEL" ]; then
echo '{}'
fi
if [ "$CNI_COMMAND" == "VERSION" ]; then
echo '{"cniVersion": "0.4.0", "supportedVersions": [ "0.1.0", "0.2.0", "0.3.0", "0.3.1", "0.4.0" ]}'
fi
if [ "$CNI_COMMAND" == "GET" ]; then
echo '{"cniVersion":"0.4.0","interfaces":['$interfaces'],"ips":['$ips'],"dns":{}}'
fi#!/bin/bash
ARGS=$1
d=$(date +%Y%m%d-%H%M%S-%3N)
export > /tmp/logger-${d}-env
echo $@ > /tmp/logger-${d}-args
if [ -p /dev/stdin ]; then
cat - >/tmp/logger-${d}-stdin
else
:
fi
count=1
if [ "$CNI_COMMAND" == "ADD" ]; then
echo '{"cniVersion":"0.4.0","interfaces":['$interfaces'],"ips":['$ips'],"dns":{}}'
fi
if [ "$CNI_COMMAND" == "DEL" ]; then
echo '{}'
fi
if [ "$CNI_COMMAND" == "VERSION" ]; then
echo '{"cniVersion": "0.4.0", "supportedVersions": [ "0.1.0", "0.2.0", "0.3.0", "0.3.1", "0.4.0" ]}'
fi
if [ "$CNI_COMMAND" == "GET" ]; then
echo '{"cniVersion":"0.4.0","interfaces":['$interfaces'],"ips":['$ips'],"dns":{}}'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment