From f667ed7aa34168cd564c4e5a3d885c15c65e1914 Mon Sep 17 00:00:00 2001 From: Yannick Barbel Date: Thu, 31 Oct 2024 22:52:30 +0100 Subject: [PATCH] Add mirror script Use cron to run script at a regular interval --- haikumirror.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 haikumirror.sh diff --git a/haikumirror.sh b/haikumirror.sh new file mode 100644 index 0000000..f4cc2bb --- /dev/null +++ b/haikumirror.sh @@ -0,0 +1,48 @@ +#/bin/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 !" \ No newline at end of file