hpfs binary update and vm cluster script improvements. (#305)

* Updated hpfs binary for log file extending fix.
* Updated vmcluster scripts to include separate hpfiles dir per contract.
This commit is contained in:
Ravin Perera
2021-05-12 09:23:36 +05:30
committed by GitHub
parent 4e75b497ec
commit 63f62228c2
4 changed files with 24 additions and 20 deletions

Binary file not shown.

View File

@@ -96,6 +96,7 @@ else
basedir=/home/$sshuser
fi
contdir=$basedir/$selectedcont
hpfiles="hpfiles/"$selectedcont
# Read the hosts list.
readarray -t hostaddrs <<< $(echo $continfo | jq -r '.hosts[]')
@@ -306,17 +307,18 @@ fi
# Copy required files to remote node hpfiles dir.
if [ $mode = "new" ] || [ $mode = "updatebin" ]; then
mkdir -p hpfiles/{bin,ssl,nodejs_contract}
rm -r hpfiles > /dev/null 2>&1
mkdir -p $hpfiles/{bin,ssl,nodejs_contract}
strip $hpcore/build/hpcore
strip $hpcore/build/appbill
cp $hpcore/build/{hpcore,hpfs,hpws} hpfiles/bin/
cp $hpcore/build/{hpcore,hpfs,hpws} $hpfiles/bin/
cp $hpcore/examples/nodejs_contract/{package.json,echo_contract.js,hp-contract-lib.js} \
hpfiles/nodejs_contract/
$hpfiles/nodejs_contract/
fi
if [ $mode = "new" ]; then
cp ../bin/{libfuse3.so.3,libblake3.so,fusermount3,hpws,hpfs} hpfiles/bin/
cp ./setup-hp.sh hpfiles/
cp ../bin/{libfuse3.so.3,libblake3.so,fusermount3,hpws,hpfs} $hpfiles/bin/
cp ./setup-hp.sh $hpfiles/
fi
if [ $mode = "new" ] || [ $mode = "reconfig" ] || [ $mode = "updateconfig" ]; then
@@ -330,14 +332,14 @@ if [ $nodeid = -1 ]; then
hostaddr=${hostaddrs[i]}
let n=$i+1
# Setup node. (This will download hp.cfg in 'new', 'reconfig', 'updateconfig' modes)
/bin/bash ./setup-node.sh $mode $n $sshuser $sshpass $hostaddr $basedir $contdir &
/bin/bash ./setup-node.sh $mode $n $sshuser $sshpass $hostaddr $basedir $contdir $hpfiles &
done
wait
else
hostaddr=${hostaddrs[$nodeid]}
let n=$nodeid+1
# Setup node. (This will download hp.cfg in 'new', 'reconfig', 'updateconfig' modes)
/bin/bash ./setup-node.sh $mode $n $sshuser $sshpass $hostaddr $basedir $contdir
/bin/bash ./setup-node.sh $mode $n $sshuser $sshpass $hostaddr $basedir $contdir $hpfiles
fi
rm -r hpfiles > /dev/null 2>&1
@@ -411,7 +413,7 @@ if [ $mode = "new" ] || [ $mode = "reconfig" ]; then
# Merge json contents to produce final config.
echo "$(cat ./cfg/node$n.cfg)" \
'{"contract": {"id": "3c349abe-4d70-4f50-9fa6-018f1f2530ab", "bin_path": "/usr/bin/node", "bin_args": "'$basedir'/hpfiles/nodejs_contract/echo_contract.js", "unl": '${myunl}'}}'\
'{"contract": {"id": "3c349abe-4d70-4f50-9fa6-018f1f2530ab", "bin_path": "/usr/bin/node", "bin_args": "'$basedir'/'$hpfiles'/nodejs_contract/echo_contract.js", "unl": '${myunl}'}}'\
'{"mesh": {"known_peers": '${mypeers}'}}'\
$contconfig \
| jq --slurp 'reduce .[] as $item ({}; . * $item)' > ./cfg/node$n-merged.cfg

View File

@@ -3,7 +3,8 @@
mode=$1
basedir=$2
contdir=$3 # Contract directory
hostaddr=$4
hpfiles=$4
hostaddr=$5
if [[ ! -f /swapfile ]]
then
@@ -33,9 +34,9 @@ if [ -x "$(command -v fusermount3)" ]; then
else
echo "Installing FUSE and other shared libraries..."
sudo apt-get -y install libgomp1 libssl-dev
sudo cp $basedir/hpfiles/bin/{libfuse3.so.3,libblake3.so} /usr/local/lib/
sudo cp $basedir/$hpfiles/bin/{libfuse3.so.3,libblake3.so} /usr/local/lib/
sudo ldconfig
sudo cp $basedir/hpfiles/bin/fusermount3 /usr/local/bin/
sudo cp $basedir/$hpfiles/bin/fusermount3 /usr/local/bin/
fi
if [ -x "$(command -v sqlite3)" ]; then
@@ -50,16 +51,16 @@ fi
sudo rm -r $contdir > /dev/null 2>&1
echo "Creating new contract directory..."
$basedir/hpfiles/bin/hpcore new $contdir
$basedir/$hpfiles/bin/hpcore new $contdir
if [ -f $basedir/hpfiles/ssl/tlscert.pem ]; then
if [ -f $basedir/$hpfiles/ssl/tlscert.pem ]; then
echo "Copying ssl certs to contract directory..."
cp -rf $basedir/hpfiles/ssl/* $contdir/cfg/
cp -rf $basedir/$hpfiles/ssl/* $contdir/cfg/
fi
if [ $mode = "new" ] || [ $mode = "reconfig" ]; then
# npm install to support nodejs contract
pushd $basedir/hpfiles/nodejs_contract > /dev/null 2>&1
pushd $basedir/$hpfiles/nodejs_contract > /dev/null 2>&1
npm install
popd > /dev/null 2>&1
@@ -68,7 +69,7 @@ if [ $mode = "new" ] || [ $mode = "reconfig" ]; then
sudo chmod +x $contdir/getpid.sh
# Create start.sh script
echo "$basedir/hpfiles/bin/hpcore run $contdir" > $contdir/start.sh
echo "$basedir/$hpfiles/bin/hpcore run $contdir" > $contdir/start.sh
sudo chmod +x $contdir/start.sh
# Create stop.sh script (sending SIGINT to hpcore)
@@ -92,9 +93,9 @@ if [ $mode = "new" ] || [ $mode = "reconfig" ]; then
# This installs LetsEncrypt certbot and generates the SSL certs matching with the host's domain name.
echo "snap install --classic certbot && ln -s /snap/bin/certbot /usr/bin/certbot > /dev/null 2>&1" > $contdir/ssl.sh
echo "certbot certonly --standalone -n -m \$1 --agree-tos -d $hostaddr" >> $contdir/ssl.sh
echo "cp /etc/letsencrypt/live/$hostaddr/fullchain.pem $basedir/hpfiles/ssl/tlscert.pem" >> $contdir/ssl.sh
echo "cp /etc/letsencrypt/live/$hostaddr/privkey.pem $basedir/hpfiles/ssl/tlskey.pem" >> $contdir/ssl.sh
echo "cp -rf $basedir/hpfiles/ssl/* $contdir/cfg/" >> $contdir/ssl.sh
echo "cp /etc/letsencrypt/live/$hostaddr/fullchain.pem $basedir/$hpfiles/ssl/tlscert.pem" >> $contdir/ssl.sh
echo "cp /etc/letsencrypt/live/$hostaddr/privkey.pem $basedir/$hpfiles/ssl/tlskey.pem" >> $contdir/ssl.sh
echo "cp -rf $basedir/$hpfiles/ssl/* $contdir/cfg/" >> $contdir/ssl.sh
sudo chmod +x $contdir/ssl.sh
# Configure .screenrc

View File

@@ -7,6 +7,7 @@ sshpass=$4
hostaddr=$5
basedir=$6
contdir=$7 # Contract directory
hpfiles=$8 # HP files dir
echo $nodeid. $hostaddr
@@ -19,7 +20,7 @@ fi
# Run hp setup script on the node and download the generated hp.cfg
if [ $mode = "new" ] || [ $mode = "reconfig" ]; then
echo "Configuring HP..."
sshpass -p $sshpass ssh $sshuser@$hostaddr $basedir/hpfiles/setup-hp.sh $mode $basedir $contdir $hostaddr
sshpass -p $sshpass ssh $sshuser@$hostaddr $basedir/$hpfiles/setup-hp.sh $mode $basedir $contdir $hpfiles $hostaddr
fi
if [ $mode = "new" ] || [ $mode = "reconfig" ] || [ $mode = "updateconfig" ]; then