#!/bin/bash
## FE - frontend mounts
[[ -z "$(mount | grep FE | grep f0xx)" ]] && sshfs foxx@f0xx.org:/etc/nginx/ tmp/FE_gentoo/etc/nginx/ -o -p 222
[[ -d "tmp/FE_gentoo/var/www/localhost/htdocs/android_cast/" && -d "tmp/FE_gentoo/var/www/localhost/htdocs/android_cast/" && -z "$(mount | grep FE | grep f0xx)" ]] && \
  
#sleep 5
## BE - backend - through jump server through FE
[ -z "${ARTC0_HOST}" ] && ARTC0_HOST="10.7.16.128"
#ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ProxyJump=foxx@f0xx.org -P 222 foxx@${ARTC0_HOST}

## check out the changes in the ~/.ssh/config
## and
## ssh -o 'ProxyJump=foxx@f0xx.org:222' 'foxx@10.7.16.128'

if [[ -z "$(mount | grep FE | grep var)" && -d "tmp/FE_gentoo/var/log/nginx"  ]]; then
  set -x
  sshfs f0xx-monstro:/var/log/nginx tmp/FE_gentoo/var/log/nginx
  set +x
fi

sleep 3

if [[ -z "$(mount | grep BE | grep etc | grep f0xx)" && -d "tmp/BE_alpine/etc/nginx"  ]]; then
  set -x
  sshfs alpine-be:/etc/nginx tmp/BE_alpine/etc/nginx
  set +x
fi

sleep 3

if [[ -z "$(mount | grep BE | grep var | grep f0xx)" && -d "tmp/BE_alpine/var/www/localhost/htdocs/apps"  ]]; then
  set -x
  sshfs alpine-be:/var/www/localhost/htdocs/apps tmp/BE_alpine/var/www/localhost/htdocs/apps
  set +x
fi

if [[ -z "$(mount | grep BE | grep etc | grep f0xx)" && -d "tmp/BE_alpine/etc/gitea"  ]]; then
  set -x
  sshfs alpine-be:/etc/gitea tmp/BE_alpine/etc/gitea
  set +x
fi

_umount() {
  umount "${1}"
}

#_umount_fe {
#  fe_eps=$(mount | grep FE | grep -e f0xx -w FE_gentoo )
#}

