jean-cloud-services/provisioning/roles/deploy_all/files/bin/hugo_rclone.sh

36 lines
1.1 KiB
Bash
Raw Normal View History

2023-08-28 18:25:32 +00:00
#!/bin/bash
2023-10-16 08:47:35 +00:00
. driglibash-base
2023-08-28 18:25:32 +00:00
set -euo pipefail
2023-10-16 08:47:35 +00:00
[ "$#" -ne 1 ] && die "Usage: $0 <hugo_directory>"
dest_dir="$1"
[ -z "$dest_dir" ] && die "Arg 'hugo_directory' should not be empty."
# Get content from nextcloud
if [ -v NC_SHARE_LINK ] ; then
webdav_url="$(echo "$NC_SHARE_LINK" | sed 's#/s/.*#/public.php/webdav/#')"
webdav_user="$(echo "$NC_SHARE_LINK" |sed 's#.*/s/##')"
webdav_pass="$(rclone obscure "$NC_SHARE_PASSWORD")"
2023-10-31 15:42:06 +00:00
rclone sync --config=/notfound --webdav-url="$webdav_url" --webdav-user="$webdav_user" --webdav-pass="$webdav_pass" --webdav-vendor=nextcloud :webdav: "$dest_dir/$CLOUD_LOCAL_PATH"
2023-10-16 08:47:35 +00:00
fi
2023-08-28 18:25:32 +00:00
2023-10-16 08:47:35 +00:00
# Go to website
cd "$dest_dir"
2023-08-28 18:25:32 +00:00
2023-10-16 08:47:35 +00:00
# Rename .attachement dirs created by nextcloud
while read filename ; do
oldname="$(basename "$filename")"
newname="${oldname:1}"
path="$(dirname "$filename")"
# And rename their references in md files
find -type f -iname '*.md' -exec sed -i "s/$oldname/$newname/g" {} \;
mv "$path/$oldname" "$path/$newname"
done < <(find -type d -name '.attachments.*')
2023-08-28 18:25:32 +00:00
2023-10-16 08:47:35 +00:00
# Build the website
2023-11-03 18:32:58 +00:00
hugo --ignoreCache