#!/bin/bash

FWWWHOME="$HOME/fwww"

cd bin_dir

./setup_lighttpd_conf_dir.sh

/bin/cp -rf ../lib_dir $FWWWHOME/
/bin/cp -rf ../bin_dir/* $FWWWHOME/bin_dir/
/bin/cp -rf ../htdocs/* $FWWWHOME/htdocs/

/bin/cp -f fwww lighttpd lighttpd-angel \
   start_prod_http.sh stop_prod_http.sh  makecertpem_on_usersite.sh \
   watch_cleanup_files.sh \
   $FWWWHOME/bin_dir


/bin/cp -f ../conf_dir/fwww.conf $FWWWHOME/conf_dir/
if [[ -f "../conf_dir/dictionary.conf" ]]; then
    /bin/cp -f ../conf_dir/dictionary.conf $FWWWHOME/conf_dir/
fi

virt=`systemd-detect-virt`
if [[ "x$virt" = "docker" ]]; then
    /bin/true
    cd $FWWWHOME/bin_dir
else
    cd $FWWWHOME
    python3 -m venv venv_fwww
    source venv_fwww/bin/activate
    cd $FWWWHOME/bin_dir
    ./start_all_servers.sh
fi

