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)
- [Setting the Full VM](#setting-the-full-vm)
- [Remote Explorer Access](#remote-explorer-access)
- [Install cargo and mdbook](#install-cargo-and-mdbook)
- [Install redis](#install-redis)
- [Install pkg-config, gcc and libssl](#install-pkg-config-gcc-and-libssl)
- [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)
- [Set the SSH Key Pair](#set-the-ssh-key-pair)
- [Install hero, crysallib and V](#install-hero-crysallib-and-v)
- [Use Hero to Generate mdbooks](#use-hero-to-generate-mdbooks)
***
@ -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.
- 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.
@ -52,88 +48,59 @@ You can use the remote explorer feature of both [VSCode](https://marketplace.vis
- 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`
- 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)
```
curl https://sh.rustup.rs -sSf | sh
```
- Configure the current shell
```
source "$HOME/.cargo/env"
```
- Install mdbook
```
cargo install mdbook
```
- Generate an SSH key pair
- To make it work with info_tfgrid, use books for the filename
```
ssh-keygen # save in /root/.ssh/books
```
- Note the public key
```
cat ~/.ssh/books.pub
```
- Add the SSH public key on git.ourworld.tf and github
- 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
```
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
```
```
curl https://raw.githubusercontent.com/freeflowuniverse/crystallib/development/scripts/build_hero.sh > /tmp/build_hero.sh
bash /tmp/build_hero.sh
```
### Install pkg-config, gcc and libssl
## Use Hero to Generate mdbooks
- Install other packages
```
apt install pkg-config -y
apt-get install gcc -y
apt install libssl-dev
```
- 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:
## Set Hero
```
hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript/bookname -o
```
- 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
```
> Note: In both cases, make sure to replace **bookname** by the name of your book, e.g. test.
## 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.