sdf/cluster-web-to-other.sh

132 lines
5.8 KiB
Bash
Executable File

#/bin/bash
month=$(date '+%m')
year=$(date '+%Y')
finger()
{
# Download the index.html and $month.html files
sftp scm@ma.sdf.org:/meta/s/scm/html/index.html /sdf/arpa/ns/s/scm/finger
sftp scm@ma.sdf.org:/meta/s/scm/html/posts/$year/$month.html /sdf/arpa/ns/s/scm/finger
# Convert the index.html file to an index-e01 text file
html2text -o /sdf/arpa/ns/s/scm/finger/index-e01 -ascii -style pretty /sdf/arpa/ns/s/scm/finger/index.html
# Convert the $month.html file to a $month-e01 text file
html2text -o /sdf/arpa/ns/s/scm/finger/$month-e01 -ascii -style pretty /sdf/arpa/ns/s/scm/finger/$month.html
# Remove the blank lines from the beginning of the index-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/s/scm/finger/index-e01
# Remove the blank lines from the beginning of the $month-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/s/scm/finger/$month-e01
# Remove the control characters from the index-e01 file and write it as index-e02
cat /sdf/arpa/ns/s/scm/finger/index-e01 | col -b -x > /sdf/arpa/ns/s/scm/finger/index-e02
# Remove the control characters from the $month-e01 file and write it as $month-e02
cat /sdf/arpa/ns/s/scm/finger/$month-e01 | col -b -x > /sdf/arpa/ns/s/scm/finger/$month-e02
# Write a header file from index-e02
head -n 5 /sdf/arpa/ns/s/scm/finger/index-e02 > /sdf/arpa/ns/s/scm/finger/header
# Write a footer file from index-e02
tail -n 15 /sdf/arpa/ns/s/scm/finger/index-e02 > /sdf/arpa/ns/s/scm/finger/footer
# Write a dotplan file from the header
cat /sdf/arpa/ns/s/scm/finger/header > /sdf/arpa/ns/s/scm/finger/dotplan
# Write the appended data from the $month-e02 file to dotplan
cat /sdf/arpa/ns/s/scm/finger/$month-e02 >> /sdf/arpa/ns/s/scm/finger/dotplan
# Write the appended data from the footer file to dotplan
cat /sdf/arpa/ns/s/scm/finger/footer >> /sdf/arpa/ns/s/scm/finger/dotplan
# Write the .plan file to the Cluster from dotplan
cp /sdf/arpa/ns/s/scm/finger/dotplan /sdf/arpa/ns/s/scm/.plan
# Write the .plan file to the Meta Array from dotplan
scp /sdf/arpa/ns/s/scm/finger/dotplan scm@ma.sdf.org:/meta/s/scm/.plan
}
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
}
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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# Write the index.gmi file to the Meta Array from index-e02
scp /sdf/arpa/ns/s/scm/gemini/index-e02 scm@ma.sdf.org:/meta/gemini/scm/index.gmi
# Write the $month.gmi file to the Meta Array from $month-e02
scp /sdf/arpa/ns/s/scm/gemini/$month-e02 scm@ma.sdf.org:/meta/gemini/scm/posts/$year/$month.gmi
}
finger
gopher
gemini
exit 0