summaryrefslogtreecommitdiff
path: root/new/scripts/vyos-1x.sh
blob: f0b84510f976c2f2893eb9c5b436ff0264e6946f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
set -e
sudo apt-get update

# detection if vyos-1x is built from vyos-build instead of standalone repo
if [ -d ../strongswan/ ]; then
  # build and install python3-vici dependency
  cd ../strongswan/
  # clone and build only if not already built as consequence of strongswan build
  shopt -s nullglob
  files=(python3-vici*.deb)
  if (( ${#files[@]} > 0 )); then
    echo "Reusing ${files[@]}"
  else
    commit_id=$(awk -F'"' '/commit_id/ {print $2; exit}' package.toml)
    scm_url=$(awk -F'"' '/scm_url/ {print $2; exit}' package.toml)
    rm -rf ./strongswan
    git clone "$scm_url" -b "$commit_id"
    ./build-vici.sh
  fi
  sudo apt-get install -y ./python3-vici*.deb
  cd ../vyos-1x

  # fix opam pcre2 package missing from vyos1x-config
  sudo apt-get install -y ocaml dune libpcre2-dev
  sudo sh -c 'eval $(opam env --root=/opt/opam --set-root); opam init --auto-setup && opam install pcre2 -y'
fi

if [ -f ./build.py ]; then
  python3 ./build.py
else
  /my-build-scripts/generic-build-script.sh
fi