sdf-scripts/cluster-web-to-other.sh

91 lines
2.5 KiB
Bash
Raw Normal View History

#/bin/sh
2023-02-11 10:33:40 -05:00
month=$(date '+%m')
year=$(date '+%Y')
2023-02-14 17:52:30 -05:00
#
2023-02-13 14:54:06 -05:00
# Cluster
2023-02-14 17:52:30 -05:00
#
# Download the websites index HTML file
2023-02-13 14:54:06 -05:00
2023-02-11 10:33:40 -05:00
wget -O /sdf/arpa/ns/s/scm/index.html https://scm.sdf.org
# Download the websites posts HTML file
2023-02-14 17:52:30 -05:00
2023-02-16 16:49:03 -05:00
wget -O /sdf/arpa/ns/s/scm/$month.html https://scm.sdf.org/posts/$year/$month.html
2023-02-14 14:26:18 -05:00
# Remove the post related lines from the index HTML file
2023-02-15 16:56:36 -05:00
2023-02-16 20:47:37 -05:00
sed -i 's/<h3>Posts<\/h3>//' /sdf/arpa/ns/s/scm/index.html
2023-02-15 16:56:36 -05:00
2023-02-16 21:39:11 -05:00
# This line works as it is but ideally the year and month would use
# variables. I don't know how to this yet and will move forward.
2023-02-16 20:47:37 -05:00
sed -i 's/<h4><a href="https\:\/\/scm.sdf.org\/posts\/2023\/02.html">2023<\/a><\/h4>//' /sdf/arpa/ns/s/scm/index.html
2023-02-15 16:56:36 -05:00
# Convert the index HTML file to an index text file
2023-02-14 17:52:30 -05:00
2023-02-14 13:52:55 -05:00
html2text -o /sdf/arpa/ns/s/scm/index -ascii -style pretty /sdf/arpa/ns/s/scm/index.html
2023-02-11 10:33:40 -05:00
2023-02-15 19:56:01 -05:00
# Convert the posts HTML file to a text file
2023-02-14 17:52:30 -05:00
html2text -o /sdf/arpa/ns/s/scm/$month -ascii -style pretty /sdf/arpa/ns/s/scm/$month.html
2023-02-14 14:26:18 -05:00
2023-02-15 19:56:01 -05: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 16:49:03 -05:00
sed -i '1d;2d;3d' /sdf/arpa/ns/s/scm/$month
2023-02-15 19:56:01 -05: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 14:17:33 -05:00
# Change the head number as needed when the index.html file is changed
2023-02-19 22:15:55 -05:00
head -n 10 index.sdf > /sdf/arpa/ns/s/scm/header
2023-02-19 22:15:55 -05:00
cat /sdf/arpa/ns/s/scm/$month.sdf > body
2023-02-19 22:15:55 -05:00
2023-02-21 10:42:52 -05:00
cat /sdf/arpa/ns/s/scm/header > /sdf/arpa/ns/s/scm/.plan
2023-02-19 22:15:55 -05:00
2023-02-21 10:42:52 -05:00
cat /sdf/arpa/ns/s/scm/body >> /sdf/arpa/ns/s/scm/.plan
2023-02-19 22:15:55 -05:00
cat /sdf/arpa/ns/s/scm/footer.sdf >> /sdf/arpa/ns/s/scm/.plan
2023-02-15 19:56:01 -05:00
2023-02-22 14:17:33 -05:00
# Write the index text file to the root directory of Gopher
2023-02-14 17:52:30 -05:00
cp /sdf/arpa/ns/s/scm/index.sdf /ftp/pub/users/scm/index
2023-02-13 14:54:06 -05:00
2023-02-22 14:17:33 -05:00
# Write the posts text file to the posts directory of Gopher
2023-02-14 14:26:18 -05:00
cp /sdf/arpa/ns/s/scm/$month.sdf /ftp/pub/users/scm/posts/$year/$month
2023-02-14 18:35:14 -05:00
2023-02-15 19:56:01 -05:00
# Set the proper Gopher directory permissions
2023-02-14 18:35:14 -05:00
chmod -R 754 /ftp/pub/users/scm
2023-02-14 14:37:49 -05:00
2023-02-14 17:52:30 -05:00
#
2023-02-13 14:54:06 -05:00
# Meta Array
2023-02-14 17:52:30 -05:00
#
scp /sdf/arpa/ns/s/scm/.plan scm@ma.sdf.org:/meta/s/scm
2023-02-13 14:54:06 -05:00
scp /sdf/arpa/ns/s/scm/index.sdf scm@ma.sdf.org:/meta/gemini/scm/index.gmi
2023-02-14 17:52:30 -05:00
scp /sdf/arpa/ns/s/scm/$month.sdf scm@ma.sdf.org:/meta/gemini/scm/posts/$year/$month.gmi
2023-02-14 16:44:59 -05:00
2023-02-11 10:33:40 -05:00
exit 0