updated steps for vm hero mdbook

This commit is contained in:
mik-tf 2024-03-23 17:14:21 +00:00
parent 9340d3958a
commit 8f1dc01ea3

View File

@ -5,13 +5,9 @@
- [Introduction](#introduction) - [Introduction](#introduction)
- [Setting the Full VM](#setting-the-full-vm) - [Setting the Full VM](#setting-the-full-vm)
- [Remote Explorer Access](#remote-explorer-access) - [Remote Explorer Access](#remote-explorer-access)
- [Install cargo and mdbook](#install-cargo-and-mdbook) - [Set the SSH Key Pair](#set-the-ssh-key-pair)
- [Install redis](#install-redis) - [Install hero, crysallib and V](#install-hero-crysallib-and-v)
- [Install pkg-config, gcc and libssl](#install-pkg-config-gcc-and-libssl) - [Use Hero to Generate mdbooks](#use-hero-to-generate-mdbooks)
- [Set Hero](#set-hero)
- [Generate the mdbook](#generate-the-mdbook)
- [Serve and View the mdbook](#serve-and-view-the-mdbook)
- [Questions and Feedback](#questions-and-feedback)
*** ***
@ -32,9 +28,9 @@ To manage the mdbook files, we will be using the remote explorer feature of eith
We start by deploying a full VM with WireGuard on the TFGrid. We also set an SSH tunnel. We start by deploying a full VM with WireGuard on the TFGrid. We also set an SSH tunnel.
- Deploy a full VM with WireGuard on the TFGrid - Deploy a full VM with WireGuard on the TFGrid
- Set an SSH tunnel, on port 3333 for both local and VM - Set an SSH tunnel, on port 5173 for both local and VM
``` ```
ssh -4 -L 3333:127.0.0.1:3333 root@10.20.4.2 ssh -4 -L 5173:127.0.0.1:5173 root@10.20.4.2
``` ```
Instead of working on the SSH tunnel terminal window, we will be using the remote explorer feature of a source-code editor. Instead of working on the SSH tunnel terminal window, we will be using the remote explorer feature of a source-code editor.
@ -52,88 +48,59 @@ You can use the remote explorer feature of both [VSCode](https://marketplace.vis
- Click on `Connect to Host` - Click on `Connect to Host`
- Open the main `/root` directory - Open the main `/root` directory
- Right-click on the main window of the directory and select `Open in Integrated Terminal` - Right-click on the main window of the directory and select `Open in Integrated Terminal`
- Update and upgrade the VM - Update and prepare the VM
``` ```
apt update && apt upgrade -y apt update && apt install curl -y && apt install openssh-client -y
``` ```
### Install cargo and mdbook ## Set the SSH Key Pair
- Install cargo rust for linux and mac (with default installation) - Generate an SSH key pair
- To make it work with info_tfgrid, use books for the filename
``` ```
curl https://sh.rustup.rs -sSf | sh ssh-keygen # save in /root/.ssh/books
``` ```
- Configure the current shell - Note the public key
``` ```
source "$HOME/.cargo/env" cat ~/.ssh/books.pub
``` ```
- Install mdbook - Add the SSH public key on git.ourworld.tf and github
- Optional: on git.ourworld.tf, verify the key
``` ```
cargo install mdbook echo -n 'token' | ssh-keygen -Y sign -n gitea -f /path/to/private/key
``` ```
- Start the ssh agent
### Install redis
- Install redis on the VM
```
apt install lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list
apt-get update
apt-get install redis -y
```
### Install pkg-config, gcc and libssl
- Install other packages
```
apt install pkg-config -y
apt-get install gcc -y
apt install libssl-dev
```
## Set Hero
- Download the hero installation script
```
curl https://raw.githubusercontent.com/freeflowuniverse/crystallib/development/scripts/installer_hero.sh > /tmp/hero_install.sh
```
- Run the script as root
```
bash /tmp/hero_install.sh
```
- Run hero to confirm the installation is done properly
```
hero -help
```
## Generate the mdbook
- Start the ssh-agent
``` ```
eval $(ssh-agent) eval $(ssh-agent)
``` ```
- Generate the mdbook with hero - Add private key to the agent
``` ```
hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript ssh-add /root/.ssh/books
```
- Change directory to where the book is built
```
cd /root/hero/var/mdbuild/book_name
```
- You can then edit the content of the book as with any mdbook
```
mdbook build
``` ```
## Serve and View the mdbook ## Install hero, crysallib and V
- To serve on your local machine, make sure to use the same part as the one set in your SSH tunnel (here it's port 3333)
``` ```
mdbook serve --port 3333 curl https://raw.githubusercontent.com/freeflowuniverse/crystallib/development/scripts/build_hero.sh > /tmp/build_hero.sh
bash /tmp/build_hero.sh
``` ```
- To see the mdbook live, open a browser on the local machine and go to localhost:3333
## Questions and Feedback ## Use Hero to Generate mdbooks
- You can download the repository.
```
hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript/bookname -gp
```
- To open the mdbook on your local browser:
```
hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript/bookname -o
```
> Note: In both cases, make sure to replace **bookname** by the name of your book, e.g. test.
To see the mdbook online on a local browser (via the file **index.html**), run the following command and open a browser with the URL **localhost:5173**:
```
pushd /root/hero/www/info/tfgrid/; python3 -m http.server 5173; popd;
```
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.