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
cargo install mdbook - Optional: on git.ourworld.tf, verify the key
``` ```
echo -n 'token' | ssh-keygen -Y sign -n gitea -f /path/to/private/key
```
- Start the ssh agent
```
eval $(ssh-agent)
```
- Add private key to the agent
```
ssh-add /root/.ssh/books
```
### Install redis ## Install hero, crysallib and V
- Install redis on the VM ```
``` curl https://raw.githubusercontent.com/freeflowuniverse/crystallib/development/scripts/build_hero.sh > /tmp/build_hero.sh
apt install lsb-release curl gpg bash /tmp/build_hero.sh
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 ## Use Hero to Generate mdbooks
- Install other packages - You can download the repository.
``` ```
apt install pkg-config -y hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript/bookname -gp
apt-get install gcc -y ```
apt install libssl-dev - To open the mdbook on your local browser:
```
## Set Hero ```
hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript/bookname -o
```
- Download the hero installation script > Note: In both cases, make sure to replace **bookname** by the name of your book, e.g. test.
```
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 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;
```
- Start the ssh-agent
```
eval $(ssh-agent)
```
- Generate the mdbook with hero
```
hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript
```
- 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
- 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
```
- To see the mdbook live, open a browser on the local machine and go to localhost:3333
## 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.