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
|
|
|
|
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"
|
2024-04-20 13:46:18 +02:00
|
|
|
# Index
|
|
|
|
cat << EOF >> index.html
|
|
|
|
<!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
|
|
|
|
# Robots
|
|
|
|
cat << EOF >> robots.txt
|
|
|
|
User-Agent: *
|
|
|
|
Disallow: /
|
|
|
|
EOF
|
2024-04-20 13:27:05 +02: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"
|
2024-05-04 17:48:17 +02:00
|
|
|
# Social
|
|
|
|
generate-link "social-fedi" "StarOpenSource's fediverse profile" "https://fly.staropensource.de/@StarOpenSource"
|
2024-04-20 13:27:05 +02:00
|
|
|
# Terms of Service
|
|
|
|
generate-link "tos" "StarOpenSource's General Terms of Service" "https://staropensource.de/#general"
|
|
|
|
generate-link "tos-general" "StarOpenSource's General Terms of Service" "https://staropensource.de/#general"
|
|
|
|
generate-link "tos-git" "sos!git's Terms of Service" "https://staropensource.de/#sosgit"
|
|
|
|
generate-link "tos-fedi" "sos!fly's Terms of Service" "https://staropensource.de/#sosfly"
|
|
|
|
# Repositories
|
|
|
|
generate-link "repos" "StarOpenSource's repositories" "https://git.staropensource.de"
|
|
|
|
generate-link "repos-core" "The 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/StarOpenSource/server-kernel"
|
2024-04-20 15:29:48 +02:00
|
|
|
generate-link "repos-redirector" "StarOpenSource's link redirector" "https://git.staropensource.de/StarOpenSource-Infrastructure/website-redirector"
|
2024-04-20 13:27:05 +02:00
|
|
|
# Documentation
|
|
|
|
generate-link "docs" "StarOpenSource's documentation" "https://docs.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 \<link name\> \<link title\> \<link url\>"
|
|
|
|
else
|
|
|
|
# Enough arguments, generate link
|
|
|
|
generate-link "${1}" "${2}" "${3}"
|
|
|
|
fi
|
|
|
|
fi
|