Browse Source

add tools

master
zeus 3 years ago
parent
commit
9fe2c2160c
  1. 61
      tools/poc-dummy-create
  2. 69
      tools/poc-dummy-log
  3. 52
      tools/poc-dummy-ls
  4. 69
      tools/poc-dummy-rm
  5. 75
      tools/poc-dummy-send

61
tools/poc-dummy-create

@ -0,0 +1,61 @@
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
#echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
#echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
SRPATH="$( dirname "$SOURCE" )"
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$SFPATH" != "$SRPATH" ]; then
RDIR=$SRPATH # relativ path directory
fi
cwdir=$PWD
wdir=$SFPATH
[ $# -eq 0 ] && { echo "Usage: $0 device-name"; exit 1; }
[ -z "$1" ] && { echo "Usage: $0 device-name"; exit 1; }
dir="$1"
dir1=/var/log-in/$dir
ex=$(docker exec -it dummy_service /bin/bash -c "mkdir \"/var/log-in/$dir\"")
(docker exec -i dummy_service sh -c "cat > /tmp/send.sh") <<EOF
if [ -d "$dir1" -a ! -h "$dir1" ];
then
echo "yes"
else
echo "no"
fi
EOF
execout=$(docker exec -i dummy_service /bin/bash -c "/bin/bash /tmp/send.sh")
[ "$execout" != 'yes' ] && { echo "device-name not created"; exit 1;}
echo ""
echo "done!"
echo ""

69
tools/poc-dummy-log

@ -0,0 +1,69 @@
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
#echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
#echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
SRPATH="$( dirname "$SOURCE" )"
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$SFPATH" != "$SRPATH" ]; then
RDIR=$SRPATH # relativ path directory
fi
cwdir=$PWD
wdir=$SFPATH
[ $# -eq 0 ] && { echo "Usage: $0 device-name"; exit 1; }
[ -z "$1" ] && { echo "Usage: $0 device-name"; exit 1; }
dir="$1"
dir1=/var/log-in/$dir
[ "$dir1" != "/var/log-in/$dir" ] && { echo "Usage: $0 device-name"; exit 1; }
(docker exec -i dummy_service sh -c "cat > /tmp/send.sh") <<EOF
if [ -d "$dir1" -a ! -h "$dir1" ];
then
echo "yes"
else
echo "no"
fi
EOF
execout=$(docker exec -i dummy_service /bin/bash -c "/bin/bash /tmp/send.sh")
[ "$execout" != 'yes' ] && { echo "device-name not exist"; exit 1;}
ex=$(docker exec -it dummy_service /bin/bash -c "cat \"/var/log-in/$dir/data\"")
#execout1=$(docker exec -i dummy_service /bin/bash -c "/bin/bash /tmp/send.sh")
#[ "$execout1" == 'yes' ] && { echo "Can't Remove device-name"; exit 1;}
#[ "$execout1" != 'no' ] && { echo "Done!"; exit 1;}
echo ""
echo "$ex"
echo ""

52
tools/poc-dummy-ls

@ -0,0 +1,52 @@
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
#echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
#echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
SRPATH="$( dirname "$SOURCE" )"
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$SFPATH" != "$SRPATH" ]; then
RDIR=$SRPATH # relativ path directory
fi
cwdir=$PWD
wdir=$SFPATH
#if [ "$cwdir" != "$wdir" ]; then
# cd $wdir
#fi
execsh=$(cat <<EOF
ls /var/log-in
EOF
)
dir="$1"
swarmlabdevdata=$2
lsfile=$wdir/src/lsfile
echo ""
echo $execsh | docker exec -i dummy_service /bin/bash
echo ""

69
tools/poc-dummy-rm

@ -0,0 +1,69 @@
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
#echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
#echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
SRPATH="$( dirname "$SOURCE" )"
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$SFPATH" != "$SRPATH" ]; then
RDIR=$SRPATH # relativ path directory
fi
cwdir=$PWD
wdir=$SFPATH
[ $# -eq 0 ] && { echo "Usage: $0 device-name"; exit 1; }
[ -z "$1" ] && { echo "Usage: $0 device-name"; exit 1; }
dir="$1"
dir1=/var/log-in/$dir
[ "$dir1" != "/var/log-in/$dir" ] && { echo "Usage: $0 device-name"; exit 1; }
(docker exec -i dummy_service sh -c "cat > /tmp/send.sh") <<EOF
if [ -d "$dir1" -a ! -h "$dir1" ];
then
echo "yes"
else
echo "no"
fi
EOF
execout=$(docker exec -i dummy_service /bin/bash -c "/bin/bash /tmp/send.sh")
[ "$execout" != 'yes' ] && { echo "device-name not exist"; exit 1;}
ex=$(docker exec -it dummy_service /bin/bash -c "rm -rf \"/var/log-in/$dir\"")
execout1=$(docker exec -i dummy_service /bin/bash -c "/bin/bash /tmp/send.sh")
[ "$execout1" == 'yes' ] && { echo "Can't Remove device-name"; exit 1;}
[ "$execout1" != 'no' ] && { echo "Done!"; exit 1;}
echo ""
echo "done!"
echo ""

75
tools/poc-dummy-send

@ -0,0 +1,75 @@
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
#echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
#echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
SRPATH="$( dirname "$SOURCE" )"
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$SFPATH" != "$SRPATH" ]; then
RDIR=$SRPATH # relativ path directory
fi
cwdir=$PWD
wdir=$SFPATH
[ $# -eq 0 ] && { echo "Usage: $0 device-name data"; exit 1; }
[ -z "$1" ] && { echo "Usage: $0 device-name data"; exit 1; }
[ -z "$2" ] && { echo "Usage: $0 device-name data"; exit 1; }
dir="$1"
devdata="$2"
dir1=/var/log-in/$dir
execsh=$(cat <<EOF
if [ -d "$dir1" -a ! -h "$dir1" ];
then
echo "yes"
else
echo "no"
fi
EOF
)
(docker exec -i dummy_service sh -c "cat > /tmp/send.sh") <<EOF
if [ -d "$dir1" -a ! -h "$dir1" ];
then
echo "yes"
else
echo "no"
fi
EOF
execout=$(docker exec -i dummy_service /bin/bash -c "/bin/bash /tmp/send.sh")
[ "$execout" != 'yes' ] && { echo "device-name not found"; exit 1;}
ex=$(docker exec -it dummy_service /bin/bash -c "echo \"$devdata\" >> $dir1/data")
echo ""
echo "done!"
echo ""
Loading…
Cancel
Save