#!/bin/bash
set -eo pipefail
# Set locale to C.UTF-8
export "LANG=C.UTF-8"
export "LC_LOCALE=${LANG}"
# Create and cd into 'out' directory
if [ -n "${LINKGEN_TRASH_OUT_DIR}" ]; then
echo ":: Removing \"out\" directory"
rm -rf out
mkdir -p out
elif [ ! -d "out" ]; then
echo ":: Creating \"out\" directory"
mkdir -p out
fi
cd out
if [ -n "${LINKGEN_VERBOSE}" ]; then
echo ":: Enabling verbose output"
set -x
fi
# Function to generate a link
function generate-link() {
echo ":: Creating link '${1}' titled '${2}' redirecting to '${3}'"
cp ../template.html "${1}.html"
sed -i "s/\_TITLE\_/${2//\//\\/}/g" "${1}.html"
sed -i "s/\_RDURL\_/${3//\//\\/}/g" "${1}.html"
}
if [ -z "${LINKGEN_NO_DEFAULT}" ]; then
# LINKGEN_NO_DEFAULT is undefined, generate default links
echo ":: Generating StarOpenSource's default links"
# Index
cat << EOF > index.html
Redirecting to nowhere
Hello! You've landed on StarOpenSource's redirection website.
You can visit the source code for this website here .
Here are some links you can try out:
[website] [status] [/fs/] [repos]
EOF
# Robots
cat << EOF > robots.txt
User-Agent: *
Disallow: /
EOF
# General
generate-link "website" "StarOpenSource's website" "https://staropensource.de"
generate-link "status" "StarOpenSource Infrastructure Status" "https://status.staropensource.de"
generate-link "filesystem" "StarOpenSource /fs/" "https://fs.staropensource.de"
generate-link "git" "sos!git" "https://git.staropensource.de"
generate-link "fedi" "sos!fly" "https://fly.staropensource.de"
generate-link "piped" "sos!piped" "https://piped.staropensource.de"
# Social
generate-link "social-fedi" "StarOpenSource's fediverse profile" "https://fly.staropensource.de/@StarOpenSource"
# Policies
generate-link "constitution" "StarOpenSource's Project Constitution" "https://docs.staropensource.de/policies/constitution/"
generate-link "tos" "StarOpenSource's General Terms of Service" "https://docs.staropensource.de/category/terms-of-service/"
generate-link "tos-general" "StarOpenSource's General Terms of Service" "https://docs.staropensource.de/policies/tos/general/"
generate-link "tos-git" "sos!git's Terms of Service" "https://docs.staropensource.de/policies/tos/git/"
generate-link "tos-fedi" "sos!fly's Terms of Service" "https://docs.staropensource.de/policies/tos/fly/"
# Repositories
generate-link "repos" "StarOpenSource's repositories" "https://git.staropensource.de"
generate-link "repos-engine" "StarOpenSource Engine repository" "https://git.staropensource.de/StarOpenSource/Engine"
generate-link "repos-enginemc" "StarOpenSource Engine Minecraft port repository" "https://git.staropensource.de/StarOpenSource/EngineMC"
generate-link "repos-bashutils" "bashutils repository" "https://git.staropensource.de/StarOpenSource/bashutils"
generate-link "repos-core" "CORE Framework repository" "https://git.staropensource.de/StarOpenSource/CORE"
generate-link "repos-sui" "StarOpenSource UI repository" "https://git.staropensource.de/StarOpenSource/SUI"
generate-link "repos-besseretests" "Bessere Tests repository" "https://git.staropensource.de/StarOpenSource/BessereTests"
generate-link "repos-server-kernel" "StarOpenSource's server kernel repository" "https://git.staropensource.de/Archive/server-kernel"
generate-link "repos-redirector" "StarOpenSource's link redirector" "https://git.staropensource.de/StarOpenSource-Infrastructure/website-redirector"
# Documentation
generate-link "docs" "StarOpenSource's documentation" "https://docs.staropensource.de"
generate-link "docs-engine" "StarOpenSource Engine documentation" "https://engine.staropensource.de"
generate-link "docs-enginemc" "StarOpenSource EngineMC documentation" "https://git.staropensource.de/StarOpenSource/EngineMC/src/branch/develop/README.md"
generate-link "docs-bashutils" "bashutils documentation" "https://bashutils.staropensource.de"
generate-link "docs-core" "The CORE Framework documentation" "https://core.staropensource.de"
generate-link "docs-sui" "StarOpenSource UI documentation" "https://sui.staropensource.de"
else
# LINKGEN_NO_DEFAULT is defined, generate custom link
if [ -z "${3}" ]; then
# Not enough arguments, display help
echo ":: At least three arguments are required."
echo " Usage: ./build.sh \ \ \ "
else
# Enough arguments, generate link
generate-link "${1}" "${2}" "${3}"
fi
fi