You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

63 lines
2.0 KiB

#!/bin/bash
#############################################################################
# Copyright (c) 2019-2021 University of Exeter, UK
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#############################################################################
set -e
NUMBEROFCOMP=$1
if (: </dev/tcp/127.0.0.1/4999) &>/dev/null
then
echo "Server still running ..."
exit 1
fi
if [ -d "companies" ]; then
rm -rf companies
echo "existed companies folder is deleted"
fi
mkdir -p companies
for i in $(seq $NUMBEROFCOMP); do
mkdir -p companies/P$i
cp -r ./template ./companies/P$i/Root
#mv ./companies/P$i/mpc/* ./companies/P$i
#rm -rf ./companies/P$i/mpc
done
for i in $(seq $NUMBEROFCOMP); do
ROOTCA=P$i
echo "Generating root certificate in directory $ROOTCA"
echo -e "$ROOTCA\nUK\nDevon\nExeter\nExeUni\nCS\n" | (./companies/P$i/Root/server.py -c InitializeSupplyChain -p 4999 -root ./companies/P$i/Root)
done
for i in $(seq $NUMBEROFCOMP); do
ROOTCA=P$i
(cd ./companies/$ROOTCA/Root; ./server.py -c RunningServer -p 4999 & echo "$!" > server.pid)
sleep 10
for j in $(seq $NUMBEROFCOMP); do
PLAYER="P${j}_${ROOTCA}"
echo "$PLAYER"
echo "Starting Player in directory P$j"
echo -e "$PLAYER\nUK\nDevon\nExeter\nExeUni\n$PLAYER\n$PLAYER@exeter.ac.uk\n" | (cd ./companies/P$j/Root; ./boarding.py joinSupplyChain )
done
pkill -F ./companies/$ROOTCA/Root/server.pid
done
[ ! "$(podman pod ps | grep mypod)" ] && podman run --pod new:mypod -t scale-mamba-latest true
exit