103 lines
4.7 KiB
Bash
Executable file
103 lines
4.7 KiB
Bash
Executable file
#!/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
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<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>
|
|
</html>
|
|
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://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"
|
|
# Miscellaneous
|
|
generate-link "join" "the joining guide" "https://docs.staropensource.de/joining/"
|
|
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 \<link name\> \<link title\> \<link url\>"
|
|
else
|
|
# Enough arguments, generate link
|
|
generate-link "${1}" "${2}" "${3}"
|
|
fi
|
|
fi
|