Files
website_to_other/gopher_map.sh
2026-01-27 20:48:10 +00:00

49 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# gopher_map.sh
# This script is part of the website to other project, which converts a
# website to other formats.
# Copyright (c) 2024-2026, Scott C. MacCallum (scm@sdf.org).
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Verify that cat, printf, and pwd are available
for prog in cat printf; do
command -v "$prog" >/dev/null 2>&1 || {
printf 'Error: required program not found: %s\n' "$prog" >&2
exit 1
}
done
printf "Writing gopher map...\n"
cwd=$(pwd -P) || exit 1
# Example: /ftp/pub/users/user
GopherDir=""
# Verify gophermap exists and can be read
if ! cat "$cwd/gopher/gophermap" > /dev/null; then
printf 'Error: required file does not exist or cannot be read: %s\n' "$FILE" >&2
exit 1
fi
# Write gophermap
cp $cwd/gopher/gophermap $GopherDir/gophermap