<h1>Hero and mdbook on a Full VM: Script</h1>

<h2>Table of Contents</h2>

- [Introduction](#introduction)
- [Setting the Full VM](#setting-the-full-vm)
- [Remote Explorer Access](#remote-explorer-access)
- [Download and Run the Script](#download-and-run-the-script)
- [Serve and View the mdbook](#serve-and-view-the-mdbook)
- [Questions and Feedback](#questions-and-feedback)

***

## Introduction

In this tutorial, we show how to use a script to deploy an mdbook with the [hero](https://github.com/freeflowuniverse/crystallib/tree/development/cli/hero) tool. 

For this guide, we show an example using the mdbook from the repository [info_tfgrid](https://git.ourworld.tf/tfgrid/info_tfgrid). This setup can be done locally or on a VM. Note that it should be run as root. 

We show the steps for a full VM deployed on the TFGrid with WireGuard. We use `10.20.4.2` as a WireGuard IP address. Adjust according to your own setup.

We will be using SSH to connect to the VM and we will access the mdbook output on a local browser. To manage the mdbook files, we will be using the remote explorer feature of either VSCodium or VSCode.

## Setting the Full VM 

We start by deploying a full VM with WireGuard on the TFGrid. 

To connect to the VM, we will be using a remote explorer.

## Remote Explorer Access

You can use the remote explorer feature of both [VSCode](https://marketplace.visualstudio.com/items?itemName=ms-vscode.remote-repositories) and [VSCodium](https://open-vsx.org/extension/jeanp413/open-remote-ssh) to manage the mdbook.

- Open the window `Remote Explorer`, click on `Add New` and write the following in the SSH config file:
    ```
    Host 10.20.4.2
        HostName 10.20.4.2
        User root
    ```
- Click on `Connect to Host`
- Open the main `/root` directory
- Right-click on the main window of the directory and select `Open in Integrated Terminal`

## Download and Run the Script

- Download the script
    ```
    wget https://git.ourworld.tf/tfgrid/info_tfgrid/raw/branch/main/scripts/hero_mdbook.sh
    ```
- Run the script (this will take a couple of minutes)
    ```
    source hero_mdbook.sh
    ```

## Serve and View the mdbook

- Serve the mdbook
    ```
    mdbook serve --hostname 0.0.0.0 --port 3333
    ```
- Open your browser and use the following URL:
    ```
    localhost:3333
    ```

You can now work on the mdbook and see live the changes your bring to the mdbook files on the remote VM.

## Questions and Feedback

If you have any questions or feedback, please let us know by either writing a post on the [ThreeFold Forum](https://forum.threefold.io/), or by chatting with us on the [TF Grid Tester Community](https://t.me/threefoldtesting) Telegram channel.