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.
 
 
 
 
 
 

141 lines
3.1 KiB

wdir=$PWD
wdir_connect="$wdir/src-local/hybrid/connect"
toolsok='ok'
# create wdir connect dir
if [ ! -d $wdir_connect ];then
mkdir -p $wdir_connect
fi
#check for jq
if ! command -v jq &> /dev/null
then
toolsok='no'
echo "jq could not be found"
exit
fi
# check version >15
if ! command -v node &> /dev/null
then
toolsok='no'
echo "Install: https://github.com/nodesource/distributions"
echo "Install it and try again!"
else
nodeversion=$(node -v | cut -d'.' -f1)
nodeversion="${nodeversion#v}"
if [ $nodeversion -lt 15 ];then
echo "node version < 15"
echo "Update: https://github.com/nodesource/distributions"
echo "Update it and try again!"
toolsok='no'
fi
fi
#check for docker
if ! command -v docker &> /dev/null
then
echo "Cannot find docker"
echo "Install it and try again!"
echo "http://docs.swarmlab.io/SwarmLab-HowTos/labs/Howtos/docker/install.adoc.html"
toolsok='no'
else
dockerversion=$(docker info --format "{{json .}}" | jq .ServerVersion | cut -d'.' -f1)
dockerversion="${dockerversion#\"}"
if [ $dockerversion -lt 19 ];then
echo "docker version < 19"
echo "Update docker and try again!"
echo "http://docs.swarmlab.io/SwarmLab-HowTos/labs/Howtos/docker/install.adoc.html"
toolsok='no'
fi
fi
#check for docker-compose
dockercomposeversion=$(docker-compose -f $wdir/test/run.yml config --services)
if [ $dockercomposeversion != 'swarmlabclient' ];then
echo "Cannot find docker-compose"
echo "Install it and try again!"
echo "http://docs.swarmlab.io/SwarmLab-HowTos/labs/Howtos/docker/install.adoc.html"
toolsok='no'
fi
#check for wireguard
if ! command -v wg &> /dev/null
then
echo "Cannot find wg"
echo "Install it and try again!"
echo "https://www.wireguard.com/install/"
toolsok='no'
fi
#check for pm2
if ! command -v pm2 &> /dev/null
then
toolsok='no'
echo "pm2 could not be found"
echo "sudo npm install -g pm2"
exit
fi
# npm install
if [ $toolsok == 'ok' ];then
npm install
fi
if [ $toolsok == 'ok' ];then
cd src-local
npm install
cd $wdir
fi
if [ $toolsok == 'ok' ];then
cp -f $wdir/files/VuetableCssConfig.js $wdir/node_modules/vuetable-2/src/components/VuetableCssConfig.js
cp -f $wdir/files/status.sh $wdir/src-local/hybrid/connect/status.sh
cat << FOE > $wdir/src-local/ecosystem.config.js
module.exports = {
"apps": [
{
"name" : "hybridserver",
"autorestart" : true,
"watch" : true,
"cwd" : "$wdir/src-local",
"script" : "./llo/new.js",
"run_as_user" : "node",
"args" : "start",
"pid_file" : "$wdir/src-local/pid.pid",
"log_type" : "json",
"log_file" : "$wdir/src-local/logs/logfile",
"error_file" : "$wdir/src-local/logs/errorfile",
"out_file" : "$wdir/src-local/logs/outfile",
"log_date_format": "YYYY-MM-DD HH:mm Z",
"merge_logs" : true,
"exec_mode" : "fork",
"max_restarts": 10,
"max_memory_restart": "500M",
"restart_delay": 1000
},
]
}
FOE
fi
echo $nodeversion
echo $dockerversion
echo $dockercomposeversion
echo $wdir
echo $wdir_connect