Browse Source

bash update

master
zeus 1 year ago
parent
commit
9f58887d43
  1. 2
      dist/index.html
  2. 4
      dist/js/app.5e7a93ea.js
  3. 2
      dist/js/app.5e7a93ea.js.map
  4. 28
      down.sh
  5. 72
      files/status.sh
  6. 26
      restart.sh
  7. 33
      run.yml.sh
  8. 2
      src-local/LabLearningObject-hybrid
  9. 33
      src-local/start-server.sh
  10. 12
      src/components/manageservices/view-events.vue
  11. 32
      start.sh
  12. 65
      status.sh
  13. 28
      update-agent.sh

2
dist/index.html

@ -1 +1 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Vue App</title><link href="/css/app.ad1e967b.css" rel="preload" as="style"><link href="/css/chunk-vendors.e469b508.css" rel="preload" as="style"><link href="/js/app.fd1c452f.js" rel="preload" as="script"><link href="/js/chunk-vendors.d8d18fe6.js" rel="preload" as="script"><link href="/css/chunk-vendors.e469b508.css" rel="stylesheet"><link href="/css/app.ad1e967b.css" rel="stylesheet"></head><body><div id="app"></div><script src="/js/chunk-vendors.d8d18fe6.js"></script><script src="/js/app.fd1c452f.js"></script></body></html>
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Vue App</title><link href="/css/app.ad1e967b.css" rel="preload" as="style"><link href="/css/chunk-vendors.e469b508.css" rel="preload" as="style"><link href="/js/app.5e7a93ea.js" rel="preload" as="script"><link href="/js/chunk-vendors.d8d18fe6.js" rel="preload" as="script"><link href="/css/chunk-vendors.e469b508.css" rel="stylesheet"><link href="/css/app.ad1e967b.css" rel="stylesheet"></head><body><div id="app"></div><script src="/js/chunk-vendors.d8d18fe6.js"></script><script src="/js/app.5e7a93ea.js"></script></body></html>

4
dist/js/app.fd1c452f.js → dist/js/app.5e7a93ea.js

File diff suppressed because one or more lines are too long

2
dist/js/app.fd1c452f.js.map → dist/js/app.5e7a93ea.js.map

File diff suppressed because one or more lines are too long

28
down.sh

@ -1 +1,29 @@
#!/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
docker-compose -f run.yml down
cd $cwdir

72
files/status.sh

@ -1,44 +1,62 @@
#!/bin/bash
function ifup {
if [[ ! -d /sys/class/net/${1} ]]; then
return 1
else
net=${1}
test_time=2
T1=$(cat /sys/class/net/$net/statistics/tx_bytes)
sleep $test_time
T2=$(cat /sys/class/net/$net/statistics/tx_bytes)
if [ -z ${1} ] ; then
echo "usage: status.sh interface "
exit
fi
tot=$(( (T2 - T1)))
CHECK="off";
ACTIVITY="off";
if [ $tot -eq 0 ]; then
return 1
fi
fi
}
net=${1}
ping_c=2 # stop after sending packets
ping_i=1 # set interval in seconds
ping_w=2 # timeout in seconds
if ifup $1; then
hybridswarm='Online'
else
hybridswarm='NotOnline'
ping_iptmp=$(ip addr show $net | grep -o "inet [0-9]*\.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*\.[0-9]*")
ping_ip="$ping_iptmp.1"
#ping_ip=10.13.13.1
if [[ -d /sys/class/net/$net ]]; then
CHECK="on";
T1=$(cat /sys/class/net/$net/statistics/tx_bytes)
ping -I $net -c $ping_c -i $ping_i -w $ping_w $ping_ip &> /dev/null
T2=$(cat /sys/class/net/$net/statistics/tx_bytes)
tot=$(( (T2 - T1)))
if [ $tot -ne 0 ]; then
ACTIVITY="on";
fi
fi
#echo "check $CHECK activity $ACTIVITY"
if [ "$CHECK" == "on" ] && [ "$ACTIVITY" == "on" ] ; then
hybridswarm='Online'
else
hybridswarm='NotOnline'
fi
dockerswarm=$(docker info --format "{{json .}}" | jq .Swarm.LocalNodeState)
tempswarm="${dockerswarm%\"}"
tempswarm="${tempswarm#\"}"
dockerswarm=$tempswarm
dockerswarmid=$(docker info --format "{{json .}}" | jq .Swarm.NodeID)
tempswarm1="${dockerswarmid%\"}"
tempswarm1="${tempswarm1#\"}"
swarmlabid=$tempswarm1
#echo $dockerswarm
#echo $hybridswarm
#echo $swarmlabid
#jq --arg key0 'swarmlab' --arg swarmlab $dockerswarm --arg key1 'hybrid' --arg hybrid $hybridswarm --arg key2 'swarmlabid' --arg swarmlabid $swarmlabid'. | .[$key0]=$swarmlab | .[$key1]=$hybrid | .[$key2]=$swarmlabid' <<<'{}'
if [ "$dockerswarm" == "active" ] ; then
dockerswarmid=$(docker info --format "{{json .}}" | jq .Swarm.NodeID)
tempswarm1="${dockerswarmid%\"}"
tempswarm1="${tempswarm1#\"}"
swarmlabid=$tempswarm1
else
swarmlabid="-1";
fi
if [ -z "$dockerswarm" ] ; then
dockerswarm=none
fi
jq \
--arg key0 'swarmlab' --arg swarmlab $dockerswarm \
--arg key1 'hybrid' --arg hybrid $hybridswarm \

26
restart.sh

