Remove extra blank line

This commit is contained in:
Scott C. MacCallum 2023-03-16 00:39:20 +00:00
parent 2fb87ab7f5
commit fd44b29fa1

View File

@ -19,11 +19,12 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
letter="s"
letter_range="ns"
year=$(date '+%Y')
month=$(date '+%m') month=$(date '+%m')
one=1 one=1
last_month=$(($month - $one)) last_month=$(($month - $one))
year=$(date '+%Y')
letter="s"
finger() finger()
{ {
@ -32,54 +33,57 @@ finger()
echo echo
# Download the index.html and $month.html files # Download the index.html and $month.html files
sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/index.html /sdf/arpa/ns/$letter/$USER/finger sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/index.html /sdf/arpa/$letter_range/$letter/$USER/finger
sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/posts/$year/$month.html /sdf/arpa/ns/$letter/$USER/finger sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/posts/$year/$month.html /sdf/arpa/$letter_range/$letter/$USER/finger
# Convert the index.html file to an index-e01 text file # Convert the index.html file to an index-e01 text file
html2text -o /sdf/arpa/ns/$letter/$USER/finger/index-e01 -ascii -style pretty /sdf/arpa/ns/$letter/$USER/finger/index.html html2text -o /sdf/arpa/$letter_range/$letter/$USER/finger/index-e01 -ascii -style pretty /sdf/arpa/$letter_range/$letter/$USER/finger/index.html
# Convert the $month.html file to a $month-e01 text file # Convert the $month.html file to a $month-e01 text file
html2text -o /sdf/arpa/ns/$letter/$USER/finger/$month-e01 -ascii -style pretty /sdf/arpa/ns/$letter/$USER/finger/$month.html html2text -o /sdf/arpa/$letter_range/$letter/$USER/finger/$month-e01 -ascii -style pretty /sdf/arpa/$letter_range/$letter/$USER/finger/$month.html
# Remove the blank lines from the beginning of the index-e01 file # Remove the blank lines from the beginning of the index-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/$letter/$USER/finger/index-e01 sed -i "1d;2d;3d" /sdf/arpa/$letter_range/$letter/$USER/finger/index-e01
# Remove the blank lines from the beginning of the $month-e01 file # Remove the blank lines from the beginning of the $month-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/$letter/$USER/finger/$month-e01 sed -i "1d;2d;3d" /sdf/arpa/$letter_range/$letter/$USER/finger/$month-e01
# Remove the control characters from the index-e01 file and write it as index-e02 # Remove the control characters from the index-e01 file and write it as index-e02
cat /sdf/arpa/ns/$letter/$USER/finger/index-e01 | col -b -x > /sdf/arpa/ns/$letter/$USER/finger/index-e02 cat /sdf/arpa/$letter_range/$letter/$USER/finger/index-e01 | col -b -x > /sdf/arpa/$letter_range/$letter/$USER/finger/index-e02
# Remove the control characters from the $month-e01 file and write it as $month-e02 # Remove the control characters from the $month-e01 file and write it as $month-e02
cat /sdf/arpa/ns/$letter/$USER/finger/$month-e01 | col -b -x > /sdf/arpa/ns/$letter/$USER/finger/$month-e02 cat /sdf/arpa/$letter_range/$letter/$USER/finger/$month-e01 | col -b -x > /sdf/arpa/$letter_range/$letter/$USER/finger/$month-e02
# Remove the HTML link reference to previous month posts # Remove the HTML link reference to previous month posts
if [ $last_month -lt 10 ]; then if [ $last_month -lt 10 ]; then
sed -i "s/0$last_month//" /sdf/arpa/ns/$letter/$USER/finger/$month-e02 sed -i "s/0$last_month//" /sdf/arpa/$letter_range/$letter/$USER/finger/$month-e02
else else
sed -i "s/$last_month//" /sdf/arpa/ns/$letter/$USER/finger/$month-e02 sed -i "s/$last_month//" /sdf/arpa/$letter_range/$letter/$USER/finger/$month-e02
fi fi
# Remove the extra blank line from the end of the post
sed -i "9d" /sdf/arpa/$letter_range/$letter/$USER/finger/$month-e02
# Write a header file from index-e02 # Write a header file from index-e02
head -n 5 /sdf/arpa/ns/$letter/$USER/finger/index-e02 > /sdf/arpa/ns/$letter/$USER/finger/header head -n 5 /sdf/arpa/$letter_range/$letter/$USER/finger/index-e02 > /sdf/arpa/$letter_range/$letter/$USER/finger/header
# Write a footer file from index-e02 # Write a footer file from index-e02
tail -n 15 /sdf/arpa/ns/$letter/$USER/finger/index-e02 > /sdf/arpa/ns/$letter/$USER/finger/footer tail -n 15 /sdf/arpa/$letter_range/$letter/$USER/finger/index-e02 > /sdf/arpa/$letter_range/$letter/$USER/finger/footer
# Write a dotplan file from the header # Write a dotplan file from the header
cat /sdf/arpa/ns/$letter/$USER/finger/header > /sdf/arpa/ns/$letter/$USER/finger/dotplan cat /sdf/arpa/$letter_range/$letter/$USER/finger/header > /sdf/arpa/$letter_range/$letter/$USER/finger/dotplan
# Write the appended data from the $month-e02 file to dotplan # Write the appended data from the $month-e02 file to dotplan
cat /sdf/arpa/ns/$letter/$USER/finger/$month-e02 >> /sdf/arpa/ns/$letter/$USER/finger/dotplan cat /sdf/arpa/$letter_range/$letter/$USER/finger/$month-e02 >> /sdf/arpa/$letter_range/$letter/$USER/finger/dotplan
# Write the appended data from the footer file to dotplan # Write the appended data from the footer file to dotplan
cat /sdf/arpa/ns/$letter/$USER/finger/footer >> /sdf/arpa/ns/$letter/$USER/finger/dotplan cat /sdf/arpa/$letter_range/$letter/$USER/finger/footer >> /sdf/arpa/$letter_range/$letter/$USER/finger/dotplan
# Write the .plan file to the Cluster from dotplan # Write the .plan file to the Cluster from dotplan
cp /sdf/arpa/ns/$letter/$USER/finger/dotplan /sdf/arpa/ns/$letter/$USER/.plan cp /sdf/arpa/$letter_range/$letter/$USER/finger/dotplan /sdf/arpa/$letter_range/$letter/$USER/.plan
# Write the .plan file to the Meta Array from dotplan # Write the .plan file to the Meta Array from dotplan
scp /sdf/arpa/ns/$letter/$USER/finger/dotplan $USER@ma.sdf.org:/meta/$letter/$USER/.plan scp /sdf/arpa/$letter_range/$letter/$USER/finger/dotplan $USER@ma.sdf.org:/meta/$letter/$USER/.plan
} }
gopher() gopher()
@ -92,34 +96,34 @@ gopher()
# exist, create it # exist, create it
# Download the index.html and $month.html files # Download the index.html and $month.html files
sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/index.html /sdf/arpa/ns/$letter/$USER/gopher-prep sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/index.html /sdf/arpa/$letter_range/$letter/$USER/gopher-prep
sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/posts/$year/$month.html /sdf/arpa/ns/$letter/$USER/gopher-prep sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/posts/$year/$month.html /sdf/arpa/$letter_range/$letter/$USER/gopher-prep
# Convert the index.html file to an index-e01 text file # Convert the index.html file to an index-e01 text file
html2text -o /sdf/arpa/ns/$letter/$USER/gopher-prep/index-e01 -ascii -style pretty /sdf/arpa/ns/$letter/$USER/gopher-prep/index.html html2text -o /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/index-e01 -ascii -style pretty /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/index.html
# Convert the $month.html file to a $month-e01 text file # Convert the $month.html file to a $month-e01 text file
html2text -o /sdf/arpa/ns/$letter/$USER/gopher-prep/$month-e01 -ascii -style pretty /sdf/arpa/ns/$letter/$USER/gopher-prep/$month.html html2text -o /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/$month-e01 -ascii -style pretty /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/$month.html
# Remove the blank lines from the beginning of the index-e01 file # Remove the blank lines from the beginning of the index-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/$letter/$USER/gopher-prep/index-e01 sed -i "1d;2d;3d" /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/index-e01
# Remove the blank lines from the beginning of the $month-e01 file # Remove the blank lines from the beginning of the $month-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/$letter/$USER/gopher-prep/$month-e01 sed -i "1d;2d;3d" /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/$month-e01
# Remove the control characters from the index-e01 file and write it as index-e02 # Remove the control characters from the index-e01 file and write it as index-e02
cat /sdf/arpa/ns/$letter/$USER/gopher-prep/index-e01 | col -b -x > /sdf/arpa/ns/$letter/$USER/gopher-prep/index-e02 cat /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/index-e01 | col -b -x > /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/index-e02
# Remove the control characters from the $month-e01 file and write it as $month-e02 # Remove the control characters from the $month-e01 file and write it as $month-e02
cat /sdf/arpa/ns/$letter/$USER/gopher-prep/$month-e01 | col -b -x > /sdf/arpa/ns/$letter/$USER/gopher-prep/$month-e02 cat /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/$month-e01 | col -b -x > /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/$month-e02
sed -i "7d;8d;9d;10d;11d;12d" /sdf/arpa/ns/$letter/$USER/gopher-prep/index-e02 sed -i "7d;8d;9d;10d;11d;12d" /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/index-e02
# From the index-e02 file write the index # From the index-e02 file write the index
cp /sdf/arpa/ns/$letter/$USER/gopher-prep/index-e02 /ftp/pub/users/$USER/index cp /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/index-e02 /ftp/pub/users/$USER/index
# From the $month-e02 file write the $month # From the $month-e02 file write the $month
cp /sdf/arpa/ns/$letter/$USER/gopher-prep/$month-e02 /ftp/pub/users/$USER/posts/$year/$month cp /sdf/arpa/$letter_range/$letter/$USER/gopher-prep/$month-e02 /ftp/pub/users/$USER/posts/$year/$month
chmod -R 754 /ftp/pub/users/$USER chmod -R 754 /ftp/pub/users/$USER
} }
@ -134,41 +138,41 @@ gemini()
# exist, create it # exist, create it
# Download the index.html and $month.html files # Download the index.html and $month.html files
sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/index.html /sdf/arpa/ns/$letter/$USER/gemini sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/index.html /sdf/arpa/$letter_range/$letter/$USER/gemini
sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/posts/$year/$month.html /sdf/arpa/ns/$letter/$USER/gemini sftp $USER@ma.sdf.org:/meta/$letter/$USER/html/posts/$year/$month.html /sdf/arpa/$letter_range/$letter/$USER/gemini
# Convert the index.html file to an index-e01 text file # Convert the index.html file to an index-e01 text file
html2text -o /sdf/arpa/ns/$letter/$USER/gemini/index-e01 -ascii -style pretty /sdf/arpa/ns/$letter/$USER/gemini/index.html html2text -o /sdf/arpa/$letter_range/$letter/$USER/gemini/index-e01 -ascii -style pretty /sdf/arpa/$letter_range/$letter/$USER/gemini/index.html
# Convert the $month.html file to a $month-e01 text file # Convert the $month.html file to a $month-e01 text file
html2text -o /sdf/arpa/ns/$letter/$USER/gemini/$month-e01 -ascii -style pretty /sdf/arpa/ns/$letter/$USER/gemini/$month.html html2text -o /sdf/arpa/$letter_range/$letter/$USER/gemini/$month-e01 -ascii -style pretty /sdf/arpa/$letter_range/$letter/$USER/gemini/$month.html
# Remove the blank lines from the beginning of the index-e01 file # Remove the blank lines from the beginning of the index-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/$letter/$USER/gemini/index-e01 sed -i "1d;2d;3d" /sdf/arpa/$letter_range/$letter/$USER/gemini/index-e01
# Remove the blank lines from the beginning of the $month-e01 file # Remove the blank lines from the beginning of the $month-e01 file
sed -i "1d;2d;3d" /sdf/arpa/ns/$letter/$USER/gemini/$month-e01 sed -i "1d;2d;3d" /sdf/arpa/$letter_range/$letter/$USER/gemini/$month-e01
# Remove the control characters from the index-e01 file and write it as index-e02 # Remove the control characters from the index-e01 file and write it as index-e02
cat /sdf/arpa/ns/$letter/$USER/gemini/index-e01 | col -b -x > /sdf/arpa/ns/$letter/$USER/gemini/index-e02 cat /sdf/arpa/$letter_range/$letter/$USER/gemini/index-e01 | col -b -x > /sdf/arpa/$letter_range/$letter/$USER/gemini/index-e02
# Remove the control characters from the $month-e01 file and write it as $month-e02 # Remove the control characters from the $month-e01 file and write it as $month-e02
cat /sdf/arpa/ns/$letter/$USER/gemini/$month-e01 | col -b -x > /sdf/arpa/ns/$letter/$USER/gemini/$month-e02 cat /sdf/arpa/$letter_range/$letter/$USER/gemini/$month-e01 | col -b -x > /sdf/arpa/$letter_range/$letter/$USER/gemini/$month-e02
# Remove the extra blank lines above and below the posts year # Remove the extra blank lines above and below the posts year
sed -i "9d;12d" /sdf/arpa/ns/$letter/$USER/gemini/index-e02 sed -i "9d;12d" /sdf/arpa/$letter_range/$letter/$USER/gemini/index-e02
# Substitute the posts year with a Gemini link to the posts # Substitute the posts year with a Gemini link to the posts
sed -i "s/$year/=> gemini\:\/\/gem.sdf.org\/$USER\/posts\/$year\/$month.gmi $year/" /sdf/arpa/ns/$letter/$USER/gemini/index-e02 sed -i "s/$year/=> gemini\:\/\/gem.sdf.org\/$USER\/posts\/$year\/$month.gmi $year/" /sdf/arpa/$letter_range/$letter/$USER/gemini/index-e02
# Substitute the Gopher text with a Gopher Gemini link # Substitute the Gopher text with a Gopher Gemini link
sed -i "s/Gopher e.g. gopher gopher\:\/\/sdf.org\:70\/1\/users\/$USER\/./=> gopher\:\/\/sdf.org\:70\/1\/users\/$USER\/ Gopher/" /sdf/arpa/ns/$letter/$USER/gemini/index-e02 sed -i "s/Gopher e.g. gopher gopher\:\/\/sdf.org\:70\/1\/users\/$USER\/./=> gopher\:\/\/sdf.org\:70\/1\/users\/$USER\/ Gopher/" /sdf/arpa/$letter_range/$letter/$USER/gemini/index-e02
# Write the index.gmi file to the Meta Array from index-e02 # Write the index.gmi file to the Meta Array from index-e02
scp /sdf/arpa/ns/$letter/$USER/gemini/index-e02 $USER@ma.sdf.org:/meta/gemini/$USER/index.gmi scp /sdf/arpa/$letter_range/$letter/$USER/gemini/index-e02 $USER@ma.sdf.org:/meta/gemini/$USER/index.gmi
# Write the $month.gmi file to the Meta Array from $month-e02 # Write the $month.gmi file to the Meta Array from $month-e02
scp /sdf/arpa/ns/$letter/$USER/gemini/$month-e02 $USER@ma.sdf.org:/meta/gemini/$USER/posts/$year/$month.gmi scp /sdf/arpa/$letter_range/$letter/$USER/gemini/$month-e02 $USER@ma.sdf.org:/meta/gemini/$USER/posts/$year/$month.gmi
} }
finger finger