Merge pull request 'development_script_hero' (#9) from development_script_hero into main
Reviewed-on: #9
This commit is contained in:
commit
9e9395cc61
@ -3,45 +3,56 @@
|
|||||||
<h2>Table of Contents</h2>
|
<h2>Table of Contents</h2>
|
||||||
|
|
||||||
- [Introduction](#introduction)
|
- [Introduction](#introduction)
|
||||||
- [Prerequisites](#prerequisites)
|
|
||||||
- [Setting the Full VM](#setting-the-full-vm)
|
- [Setting the Full VM](#setting-the-full-vm)
|
||||||
|
- [Remote Explorer Access](#remote-explorer-access)
|
||||||
- [Install cargo](#install-cargo)
|
- [Install cargo](#install-cargo)
|
||||||
- [Install redis](#install-redis)
|
- [Install redis](#install-redis)
|
||||||
- [Install pkg-config, gcc and libssl](#install-pkg-config-gcc-and-libssl)
|
- [Install pkg-config, gcc and libssl](#install-pkg-config-gcc-and-libssl)
|
||||||
- [Set Hero](#set-hero)
|
- [Set Hero](#set-hero)
|
||||||
- [Generate the mdbook](#generate-the-mdbook)
|
- [Generate the mdbook](#generate-the-mdbook)
|
||||||
- [Access the mdbook from your local machine with the SSH tunnel](#access-the-mdbook-from-your-local-machine-with-the-ssh-tunnel)
|
- [Serve and View the mdbook](#serve-and-view-the-mdbook)
|
||||||
|
- [Questions and Feedback](#questions-and-feedback)
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
We show how to work with mdbook using the [hero](https://github.com/freeflowuniverse/crystallib/tree/development/cli/hero) tool.
|
In this tutorial, we show all the steps 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).
|
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.
|
||||||
|
|
||||||
This guide can be done locally or on a VM. It should be run as root. We show the steps for a full VM deployed on the TFGrid with WireGuard.
|
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.
|
||||||
|
|
||||||
## Prerequisites
|
We will be using SSH to connect to the VM and to create an SSH tunnel between the local machine and the VM. This will allow the mdbook output to be displayed on a local browser.
|
||||||
|
|
||||||
On the full VM, you will need to install the following:
|
To manage the mdbook files, we will be using the remote explorer feature of either VSCodium or VSCode.
|
||||||
|
|
||||||
- cargo
|
## Setting the Full VM
|
||||||
- redis
|
|
||||||
- gcc
|
|
||||||
- pkg-config
|
|
||||||
- libssl-dev
|
|
||||||
|
|
||||||
Steps will be shown to install those prerequisites.
|
We start by deploying a full VM with WireGuard on the TFGrid. We also set an SSH tunnel.
|
||||||
|
|
||||||
## Setting the Full VM
|
|
||||||
|
|
||||||
- Deploy a full VM with WireGuard on the TFGrid
|
- Deploy a full VM with WireGuard on the TFGrid
|
||||||
- Connect to the full VM with an SSH tunnel on port 3333 on both local and VM
|
- Set an SSH tunnel, on port 3333 for both local and VM
|
||||||
```
|
```
|
||||||
ssh -4 -L 3333:127.0.0.1:3333 root@10.20.4.2
|
ssh -4 -L 3333:127.0.0.1:3333 root@10.20.4.2
|
||||||
```
|
```
|
||||||
- Prepare the VM:
|
|
||||||
|
Instead of working on the SSH tunnel terminal window, we will be using the remote explorer feature of a source-code editor.
|
||||||
|
|
||||||
|
### 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`
|
||||||
|
- Update and upgrade the VM
|
||||||
```
|
```
|
||||||
apt update && apt upgrade -y
|
apt update && apt upgrade -y
|
||||||
```
|
```
|
||||||
@ -113,10 +124,14 @@ Once you install cargo, all mdbook dependencies will be installed via the hero s
|
|||||||
mdbook build
|
mdbook build
|
||||||
```
|
```
|
||||||
|
|
||||||
## Access the mdbook from your local machine with the SSH tunnel
|
## 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)
|
- 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
|
mdbook serve --port 3333
|
||||||
```
|
```
|
||||||
- To see the mdbook live, open a browser on the local machine and go to localhost: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.
|
78
docs/hero_mdbook_fullvm_script.md
Normal file
78
docs/hero_mdbook_fullvm_script.md
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<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 to create an SSH tunnel between the local machine and the VM. This will allow the mdbook output to be displayed 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. 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
|
||||||
|
```
|
||||||
|
ssh -4 -L 3333:127.0.0.1:3333 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.
|
||||||
|
|
||||||
|
## 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 --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.
|
38
scripts/hero_mdbook.sh
Normal file
38
scripts/hero_mdbook.sh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
sed -i "s/#\$nrconf{kernelhints} = -1;/\$nrconf{kernelhints} = -1;/g" /etc/needrestart/needrestart.conf
|
||||||
|
sed -i "/#\$nrconf{restart} = 'i';/s/.*/\$nrconf{restart} = 'a';/" /etc/needrestart/needrestart.conf
|
||||||
|
apt update && apt upgrade -y
|
||||||
|
curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||||
|
source "$HOME/.cargo/env"
|
||||||
|
export PATH=$PATH:/root/.cargo/bin
|
||||||
|
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
|
||||||
|
apt install pkg-config -y
|
||||||
|
apt-get install gcc -y
|
||||||
|
apt install libssl-dev
|
||||||
|
curl https://raw.githubusercontent.com/freeflowuniverse/crystallib/development/scripts/installer_hero.sh > /tmp/hero_install.sh
|
||||||
|
bash /tmp/hero_install.sh
|
||||||
|
eval $(ssh-agent)
|
||||||
|
hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript
|
||||||
|
cd /root/hero/var/mdbuild/duniayetu
|
||||||
|
mdbook build
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
* * * * *
|
||||||
|
|
||||||
|
The script has been successfully completed.
|
||||||
|
|
||||||
|
To see the mdbook live on your browser with the SSH tunnel,
|
||||||
|
run the following command with the proper port (here we use 3333).
|
||||||
|
|
||||||
|
mdbook serve --port 3333
|
||||||
|
|
||||||
|
Happy mdbooking!
|
||||||
|
|
||||||
|
* * * * *
|
||||||
|
|
||||||
|
EOF
|
||||||
|
return 2> /dev/null; exit
|
Loading…
Reference in New Issue
Block a user