From 9003f72a6c54ffe90fc99692e5600c621db8c61c Mon Sep 17 00:00:00 2001 From: Cloud User Date: Fri, 17 May 2019 08:00:14 -0500 Subject: [PATCH] Initialization of repository --- README.md | 0 lentry.sh | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 README.md create mode 100755 lentry.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/lentry.sh b/lentry.sh new file mode 100755 index 0000000..e5a4235 --- /dev/null +++ b/lentry.sh @@ -0,0 +1,137 @@ +#!/bin/bash + +echo -n "Enter Title: " +read title +echo -n "Enter Author Name: " +read author +echo -n "Enter Catalog Number: " +read cnumber +echo -n "Enter Description: " +read descrip +echo -n "Enter Date(format: 25 06 2005): " +read date + + +mkdir /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber +mv $1 /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber +touch /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph +touch /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html + +# html header +echo "" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Library of Eris" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Main Catalog" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " ⋄" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Books" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " ⋄" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Documents" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " ⋄" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Periodicals" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " ⋄" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Posters" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " ⋄" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Miscellaneous" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html + +# Generate Html Content +echo " Title: $title

" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Author: $author

" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Catalog Number: $cnumber

" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Description: $descrip

" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " Date Published: $date

" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html + +# Generate Gopher Content +echo "Title: $title" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph +echo "" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph +echo "Author: $author" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph +echo "" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph +echo "Catalog Number: $cnumber" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph +echo "" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph + +# This section ensures that the description is kept to 67 lines and adds an extra t due to escape character +whole_title="Description: $descrip" +touch fold.tmp +echo "$whole_title" >> fold.tmp +fold_title="$(fold -w 67 -s fold.tmp)" +rm fold.tmp +echo "$fold_title" >> sed.tmp +final_title="$(sed 's/^t/tt/g' sed.tmp)" +rm sed.tmp + +echo "$final_title" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph +echo "" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph +echo "Date Published: $date" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph +echo "" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph + +# Determine link type +lastchars=${1: -3} +if [[ "$lastchars" == "txt" ]]; then + echo "[0|TXT|/library/catalog/$cnumber/$1|server|port]" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph + echo " Formats: TXT" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +elif [[ "$lastchars" == "pdf" ]]; then + echo "[9|PDF|/library/catalog/$cnumber/$1|server|port]" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph + echo " Formats: PDF" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +elif [[ "$lastchars" == "jpg" ]]; then + echo "[I|JPG|/library/catalog/$cnumber/$1|server|port]" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph + echo " Formats: JPG" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +elif [[ "$lastchars" == "gif" ]]; then + echo "[g|GIF|/library/catalog/$cnumber/$1|server|port]" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph + echo " Formats: GIF" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +else + echo "[0|TXT|/library/catalog/$cnumber/$1|server|port]" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.gph + echo " Formats: TXT" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +fi + +# Html footer +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "
" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo " " >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html +echo "" >> /var/lib/nethserver/vhost/libraryoferis/catalog/$cnumber/index.html + +# Update catalog for gopher and html + +echo "[1|$cnumber $title|/library/catalog/$cnumber|server|port]" >> /var/lib/nethserver/vhost/libraryoferis/catalog/index.gph +count=$(cat /var/lib/nethserver/vhost/libraryoferis/.counter) +sed -i "${count}i ${cnumber} - ${title}" /var/lib/nethserver/vhost/libraryoferis/catalog.html +sed -i "${count}i
" /var/lib/nethserver/vhost/libraryoferis/catalog.html +ad_num=$((count + 2)) +echo "$ad_num" > /var/lib/nethserver/vhost/libraryoferis/.counter