#!/bin/sh run_user=$(id -u) if [ "$run_user" -eq 0 ]; then file_rss="/var/www/html/rss.xml" gopher_rss="/var/gopher/rss.xml" ###################################################################### ############################# HTML VERSION ########################### ###################################################################### # Add header info to xml output { printf '' printf '' printf "\\nCosmic Voyage\\n" printf "https://cosmic.voyage\\n" printf "Messages from the human stellar diaspora\\n" } > "${file_rss}" # Loop through listings gophermap while read -r line; do log=$(printf "%s" "$line" | awk -F'\t' '{print $2}') title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed 's|^.||') owner=$(stat -c %U "/var/gopher${log}") # print item entry for each log { printf "\\n" printf " %s\\n" "$title" printf " %s@cosmic.voyage (%s)\\n" "$owner" "$owner" printf " https://cosmic.voyage%s\\n" "$(printf "%s" "$log" | sed 's|.txt$|.html|' | sed 's|\ |%20|')" printf " https://cosmic.voyage%s\\n" "$(printf "%s" "$log" | sed 's|.txt$|.html|' | sed 's|\ |%20|')" printf " %s GMT\\n" "$(date -d "$(stat -c %y "/var/gopher${log}")" +'%a, %d %b %Y %H:%M:%S')" printf " \\n" sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g' "/var/gopher${log}" printf "]]>\\n" printf "\\n" } >> "${file_rss}" done < "/var/gopher/listing.gophermap" # close up the footer { printf "\\n" printf "\\n" } >> "${file_rss}" ###################################################################### ########################## GOPHER VERSION ########################### ###################################################################### # Add header info to xml output { printf '' printf '' printf "\\nCosmic Voyage\\n" printf "gopher://cosmic.voyage\\n" printf "Messages from the human stellar diaspora\\n" } > "${gopher_rss}" # Loop through listings gophermap while read -r line; do log=$(printf "%s" "$line" | awk -F'\t' '{print $2}') title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed 's|^.||') owner=$(stat -c %U "/var/gopher${log}") # print item entry for each log { printf "\\n" printf " %s\\n" "$title" printf " %s@cosmic.voyage (%s)\\n" "$owner" "$owner" printf " gopher://cosmic.voyage/0%s\\n" "$log" printf " gopher://cosmic.voyage/0%s\\n" "$log" printf " %s GMT\\n" "$(date -d "$(stat -c %y "/var/gopher${log}")" +'%a, %d %b %Y %H:%M:%S')" printf " \\n" printf "\\n" } >> "${gopher_rss}" done < "/var/gopher/listing.gophermap" # close up the footer { printf "\\n" printf "\\n" } >> "${gopher_rss}" else exec sudo "$0" "$@" fi