#!/bin/bash EVIO=https://github.com/EdgeVPNio/evio.git EXLIBS=https://github.com/ipop-project/3rd-Party-Libs.git PY=python3.8 WorkspaceRoot=~/workspace Build_WRTC=./EdgeVPNIO/tools/scripts/build_webrtc.sh Get_Archives=./EdgeVPNIO/tools/scripts/get_archives.sh Get_Include=./EdgeVPNIO/tools/scripts/get_include.sh Build_Tincan=./EdgeVPNIO/tools/build_tincan.sh function install_build_tools { sudo bash -c " apt-get update -y && \ apt-get install -y git \ make clang libc++-dev libssl-dev $PY" } function pull_src { wd=$(pwd) cd .. #stat evio dir clone or pull git clone $EVIO cd evio/tincan/external # git clone -b ubuntu-x64 --single-branch https://github.com/ipop-project/3rd-Party-Libs.git cd $wd } function make_debpak { wd=$(pwd) cd ../../.. mkdir -p out cd $wd cp ../debian-package ../../out cp ../evio/controller/Controller.py ../../out/debian-package/edge-vpnio/opt/edge-vpnio/ && \ mkdir -p ../../out/debian-package/edge-vpnio/etc/opt/edge-vpnio/ cp ../evio/controller/template-config.json ../../out/debian-package/edge-vpnio/etc/opt/edge-vpnio/config.json && \ cp -r ../evio/controller/modules/ ../evio/controller/framework/ ../../out/debian-package/edge-vpnio/opt/edge-vpnio/ && \ chmod 0775 ../../out/debian-package/edge-vpnio/opt/edge-vpnio/framework/ && \ chmod 0664 ../../out/debian-package/edge-vpnio/opt/edge-vpnio/framework/* && \ chmod 0775 ../../out/debian-package/edge-vpnio/opt/edge-vpnio/modules/ && \ chmod 0664 ../../out/debian-package/edge-vpnio/opt/edge-vpnio/modules/* && \ chmod 0664 ../../out/debian-package/edge-vpnio/opt/edge-vpnio/Controller.py && \ chmod 0664 ../../out/debian-package/edge-vpnio/etc/opt/edge-vpnio/config.json && \ cp ../evio/tincan/trunk/out/release/x86_64/tincan ../../out/debian-package/edge-vpnio/opt/edge-vpnio/ && \ chmod 0775 ../../out/debian-package/edge-vpnio/opt/edge-vpnio/tincan && \ cd ../../out/debian-package/ && \ ./deb-gen && \ rm -rf edge-vpnio/opt/edge-vpnio/framework \ edge-vpnio/opt/edge-vpnio/modules \ edge-vpnio/opt/edge-vpnio/tincan \ edge-vpnio/opt/edge-vpnio/template-config.json \ edge-vpnio/opt/edge-vpnio/Controller.py \ edge-vpnio/etc/opt/edge-vpnio/config.json cd $wd } function install_testbed_deps { sudo bash -c " apt-get update -y && \ apt-get install -y openvswitch-switch \ $PY $PY-venv $PY-dev python3-pip \ apt-transport-https \ ca-certificates \ curl git \ software-properties-common && \ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \ add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable\" && \ apt-cache policy docker-ce && \ apt-get install -y containerd.io \ docker-ce-cli \ docker-ce && \ groupadd -f docker && \ usermod -a -G docker $USER \ " echo "You must logout and relogin for docker group membership to take effect." } function make_venv { wd=$(pwd) cd ../testbed && \ $PY -m venv venv && \ source venv/bin/activate && \ pip3 install simplejson cd $wd } function make_dkrimg { mv ../../out/debian-package/edge-vpnio_20.7_amd64.deb docker-image/ && \ docker build -f ./../docker-image/evio-base.Dockerfile -t edgevpnio/evio-base:1.0 ./docker-image && \ docker build -f ./../docker-image/evio-node.Dockerfile -t edgevpnio/evio-node:20.7.3 ./docker-image } function install_openfire { docker run --name openfire -d \ -p 9090:9090 -p 5222:5222 \ -p 5269:5269 -p 5223:5223 \ -p 7443:7443 -p 7777:7777 \ -p 7070:7070 -p 5229:5229 \ -p 5275:5275 \ edgevpnio/openfire_edgevpn_demo } function install_portal { #Todo: visualizer not yet available git clone https://github.com/edgevpnio/portal.git cd portal/setup ./setup.sh chown -R $USER /users/$USER/ } function do_clean { # tincan wd=$(pwd) cd ../../evio/tincan/trunk/build make clean; cd $wd #debian pak cd ../debian-package/ && \ rm -ri ./edge-vpnio_20.7_amd64.deb \ edge-vpnio/opt/edge-vpnio/framework \ edge-vpnio/opt/edge-vpnio/modules \ edge-vpnio/opt/edge-vpnio/tincan \ edge-vpnio/opt/edge-vpnio/template-config.json \ edge-vpnio/opt/edge-vpnio/Controller.py && \ cd $wd # docker-image rm -f docker-image/edge-vpnio_20.7_amd64.deb docker rmi edgevpnio/evio-base:1.0 edgevpnio/evio-node:20.7 docker rmi $(docker images -q --filter "dangling=true") # testbed cd ../testbed rm -rf config log cert venv cd $wd } function build_webrtc() { wd=$(pwd) cd $WorkspaceRoot chmod +x $Build_WRTC $Get_Archives $Get_Include echo "Building webrtc with" "$1" "$2" if ! $Build_WRTC -b "$1" -t "$2" then cd $WorkspaceRoot if ! $Get_Archives -b "$1" -t "$2" then cd $WorkspaceRoot $Get_Include -b "$1" -t "$2" fi fi cd $wd } #function build_webrtc_with_release_ubuntu #{ # wd=$(pwd) # cd $WorkspaceRoot # chmod +x $Build_WRTC $Get_Archives $Get_Include # $Build_WRTC -b release -t ubuntu # cd $WorkspaceRoot # $Get_Archives -b release -t ubuntu # cd $WorkspaceRoot # $Get_Include -b release -t ubuntu # cd $wd #} # #function build_webrtc_with_debug_raspberry_pi #{ # wd=$(pwd) # cd $WorkspaceRoot # chmod +x $Build_WRTC $Get_Archives $Get_Include # ./EdgeVPNIO/tools/scripts/build_webrtc.sh -b debug -t raspberry-pi # cd $WorkspaceRoot # ./EdgeVPNIO/tools/scripts/get_archives.sh -b debug -t raspberry-pi # cd $WorkspaceRoot # ./EdgeVPNIO/tools/scripts/get_include.sh -b debug -t raspberry-pi # cd $wd #} # #function build_webrtc_with_release_raspberry_pi #{ # wd=$(pwd) # cd $WorkspaceRoot # chmod +x $Build_WRTC $Get_Archives $Get_Include # ./EdgeVPNIO/tools/scripts/build_webrtc.sh -b release -t raspberry-pi # cd $WorkspaceRoot # ./EdgeVPNIO/tools/scripts/get_archives.sh -b release -t raspberry-pi # cd $WorkspaceRoot # ./EdgeVPNIO/tools/scripts/get_include.sh -b release -t raspberry-pi # cd $wd #} function build_tincan() { wd=$(pwd) cd $WorkspaceRoot chmod +x $Build_Tincan $Build_Tincan -b "$1" -t "$2" cd $wd } #function build_tincan_release_ubuntu { # wd=$(pwd) # cd $WorkspaceRoot # chmod +x ./EdgeVPNIO/tools/build_tincan.sh # ./EdgeVPNIO/tools/scripts/build_tincan.sh -b release -t ubuntu # cd $wd #} # #function build_tincan_debug_raspberry { # wd=$(pwd) # cd $WorkspaceRoot # chmod +x ./EdgeVPNIO/tools/build_tincan.sh # ./EdgeVPNIO/tools/scripts/build_tincan.sh -b debug -t raspberry-pi # cd $wd #} # #function build_tincan_release_raspberry { # wd=$(pwd) # cd $WorkspaceRoot # chmod +x ./EdgeVPNIO/tools/build_tincan.sh # ./EdgeVPNIO/tools/scripts/build_tincan.sh -b debug -t raspberry-pi # cd $wd #} function do_full_setup { install_build_tools pull_src build_webrtc build_tincan make_debpak make_dkrimg make_testbed_prereqs make_venv } case $1 in deps) install_build_tools ;; src) pull_src ;; debpak) make_debpak ;; dkrimg) make_dkrimg ;; testbed) install_testbed_deps ;; venv) make_venv ;; xmpp) install_openfire ;; clean) do_clean ;; build_webrtc) build_webrtc debug ubuntu ;; build_webrtc_with_release_ubuntu) build_webrtc release ubuntu ;; build_webrtc_with_debug_raspberry_pi) build_webrtc debug raspberry-pi ;; build_webrtc_with_release_raspberry_pi) build_webrtc release raspberry-pi ;; build_tincan) build_tincan debug ubuntu ;; build_tincan_release_ubuntu) build_tincan release ubuntu ;; build_tincan_debug_raspberry) build_tincan debug raspberry-pi ;; build_tincan_release_raspberry) build_tincan release raspberry-pi ;; all) do_full_setup ;; *) echo "no match on input -> $1" ;; esac