website-to-other/convert-website.sh
2025-02-13 20:38:08 +00:00

73 lines
2.6 KiB
Bash
Executable File

#!/usr/pkg/bin/bash
# convert-website.sh
# This script is part of the website-to-other.sh project, which converts my
# website to other formats
# Copyright (c) 2024, 2025, Scott C. MacCallum (scm@sdf.org).
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# 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/>.
# Change this variable to the group that should be informed of a need to
# charge the battery. On GNU/Linux distributions users are often part of
# a group that is the same as their login name, which works well if you only
# want your user to be informed on the console.
GopherDir="/ftp/pub/users/scm"
WebDir="/sdf/arpa/ns/s/scm/html/text"
# Make a backup of the index.html file
cp $WebDir/index.html $WebDir/index.html.old
# Where there are blank lines in index.html file insert the <br> HTML tag
sed 's/^$/<br>/' $WebDir/index.html > $WebDir/index.html-01
# Convert the modified index.html file to an index.html text file
html2text -o $WebDir/index.html-02 $WebDir/index.html-01
# Remove the control characters from the index.html text file
cat $WebDir/index.html-02 | col -b -x > $WebDir/index.html-03
# Remove the blank lines from the top of the index.html text file
sed '1,12d' $WebDir/index.html-03 > $WebDir/index.html-04
# Write the show title to a new index.html text file
cat $HOME/SCM-Show.txt > $WebDir/index.html-05
# Append the previous index.html text file to the new index.html text file
cat $WebDir/index.html-04 >> $WebDir/index.html-05
# Write the Gopher index file from the index.html text file
cat $WebDir/index.html-05 > $GopherDir/index
# Write the Gemini file index.gmi from the index.html text file
cat $WebDir/index.html-05 > $GopherDir/index.gmi
# Write the cluster .plan file from the Gopher index file
cat $GopherDir/index > $HOME/.plan
# Write the MetaArray .plan file from the cluster .plan file
scp $HOME/.plan scm@ma.sdf.org:/meta/s/scm/.plan
# Set the correct WWW permissions
mkhomepg -p
# Set the correct Gopher and Gemini permissions
chmod -R 754 $GopherDir
# Unless the debug option is invoked clean up the unneeded files
sh $HOME/website-to-other/cleanup.sh
exit 0