sdf/cluster-web-to-other.sh

92 lines
2.6 KiB
Bash
Raw Normal View History

#/bin/sh
2023-02-11 15:33:40 +00:00
month=$(date '+%m')
year=$(date '+%Y')
2023-02-14 22:52:30 +00:00
#
2023-02-13 19:54:06 +00:00
# Cluster
2023-02-14 22:52:30 +00:00
#
# Download the websites index HTML file
2023-02-13 19:54:06 +00:00
2023-02-11 15:33:40 +00:00
wget -O /sdf/arpa/ns/s/scm/index.html https://scm.sdf.org
# Download the websites posts HTML file
2023-02-14 22:52:30 +00:00
2023-02-16 21:49:03 +00:00
wget -O /sdf/arpa/ns/s/scm/$month.html https://scm.sdf.org/posts/$year/$month.html
2023-02-14 19:26:18 +00:00
# Convert the index HTML file to an index text file
2023-02-14 22:52:30 +00:00
2023-02-14 18:52:55 +00:00
html2text -o /sdf/arpa/ns/s/scm/index -ascii -style pretty /sdf/arpa/ns/s/scm/index.html
2023-02-11 15:33:40 +00:00
2023-02-16 00:56:01 +00:00
# Convert the posts HTML file to a text file
2023-02-14 22:52:30 +00:00
html2text -o /sdf/arpa/ns/s/scm/$month -ascii -style pretty /sdf/arpa/ns/s/scm/$month.html
2023-02-14 19:26:18 +00:00
2023-02-26 19:44:41 +00:00
# Write the footer text file from the index text file
tail -n 15 /sdf/arpa/ns/s/scm/index > footer
# Remove the posts header line from the index HTML file
sed -i 's/<h3>Posts<\/h3>//' /sdf/arpa/ns/s/scm/index.html
# Remove the posts lines from the index HTML file
sed -i "s/<h4><a href="https\:\/\/scm.sdf.org\/posts\/{$year}\/{$month}.html">{$year}<\/a><\/h4>//" /sdf/arpa/ns/s/scm/index.html
2023-02-16 00:56:01 +00:00
# Remove the blank lines from the beginning of the index file
sed -i '1d;2d;3d' /sdf/arpa/ns/s/scm/index
# Remove the blank lines from the beginning of the posts file
2023-02-16 21:49:03 +00:00
sed -i '1d;2d;3d' /sdf/arpa/ns/s/scm/$month
2023-02-16 00:56:01 +00:00
# Remove the control characters from the index file
cat /sdf/arpa/ns/s/scm/index | col -b -x > /sdf/arpa/ns/s/scm/index.sdf
# Remove the control characters from the posts file
cat /sdf/arpa/ns/s/scm/$month | col -b -x > /sdf/arpa/ns/s/scm/$month.sdf
# Remove the control characters from the footer file
cat /sdf/arpa/ns/s/scm/footer | col -b -x > /sdf/arpa/ns/s/scm/footer.sdf
# Write the posts text file to the .plan cluster text file
2023-02-22 19:17:33 +00:00
# Change the head number as needed when the index.html file is changed
2023-02-20 03:15:55 +00:00
2023-02-25 00:41:03 +00:00
head -n 5 index.sdf > /sdf/arpa/ns/s/scm/header
cat /sdf/arpa/ns/s/scm/$month.sdf > body
2023-02-21 15:42:52 +00:00
cat /sdf/arpa/ns/s/scm/header > /sdf/arpa/ns/s/scm/.plan
cat /sdf/arpa/ns/s/scm/body >> /sdf/arpa/ns/s/scm/.plan
cat /sdf/arpa/ns/s/scm/footer.sdf >> /sdf/arpa/ns/s/scm/.plan
2023-02-16 00:56:01 +00:00
2023-02-22 19:17:33 +00:00
# Write the index text file to the root directory of Gopher
2023-02-14 22:52:30 +00:00
cp /sdf/arpa/ns/s/scm/index.sdf /ftp/pub/users/scm/index
2023-02-13 19:54:06 +00:00
2023-02-22 19:17:33 +00:00
# Write the posts text file to the posts directory of Gopher
2023-02-14 19:26:18 +00:00
cp /sdf/arpa/ns/s/scm/$month.sdf /ftp/pub/users/scm/posts/$year/$month
2023-02-14 23:35:14 +00:00
2023-02-16 00:56:01 +00:00
# Set the proper Gopher directory permissions
2023-02-14 23:35:14 +00:00
chmod -R 754 /ftp/pub/users/scm
2023-02-14 19:37:49 +00:00
2023-02-14 22:52:30 +00:00
#
2023-02-13 19:54:06 +00:00
# Meta Array
2023-02-14 22:52:30 +00:00
#
scp /sdf/arpa/ns/s/scm/.plan scm@ma.sdf.org:/meta/s/scm
2023-02-13 19:54:06 +00:00
2023-02-25 00:41:03 +00:00
scp /sdf/arpa/ns/s/scm/header scm@ma.sdf.org:/meta/gemini/scm/index.gmi
cat /sdf/arpa/ns/s/scm/body | ssh scm@ma.sdf.org "cat >> /meta/gemini/scm/index.gmi"
2023-02-14 22:52:30 +00:00
scp /sdf/arpa/ns/s/scm/$month.sdf scm@ma.sdf.org:/meta/gemini/scm/posts/$year/$month.gmi
2023-02-14 21:44:59 +00:00
2023-02-11 15:33:40 +00:00
exit 0