2024-04-20 13:27:05 +02:00
#!/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
2024-12-04 18:51:33 +01:00
echo ":: Removing \"out\" directory"
rm -rf out
mkdir -p out
2024-04-20 13:27:05 +02:00
elif [ ! -d "out" ] ; then
2024-12-04 18:51:33 +01:00
echo ":: Creating \"out\" directory"
mkdir -p out
2024-04-20 13:27:05 +02:00
fi
cd out
if [ -n " ${ LINKGEN_VERBOSE } " ] ; then
2024-12-04 18:51:33 +01:00
echo ":: Enabling verbose output"
set -x
2024-04-20 13:27:05 +02:00
fi
# Function to generate a link
function generate-link( ) {
2024-12-04 18:51:33 +01:00
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 "
2024-04-20 13:27:05 +02:00
}
if [ -z " ${ LINKGEN_NO_DEFAULT } " ] ; then
2024-12-04 18:51:33 +01:00
# LINKGEN_NO_DEFAULT is undefined, generate default links
echo ":: Generating StarOpenSource's default links"
# Index
cat << EOF > index.html
2024-04-20 13:46:18 +02:00
<!DOCTYPE html>
<html>
2024-05-04 18:42:55 +02:00
<head>
<title>Redirecting to nowhere</title>
<meta charset = "UTF-8" />
</head>
<body>
<center>
<p>Hello! You've landed on StarOpenSource' s redirection website.</p>
<p>You can visit the source code for this website <a href = "/repos-redirector" >here</a>.</p>
<br/>
<p>Here are some links you can try out:</p>
<p><a href = "/website" >[ website] </a> <a href = "/status" >[ status] </a> <a href = "/filesystem" >[ /fs/] </a> <a href = "/repos" >[ repos] </a></p>
</center>
</body>
2024-04-20 13:46:18 +02:00
</html>
EOF
2024-12-04 18:51:33 +01:00
# Robots
cat << EOF > robots.txt
2024-04-20 13:46:18 +02:00
User-Agent: *
Disallow: /
EOF
2024-12-04 18:51:33 +01:00
# 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://docs.staropensource.de/projects/"
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"
# Specifications
generate-link "spec" "StarOpenSource's specifications" "https://docs.staropensource.de/specifications/"
generate-link "spec-versioning" "the StarOpenSource Versioning Specification" "https://docs.staropensource.de/specifications/versioning/about/"
generate-link "spec-versioning-v1" "the 1st version of the StarOpenSource Versioning Specification" "https://docs.staropensource.de/specifications/versioning/versions/1/"
generate-link "spec-versioning-v2" "the 2nd version of the StarOpenSource Versioning Specification" "https://docs.staropensource.de/specifications/versioning/versions/2/"
generate-link "spec-logging" "the StarOpenSource Logging Specification" "https://docs.staropensource.de/specifications/logging/about/"
generate-link "spec-logging-v1" "the 1st version of the StarOpenSource Logging Specification" "https://docs.staropensource.de/specifications/logging/versions/1/"
generate-link "spec-logging-v2" "the 2nd version of the StarOpenSource Logging Specification" "https://docs.staropensource.de/specifications/logging/versions/2/"
# Miscellaneous
generate-link "join" "the joining guide" "https://docs.staropensource.de/joining/"
2024-04-20 13:27:05 +02:00
else
2024-12-04 18:51:33 +01:00
# 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 \<link name\> \<link title\> \<link url\>"
else
# Enough arguments, generate link
generate-link " ${ 1 } " " ${ 2 } " " ${ 3 } "
fi
2024-04-20 13:27:05 +02:00
fi