#!/bin/bash

kubectl apply -f ns
kubectl apply -f volumes

_install_html() {
  local src=$1
  local target=$2
  local ns 
  local pod_id
  ns="cloudnative-zone"  
  pod_id=$(kubectl get pods -n "$ns" | grep -m1 web  | cut -f1 -d" ")
  if [ -n "$pod_id" ] ; then 
     echo "wait for container state ..."
     sleep 8
     if kubectl cp $src/* -n $ns $pod_id:$target  ; then
        echo "$src files copied to $pod_id:$target"
     fi
  fi
}

sudo chown -R devadm $(dirname "$0") 

[ -r "bin/apply.sh" ] && ./bin/apply.sh  &&  [ -d "html-root" ] && _install_html html-root /usr/share/nginx/html

exit 0

