#!/usr/pkg/bin/bash # convert-website.sh # This script is part of the website-to-other 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 . 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
HTML tag sed 's/^$/
/' $WebDir/index.html > $WebDir/index.html-01 # Convert the modified index.html file to an index.html text file html2text -width 65 -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 # Add five to the second number when a new post is added to the index.html # file sed '1,13d' $WebDir/index.html-03 > $WebDir/index.html-04 # Write the SCM header to a new index.html text file cat $HOME/gophersite/SCM-Header.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 # Remove the tabs from the index.html text file tr -d '\t' < $WebDir/index.html-05 > $WebDir/index.html-06 # Write a Gopher index text file from the index.html text file cat $WebDir/index.html-06 > $GopherDir/posts # Write gophermap file cp $HOME/gopher/gophermap $GopherDir/gophermap # Write a Gemini index.gmi from the Gopher text file cat $GopherDir/posts > $GopherDir/posts.gmi # Write a cluster .plan file from the Gopher index text file cat $GopherDir/posts > $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 World Wide Web (WWW) permissions chmod -R 751 /www/nz/s/scm # Set the correct Gopher and Gemini permissions chmod -R 754 $GopherDir # Copy the Gopher site files to the Gopher respository cp $GopherDir/posts $HOME/gophersite # Unless the debug option is invoked, clean up the unneeded files sh $HOME/website-to-other/cleanup.sh exit 0