Want to contribute? Fork me on Codeberg.org!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

#!/usr/bin/env bash
main() {
declare hugo_publish_dir=public
declare stork_config_file=stork.config.json # generated by hugo
declare stork_index_file=home.st # generated by stork (json suffix triggers gzip/br compression)
declare stork_arch=stork-ubuntu-20-04
declare stork_releases=https://files.stork-search.net/releases
declare stork_version=1.5.0
declare stork_exec=${stork_arch}-${stork_version}
declare stork_url=${stork_releases}/v${stork_version}/${stork_arch}
# Install Stork if it's not already installed.
if [[ ! -f "${stork_exec}" ]]; then
echo -e "\nInstalling Stork...\n"
wget --no-verbose "${stork_url}" ||
{ echo "Error: unable to wget ${stork_url}"; exit 1; }
mv "${stork_arch}" "${stork_exec}" ||
{ echo "Error: unable to mv ${stork_arch} ${stork_exec}"; exit 1; }
chmod +x "${stork_exec}" ||
{ echo "Error: unable to chmod ${stork_exec}"; exit 1; }
fi
# Build the Stork index.
echo -e "\nBuilding Stork index...\n"
./${stork_exec} build --input "${hugo_publish_dir}/${stork_config_file}" --output "${hugo_publish_dir}/${stork_index_file}" ||
{ echo "Error: unable to run stork"; exit 1; }
}
set -euo pipefail
main "$@"