@ -1,5 +1,29 @@
#!/bin/sh
#!/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
cd $wdir
./stop.sh
./start.sh
cd $cwdir

33
run.yml.sh

@ -1,8 +1,33 @@
#docker service rm ondemand_playground_swarmlabclient
#env node7=636656brviohbzo5dhdggba0q \
#env node7=qpszok5px74lqpvidoeq2wyyc \
#docker stack deploy -c run.yml ondemand_playground
#!/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
env nodepath=$PWD \
docker-compose -f run.yml up -d > /dev/null 2>&1
cd $cwdir

2
src-local/LabLearningObject-hybrid

@ -1 +1 @@
Subproject commit acb33e1751110430ee6386fc2ad4e20e90cca230
Subproject commit 7034fdc050de0b0ec6d75597361a8bf4a2ce2580

33
src-local/start-server.sh

@ -1,3 +1,31 @@
#!/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
pm2 stop hybridserver > /dev/null 2>&1
sleep 1
@ -7,11 +35,12 @@ pm2 stop hybridserver > /dev/null 2>&1
sleep 3
pm2 start hybridserver
/bin/bash ./git-update.sh https://git.swarmlab.io:3000/llo/LabLearningObject-hybrid.git LabLearningObject-hybrid
if [ ! -d 'LabLearningObject-hybrid-tmp' ]; then
mkdir LabLearningObject-hybrid-tmp
fi
sudo /bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/get-swarmlab-ca > /dev/null 2>&1
sudo /bin/bash /data/appl/ok/swarmlab-hybrid-agent/src-local/hybrid/connect/get-base-ca > /dev/null 2>&1
sudo /bin/bash ./hybrid/connect/get-swarmlab-ca > /dev/null 2>&1
sudo /bin/bash ./hybrid/connect/get-base-ca > /dev/null 2>&1

12
src/components/manageservices/view-events.vue

@ -51,6 +51,18 @@
{{ labtext.originalItem.url }}
</td>
</tr>
<tr>
<th scope="row">Level</th>
<td colspan="2">
{{ labtext.originalItem.Level }}
</td>
</tr>
<tr>
<th scope="row">Prerequisites</th>
<td colspan="2">
{{ labtext.originalItem.Prerequisites }}
</td>
</tr>
<tr>
<th scope="row">startDate</th>
<td colspan="2">

32
start.sh

@ -1,5 +1,31 @@
#!/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
#echo "full path file $SOURCE"
#echo "full path dir $SFPATH"
#echo "relativ path dir $SRPATH"
wdir=$PWD
cwdir=$PWD
wdir=$SFPATH
cd $wdir
./update-agent.sh
cd src-local
./start-server.sh
@ -7,12 +33,14 @@ cd $wdir
#npm run serve
./run.yml.sh
FILEstart="$wdir/src-local/hybrid/connect/join.sh"
cd $wdir
FILEstart="$wdir/src-local/hybrid/connect/join.sh"
if [ -f "$FILEstart" ]; then
sudo bash $FILEstart
fi
cd $cwdir
txturl='\033[1;36m'
txturl1='\033[0;36m'

65
status.sh

@ -0,0 +1,65 @@
#!/bin/bash
if [ -z ${1} ] ; then
echo "usage: status.sh interface "
exit
fi
CHECK="off";
ACTIVITY="off";
net=${1}
ping_c=2 # stop after sending packets
ping_i=1 # set interval in seconds
ping_w=2 # timeout in seconds
ping_iptmp=$(ip addr show $net | grep -o "inet [0-9]*\.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*\.[0-9]*")
ping_ip="$ping_iptmp.1"
#ping_ip=10.13.13.1
if [[ -d /sys/class/net/$net ]]; then
CHECK="on";
T1=$(cat /sys/class/net/$net/statistics/tx_bytes)
ping -I $net -c $ping_c -i $ping_i -w $ping_w $ping_ip &> /dev/null
T2=$(cat /sys/class/net/$net/statistics/tx_bytes)
tot=$(( (T2 - T1)))
if [ $tot -ne 0 ]; then
ACTIVITY="on";
fi
fi
#echo "check $CHECK activity $ACTIVITY"
if [ "$CHECK" == "on" ] && [ "$ACTIVITY" == "on" ] ; then
hybridswarm='Online'
else
hybridswarm='NotOnline'
fi
dockerswarm=$(docker info --format "{{json .}}" | jq .Swarm.LocalNodeState)
tempswarm="${dockerswarm%\"}"
tempswarm="${tempswarm#\"}"
dockerswarm=$tempswarm
if [ "$dockerswarm" == "active" ] ; then
dockerswarmid=$(docker info --format "{{json .}}" | jq .Swarm.NodeID)
tempswarm1="${dockerswarmid%\"}"
tempswarm1="${tempswarm1#\"}"
swarmlabid=$tempswarm1
else
swarmlabid="-1";
fi
if [ -z "$dockerswarm" ] ; then
dockerswarm=none
fi
jq \
--arg key0 'swarmlab' --arg swarmlab $dockerswarm \
--arg key1 'hybrid' --arg hybrid $hybridswarm \
--arg key2 'swarmlabid' --arg swarmlabid $swarmlabid \
'. | .[$key0]=$swarmlab | .[$key1]=$hybrid | .[$key2]=$swarmlabid' <<<'{}'

28
update-agent.sh

@ -1,5 +1,32 @@
#!/bin/sh
#!/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
git fetch
UPSTREAM=${1:-'@{u}'}
@ -18,3 +45,4 @@ else
echo "Diverged"
fi
cd $cwdir

Loading…
Cancel
Save