sdf/cluster-web-to-other.sh

166 lines
6.8 KiB
Bash
Raw Normal View History

2023-02-27 21:37:17 +00:00
#/bin/bash
2023-02-11 15:33:40 +00:00
month=$(date '+%m')
year=$(date '+%Y')
2023-02-14 22:52:30 +00:00
#
2023-02-27 21:37:17 +00:00
# Finger
2023-02-14 22:52:30 +00:00
#
2023-02-28 12:17:03 +00:00
gopher()
{
# Download the index.html and month.html files
sftp scm@ma.sdf.org:/meta/s/scm/html/index.html /sdf/arpa/ns/s/scm/gopher-prep
sftp scm@ma.sdf.org:/meta/s/scm/html/posts/$year/$month.html /sdf/arpa/ns/s/scm/gopher-prep
# Convert the index.html file to an index-e01 text file
html2text -o /sdf/arpa/ns/s/scm/gopher-prep/index-e01 -ascii -style pretty /sdf/arpa/ns/s/scm/gopher-prep/index.html
# Convert the month.html file to a month-e01 text file
html2text -o /sdf/arpa/ns/s/scm/gopher-prep/$month-e01 -ascii -style pretty /sdf/arpa/ns/s/scm/gopher-prep/$month.html
# Remove the blank lines from the beginning of the index-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/s/scm/gopher-prep/index-e01
# Remove the blank lines from the beginning of the month-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/s/scm/gopher-prep/$month-e01
# Remove the control characters from the index-e01 file and write it as index-e02
cat /sdf/arpa/ns/s/scm/gopher-prep/index-e01 | col -b -x > /sdf/arpa/ns/s/scm/gopher-prep/index-e02
# Remove the control characters from the month-e01 file and write it as month-e02
cat /sdf/arpa/ns/s/scm/gopher-prep/$month-e01 | col -b -x > /sdf/arpa/ns/s/scm/gopher-prep/$month-e02
sed -i "7d;8d;9d;10d;11d;12d" /sdf/arpa/ns/s/scm/gopher-prep/index-e02
# From the index-e02 file write the index
cp /sdf/arpa/ns/s/scm/gopher-prep/index-e02 /ftp/pub/users/scm/index
# From the month-e02 file write the month
cp /sdf/arpa/ns/s/scm/gopher-prep/$month-e02 /ftp/pub/users/scm/posts/$year/$month
chmod -R 754 /ftp/pub/users/scm
}
2023-02-11 15:33:40 +00:00
2023-02-27 21:37:17 +00:00
gemini()
{
# Download the index.html and month.html files
sftp scm@ma.sdf.org:/meta/s/scm/html/index.html /sdf/arpa/ns/s/scm/gemini
sftp scm@ma.sdf.org:/meta/s/scm/html/posts/$year/$month.html /sdf/arpa/ns/s/scm/gemini
2023-02-14 22:52:30 +00:00
2023-02-27 21:37:17 +00:00
# Convert the index.html file to an index-e01 text file
html2text -o /sdf/arpa/ns/s/scm/gemini/index-e01 -ascii -style pretty /sdf/arpa/ns/s/scm/gemini/index.html
2023-02-14 19:26:18 +00:00
2023-02-27 21:37:17 +00:00
# Convert the month.html file to a month-e01 text file
html2text -o /sdf/arpa/ns/s/scm/gemini/$month-e01 -ascii -style pretty /sdf/arpa/ns/s/scm/gemini/$month.html
2023-02-26 19:44:41 +00:00
2023-02-27 21:37:17 +00:00
# Remove the blank lines from the beginning of the index-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/s/scm/gemini/index-e01
2023-02-26 19:44:41 +00:00
2023-02-27 21:37:17 +00:00
# Remove the blank lines from the beginning of the month-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/s/scm/gemini/$month-e01
2023-02-26 19:44:41 +00:00
2023-02-27 21:37:17 +00:00
# Remove the control characters from the index-e01 file and write it as index-e02
cat /sdf/arpa/ns/s/scm/gemini/index-e01 | col -b -x > /sdf/arpa/ns/s/scm/gemini/index-e02
2023-02-26 19:44:41 +00:00
2023-02-27 21:37:17 +00:00
# Remove the control characters from the month-e01 file and write it as month-e02
cat /sdf/arpa/ns/s/scm/gemini/$month-e01 | col -b -x > /sdf/arpa/ns/s/scm/gemini/$month-e02
2023-02-28 12:17:03 +00:00
# Remove the extra blank lines above and below the posts year
sed -i "9d;12d" /sdf/arpa/ns/s/scm/gemini/index-e02
# Substitute the posts year with a Gemini link to the posts
sed -i "s/$year/=> gemini\:\/\/gem.sdf.org\/scm\/posts\/$year\/$month.gmi $year/" /sdf/arpa/ns/s/scm/gemini/index-e02
# Substitute the Gopher text with a Gopher Gemini link
sed -i "s/Gopher e.g. gopher gopher\:\/\/sdf.org\:70\/1\/users\/scm\/./=> gopher\:\/\/sdf.org\:70\/1\/users\/scm\/ Gopher/" /sdf/arpa/ns/s/scm/gemini/index-e02
# From the index-e02 file write the index.gmi
scp /sdf/arpa/ns/s/scm/gemini/index-e02 scm@ma.sdf.org:/meta/gemini/scm/index.gmi
# From the month-e02 file write the month.gmi
scp /sdf/arpa/ns/s/scm/gemini/$month-e02 scm@ma.sdf.org:/meta/gemini/scm/posts/$year/$month.gmi
2023-02-27 21:37:17 +00:00
}
2023-02-26 19:44:41 +00:00
2023-02-28 12:17:03 +00:00
gopher
2023-02-27 21:37:17 +00:00
gemini
2023-02-26 19:44:41 +00:00
2023-02-27 21:37:17 +00:00
# Write the head.gmi text file from the index.gmi text file
# The number determines which lines are written
#head -n 5 /sdf/arpa/ns/s/scm/gemini/index-gmi > /sdf/arpa/ns/s/scm/gemini/header.gmi
2023-02-16 00:56:01 +00:00
2023-02-27 21:37:17 +00:00
# Write the footer.gmi text file from the index.gmi text file
#tail -n 15 /sdf/arpa/ns/s/scm/gemini/index-gmi > /sdf/arpa/ns/s/scm/gemini/footer.gmi
2023-02-16 00:56:01 +00:00
2023-02-27 21:37:17 +00:00
# Write the index.gmi text file from the header.gmi and footer.gmi text files
#cat /sdf/arpa/ns/s/scm/gemini/header.gmi > /sdf/arpa/ns/s/scm/gemini/index.gmi
#cat /sdf/arpa/ns/s/scm/gemini/footer.gmi >> /sdf/arpa/ns/s/scm/gemini/index.gmi
2023-02-16 00:56:01 +00:00
2023-02-27 21:37:17 +00:00
# # Remove the posts header line from the index.html file
# sed -i 's/<h3>Posts<\/h3>//' /sdf/arpa/ns/s/scm/index.html
2023-02-16 00:56:01 +00:00
2023-02-27 21:37:17 +00:00
# Remove the posts year line 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-27 21:37:17 +00:00
# # Remove the blank lines from the beginning of the index file
# sed -i '1d;2d;3d' /sdf/arpa/ns/s/scm/index
2023-02-27 21:37:17 +00:00
# # Remove the blank lines from the beginning of the posts file
# sed -i '1d;2d;3d' /sdf/arpa/ns/s/scm/$month
2023-02-27 21:37:17 +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
2023-02-27 21:37:17 +00:00
# # Remove the control characters from the month (posts) text file and write
# # to the month.sdf text file
# cat /sdf/arpa/ns/s/scm/$month | col -b -x > /sdf/arpa/ns/s/scm/$month.sdf
2023-02-27 21:37:17 +00:00
# # 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
2023-02-27 21:37:17 +00:00
# # Change the head number as needed when the top of the index.html file is
# # changed
# head -n 5 index.sdf > /sdf/arpa/ns/s/scm/header.sdf
2023-02-20 03:15:55 +00:00
2023-02-27 21:37:17 +00:00
# # Create the body for the clusters .plan text file from the month.sdf text
# # file
# cat /sdf/arpa/ns/s/scm/$month.sdf > body.sdf
2023-02-16 00:56:01 +00:00
2023-02-27 21:37:17 +00:00
# # Write the the dot plan Cluster text file
# cat /sdf/arpa/ns/s/scm/header.sdf > /sdf/arpa/ns/s/scm/.plan
# cat /sdf/arpa/ns/s/scm/body.sdf >> /sdf/arpa/ns/s/scm/.plan
# cat /sdf/arpa/ns/s/scm/footer.sdf >> /sdf/arpa/ns/s/scm/.plan
2023-02-14 22:52:30 +00:00
2023-02-27 21:37:17 +00:00
# # Write the index text file to the root directory of Gopher from the
# # index.sdf text file
# cp /sdf/arpa/ns/s/scm/index.sdf /ftp/pub/users/scm/index
2023-02-13 19:54:06 +00:00
2023-02-27 21:37:17 +00:00
# # Write the posts text file to the posts directory of Gopher from the
# # month.sdf text file
# cp /sdf/arpa/ns/s/scm/$month.sdf /ftp/pub/users/scm/posts/$year/$month
2023-02-14 19:26:18 +00:00
2023-02-27 21:37:17 +00:00
# # Set the proper Gopher permissions
# chmod -R 754 /ftp/pub/users/scm
2023-02-14 23:35:14 +00:00
2023-02-27 21:37:17 +00:00
# #
# # Meta Array
# #
2023-02-16 00:56:01 +00:00
2023-02-27 21:37:17 +00:00
# # Write the MA dot plan text file from the clusters' dot plan text file
# scp /sdf/arpa/ns/s/scm/.plan scm@ma.sdf.org:/meta/s/scm
2023-02-14 19:37:49 +00:00
2023-02-27 21:37:17 +00:00
# #sed -i "s/Gopher e.g. gopher gopher\:\/\/sdf.org:70\/1\/users\/scm\/gopher\//=> gopher\:\/\/sdf.org:70\/1\/users\/scm\/ Gopher" /sdf/arpa/ns/s/scm/footer.sdf
2023-02-14 22:52:30 +00:00
2023-02-27 21:37:17 +00:00
# #scp /sdf/arpa/ns/s/scm/index.sdf scm@ma.sdf.org:/meta/gemini/scm/index.gmi
2023-02-13 19:54:06 +00:00
2023-02-27 21:37:17 +00:00
# # Write the MA posts text file from the clusters' posts text file
2023-02-25 00:41:03 +00:00
2023-02-27 21:37:17 +00:00
# cat /sdf/arpa/ns/s/scm/header > /sdf/arpa/ns/s/scm/index.gmi
# cat /sdf/arpa/ns/s/scm/body >> /sdf/arpa/ns/s/scm/index.gmi
# cat /sdf/arpa/ns/s/scm/footer.sdf >> /sdf/arpa/ns/s/scm/.plan
2023-02-14 22:52:30 +00:00
2023-02-27 21:37:17 +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