Merge branch 'main' of git.ourworld.tf:tfgrid/info_tfgrid

* 'main' of git.ourworld.tf:tfgrid/info_tfgrid:
  Update docs/hero_mdbook_fullvm.md
  Update docs/hero_mdbook_fullvm.md
  Update scripts/hero_mdbook.sh
This commit is contained in:
despiegk 2024-02-23 16:07:54 +03:00
commit 2911384605
Signed by: despiegk
GPG Key ID: 99E4E1492F73BC18
2 changed files with 81 additions and 70 deletions

View File

@ -5,7 +5,7 @@
- [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](#install-cargo) - [Install cargo and mdbook](#install-cargo-and-mdbook)
- [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)
@ -23,13 +23,21 @@ For this guide, we show an example using the mdbook from the repository [info_tf
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 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. 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 ## Setting the Full VM
We start by deploying a full VM with WireGuard on the TFGrid. We start by deploying a full VM with WireGuard on the TFGrid. We also set an SSH tunnel.
To connect to the VM, we will be using a remote explorer. - 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 ### Remote Explorer Access
@ -49,9 +57,7 @@ You can use the remote explorer feature of both [VSCode](https://marketplace.vis
apt update && apt upgrade -y apt update && apt upgrade -y
``` ```
### Install cargo ### Install cargo and mdbook
Once you install cargo, all mdbook dependencies will be installed via the hero script.
- Install cargo rust for linux and mac (with default installation) - Install cargo rust for linux and mac (with default installation)
``` ```
@ -61,6 +67,10 @@ Once you install cargo, all mdbook dependencies will be installed via the hero s
``` ```
source "$HOME/.cargo/env" source "$HOME/.cargo/env"
``` ```
- Install mdbook
```
cargo install mdbook
```
### Install redis ### Install redis
@ -120,7 +130,7 @@ Once you install cargo, all mdbook dependencies will be installed via the hero s
- 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 --hostname 0.0.0.0 --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

View File

@ -1,63 +1,64 @@
#!/bin/bash #!/bin/bash
# Generate opening text. # Generate opening text.
cat <<EOF cat <<EOF
* * * * * * * * * *
Welcome! Welcome!
The script will install hero and set the environment to work with mdbook. The script will install hero and set the environment to work with mdbook.
This will take a couple of minutes. This will take a couple of minutes.
* * * * * * * * * *
EOF EOF
sleep 2 sleep 2
# Disable "Pending kernel upgrade" and "Daemons using outdated libraries" windows # Disable "Pending kernel upgrade" and "Daemons using outdated libraries" windows
sed -i "s/#\$nrconf{kernelhints} = -1;/\$nrconf{kernelhints} = -1;/g" /etc/needrestart/needrestart.conf 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 sed -i "/#\$nrconf{restart} = 'i';/s/.*/\$nrconf{restart} = 'a';/" /etc/needrestart/needrestart.conf
# Update and install dependencies # Update and install dependencies
apt-get update apt-get update
apt-get install -y lsb-release gpg apt-get install -y lsb-release gpg
curl https://sh.rustup.rs -sSf | sh -s -- -y curl https://sh.rustup.rs -sSf | sh -s -- -y
source "$HOME/.cargo/env" source "$HOME/.cargo/env"
export PATH=$PATH:/root/.cargo/bin export PATH=$PATH:/root/.cargo/bin
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg /root/.cargo/bin/cargo install mdbook
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 curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
apt-get update 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 install -y redis pkg-config gcc libssl-dev apt-get update
apt-get install -y redis pkg-config gcc libssl-dev
# Download and run the hero installer script
curl https://raw.githubusercontent.com/freeflowuniverse/crystallib/development/scripts/installer_hero.sh > /tmp/hero_install.sh # Download and run the hero installer script
bash /tmp/hero_install.sh curl https://raw.githubusercontent.com/freeflowuniverse/crystallib/development/scripts/installer_hero.sh > /tmp/hero_install.sh
bash /tmp/hero_install.sh
# Start the SSH agent, run hero mdbook and build the mdbook
eval $(ssh-agent) # Start the SSH agent, run hero mdbook and build the mdbook
hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript eval $(ssh-agent)
cd /root/hero/var/mdbuild/duniayetu hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript
mdbook build cd /root/hero/var/mdbuild/duniayetu
mdbook build
# Generate closing text after successful script.
cat <<EOF # Generate closing text after successful script.
cat <<EOF
* * * * *
* * * * *
The script has been successfully completed.
The script has been successfully completed.
To see the mdbook live on your browser,
run the following command with the proper port (here we use 3333). To see the mdbook live on your browser,
run the following command with the proper port (here we use 3333).
mdbook serve --hostname 0.0.0.0 --port 3333
mdbook serve --hostname 0.0.0.0 --port 3333
Happy mdbooking!
Happy mdbooking!
* * * * *
* * * * *
EOF
EOF
# Send stderr to null and exit gracefully
# Send stderr to null and exit gracefully
return 2> /dev/null; exit return 2> /dev/null; exit