forked from cosmic/cosmic
basic rss generator added
This commit is contained in:
parent
f274429552
commit
6fbff155c3
40
cosmic-rss
Executable file
40
cosmic-rss
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
|
||||
run_user=$(id -u)
|
||||
if [ "$run_user" -eq 0 ]; then
|
||||
file_rss="/var/www/html/rss.xml"
|
||||
|
||||
# Add header info to xml output
|
||||
{
|
||||
printf '<?xml version="1.0"?><rss version="2.0"><channel>'
|
||||
printf "\\n<title>Cosmic Voyage</title>\\n"
|
||||
printf "<link>gopher://cosmic.voyage</link>\\n"
|
||||
printf "<description>Messages from the human stellar diaspora</description>\\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|^.||')
|
||||
|
||||
# print item entry for each log
|
||||
{
|
||||
printf "<item>\\n"
|
||||
printf " <title>%s</title>\\n" "$title"
|
||||
printf " <link>gopher://cosmic.voyage/0/%s</link>\\n" "$log"
|
||||
# printf " <pubdate>%s</pubdate>\\n" "$(date_func "$date")"
|
||||
printf " <description><![CDATA[<pre>\\n"
|
||||
cat "/var/gopher${log}"
|
||||
printf "</pre>]]></description>\\n"
|
||||
printf "</item>\\n"
|
||||
} >> "${file_rss}"
|
||||
done < "/var/gopher/listing.gophermap"
|
||||
|
||||
# close up the footer
|
||||
{
|
||||
printf "</channel>\\n"
|
||||
printf "</rss>\\n"
|
||||
} >> "${file_rss}"
|
||||
else
|
||||
printf "You must be root to run this script.\\n"
|
||||
fi
|
|
@ -9,6 +9,10 @@ if [ ! -L "/usr/local/bin/cosmic-user" ]; then
|
|||
ln -s "${DIR}/cosmic-user" "/usr/local/bin/cosmic-user"
|
||||
fi
|
||||
|
||||
if [ ! -L "/usr/local/bin/cosmic-rss" ]; then
|
||||
ln -s "${DIR}/cosmic-rss" "/usr/local/bin/cosmic-rss"
|
||||
fi
|
||||
|
||||
if [ ! -L "/usr/local/bin/cosmic-ship" ]; then
|
||||
ln -s "${DIR}/cosmic-ship" "/usr/local/bin/cosmic-ship"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue
Block a user