Ajout de l'article sur la réalisation d'un mirroir pour le site principal du projet Haiku

This commit is contained in:
yann64
2024-10-31 22:36:04 +01:00
parent 51c820c94e
commit 339286aee5
2 changed files with 134 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
---
date: 2024-10-30
title: Haiku project main site mirror
description: How I created a mirror for the Haiku project main website using a simple bash script.
authors:
- yann64
toc: false
category: Haiku
tags: Haiku
---
Whenever possible, the Haiku project tries to be self-hosted. This is not without constraints for a project with limited resources, and sometimes the official hosting is not accessible.
I created a script to create a mirror and be able to access the information when the main site is not accessible: https://barbel.synology.me/haiku/
I use the following Bash script :
```bash
# Change the following values to configure your mirror
# Path to the Hugo binary
HUGO_PATH="/path/to/hugo"
# The mirror website title
MIRROR_TITLE="Haiku Project (Yann64's Mirror)"
# The mirror base URL (must end with a slash '/')
MIRROR_BASEURL="https://barbel.synology.me/haiku/"
# Server base directory
MIRROR_ROOTPATH="/opt/http"
# Full path for Haiku site mirror
MIRROR_LOCALPATH="/opt/http/haiku"
# Update main site to latest version
echo "==> Clone website from the official repository :"
git clone https://github.com/haiku/website.git
cd website
sed -i "s/title = \"Haiku Project\"/title = \"$MIRROR_TITLE\"/" ./config.toml
sed -i "s@baseURL = \"https://www.haiku-os.org/\"@baseURL = \"$MIRROR_BASEURL\"@" ./config.toml
# Uncomment following lines if you want to change tickets source information
#sed -i "s@'https://cgit.haiku-os.org/haiku/commit/?id='@'https://git.barbel.synology.me/Haiku/haiku/commit/'@" ./static/js/activity.js
#sed -i "s@https://cgit.haiku-os.org/haiku/log/@https://git.barbel.synology.me/Haiku/haiku/commits/branch/master@ " ./themes/shijin4/layouts/partials/home.html
echo "==> Site generation using Hugo :"
$HUGO_PATH
echo "==> Copy files to destination forlder: "$MIRROR_LOCALPATH
cd public
cp -r * $MIRROR_LOCALPATH
cp -r ./images $MIRROR_ROOTPATH
echo "==> Cleaning"
cd ../..
rm -rf ./website
# Update userguide to latest version
echo "==> Clone userguide from the official repository :"
git clone "https://review.haiku-os.org/userguide"
cd userguide
echo "==> Copy files to destination forlder: $MIRROR_LOCALPATH/docs"
cp -r * "$MIRROR_LOCALPATH/docs"
echo "==> Cleaning"
cd ..
rm -rf ./userguide
echo "Done !"
```

View File

@@ -0,0 +1,68 @@
---
date: 2024-10-30
title: Un mirroir pour le site du projet Haiku
description: Comment j'ai créé un pirroir pour le site principal du projet Haiku à l'aide d'un simpls script Bash.
authors:
- yann64
slug: mirroir-haiku
toc: false
draft: false
category: Informatique
tags: Haiku
---
Dans la mesure du possible, le projet Haiku essaye dêtre auto hébergé. Cela nest pas sans contrainte pour un projet aux ressources encore limitées, et il arrive parfois que lhébergement officiel ne soit pas accessible.
Jai donc créé un script permettant de réaliser un mirroir du site principal et ainsi pouvoir accéder aux informations quand lhébergement principal nest pas accessible : https://barbel.synology.me/haiku/
Pour ce faire, j'utilise le script Bash suivant :
```bash
# Changer les valleurs suivantes pour configurer votre mirroir
# Chemin de l'exécutable Hugo
HUGO_PATH="/path/to/hugo"
# Titre du site mirroir
MIRROR_TITLE="Haiku Project (Yann64's Mirror)"
# UTL du mirroir (doit se terminer avec un slash '/')
MIRROR_BASEURL="https://barbel.synology.me/haiku/"
# Chemin racine du server web
MIRROR_ROOTPATH="/opt/http"
# Chemin complet du repertoire de stockage du mirroir
MIRROR_LOCALPATH="/opt/http/haiku"
# Mise à jour du mirroir à la dernière version
echo "==> Clone website from the official repository :"
git clone https://github.com/haiku/website.git
cd website
sed -i "s/title = \"Haiku Project\"/title = \"$MIRROR_TITLE\"/" ./config.toml
sed -i "s@baseURL = \"https://www.haiku-os.org/\"@baseURL = \"$MIRROR_BASEURL\"@" ./config.toml
# Décommenter les lignes suivantes et modifier pour changer la source des tickets d'évolution
#sed -i "s@'https://cgit.haiku-os.org/haiku/commit/?id='@'https://git.barbel.synology.me/Haiku/haiku/commit/'@" ./static/js/activity.js
#sed -i "s@https://cgit.haiku-os.org/haiku/log/@https://git.barbel.synology.me/Haiku/haiku/commits/branch/master@ " ./themes/shijin4/layouts/partials/home.html
echo "==> Site generation using Hugo :"
$HUGO_PATH
echo "==> Copy files to destination forlder: "$MIRROR_LOCALPATH
cd public
cp -r * $MIRROR_LOCALPATH
cp -r ./images $MIRROR_ROOTPATH
echo "==> Cleaning"
cd ../..
rm -rf ./website
# Update userguide to latest version
echo "==> Clone userguide from the official repository :"
git clone "https://review.haiku-os.org/userguide"
cd userguide
echo "==> Copy files to destination forlder: $MIRROR_LOCALPATH/docs"
cp -r * "$MIRROR_LOCALPATH/docs"
echo "==> Cleaning"
cd ..
rm -rf ./userguide
echo "Done !"
```