cosmic-backup/gopher/ships/ship/gophermap

26 lines
686 B
Bash
Executable File

#!/bin/sh
ship="$(/bin/pwd -L | sed 's|.*/||')"
desc="/var/gopher/${ship}/.description"
if [ -f "$desc" ]; then
cat "$desc"
printf "\\n"
fi
printf "%s - Ship Log\\n" "$ship"
tac "/var/gopher/listing.gophermap" | sed "s|^0||" | awk '{print 0 NR " >> " $0}' | grep "^.*>>\\ ${ship}"
printf "\\n\\n"
auth="/var/gopher/${ship}/AUTHOR"
if [ -f "$auth" ]; then
printf "0© %s %s\\t/%s/AUTHOR\\n" "$(date +%Y)" "$(head -n 1 "$auth")" "$ship"
else
printf "© %s %s\\n" "$(date +%Y)" "$(stat -c %U "/var/gopher/${ship}")"
fi
lic="/var/gopher/${ship}/LICENSE"
if [ -f "$lic" ]; then
printf "0%s\\t/%s/LICENSE" "$(head -n 1 "$lic")" "$ship"
else
printf "All rights reserved.\\n"
fi