bash << 'EOF'

type="type_placeholder"
user="user_placeholder"
path="path_placeholder"
ignore_existing="flag_ignore_existing"
archived="flag_archived"
extra_args=""

if [ ! -e /root/bin/sshrestore ];
  then echo \"Datacycle Backups are not enabled on $server\";
  exit 1;
fi

if screen -ls | grep -q "eigshell_restore_${user}"; then
  echo -e "\n\n[*] Restore already in progress for ${user}\n"
  cat /var/log/eigshell_restores/${user}
  exit 1;
fi

if ! _user_info=$(/root/bin/ui $user 2>/dev/null); then
  echo -e "\n\n[*] User ${user} not found in ${HOSTNAME}\n"
  exit 1;
fi

MSG="Please DOUBLE CHECK you've entered the correct account below and that you intend to OVERWRITE the follwing path "

if [[ "$ignore_existing" == "1" ]]; then
    extra_args+=" --rsyncargs=--ignore-existing"
    MSG="Please DOUBLE CHECK you've entered the correct account below and that you intend to restore the follwing path with ignore existing "
fi

if [[ "$archived" == "1" ]]; then
  extra_args+=" --archived"
  MSG+="from ARCHIVED backup"
fi

if (whiptail --title " WARNING " --yesno --defaultno "${MSG} \nUSER: ${user}\nPATH: /home/${user}/${path}\nSERVER: ${HOSTNAME}" 24 78); then
  [[ -d /var/log/eigshell_restores ]] || ( mkdir -p /var/log/eigshell_restores && chmod 700 /var/log/eigshell_restores )
  echo -e "[*] restoring user $user on path $path"
  date &> /var/log/eigshell_restores/${user}
  screen -dmS eigshell_restore_${user} bash -c "/root/bin/sshrestore -f --user $user --type $type --path=\"${path}\" ${extra_args}  &>> /var/log/eigshell_restores/${user}; date &>> /var/log/eigshell_restores/${user}"
  sleep 5
fi
EOF
