Browse Source

migrate from plaintext on sexoskeleton.com

master
trav 3 months ago
commit
f5f5ba4538
  1. 31
      README.md
  2. 110
      sexoskeleton.sh

31
README.md

@ -0,0 +1,31 @@
this page details the script that is used to update sexoskeleton.com. It's basically a cron-ed bash script that makes a "blog" from a folder of images and text. It is not perfect by any means, it is a blog by the simplest means. If you have questions feel free to email hello@sexoskeleton.com
first of all, the full script can be downloaded here
to set it up: you've got to have a webadd directory and a webdir directory. Webdir is the site, webadd is images and text to be added. We have these setup in the user's root directory. You may need to tweak.
we have webadd shared over syncthing so that all we have to do is drag a file from our local machine, it syncs and within an hour will be posted.
ok so, I'll walk through some important parts of the script:
MAXINDEX=70
MAXLOG=1000
these variables set how long, in # of lines, you want the index.html and log file to get before they are archived or deleted. By default everytime sexoskeleton.sh is run it stores most of its output into ~/cronlog.log which isn't precisely a cronlog. But that's what it's called
when index.html gets bigger than MAXINDEX, index.html is renamed $currentdate.html and linked to on archive.html. Then ~/template.conf is copied to create a new index.html. Template.conf is basically the header and footer minus all the content in the middle
so then the script iterates through any files in the webadd directory. Anything ending in .gif, .jpg, .png or .txt will be picked up. .txt files can contain html but you need to escape your own slashes. Which is to say if you put in / in a .txt add a \ before it.
also of note, image files are moved from webadd to webdir under a unique filename to avoid conflicts and .txt files are DELETED after being appended to the index.
the script looks for
inside index.html and adds the new content just below that line. I couldn't figure out adding below the line so it actually replaces
and then adds it back in....
if nothing has changed the site is not re-uploaded
if something has changed, the script runs surge to upload the site.
and that's it. This script was written by [trav](https://teafry.me)

110
sexoskeleton.sh

@ -0,0 +1,110 @@
#!/bin/bash
#sexoskeleton.com update script by trav fryer
echo "SEXOSKELETONZ INCOMMING"
#set some vars
MAXINDEX=70
MAXLOG=1000
didsomethingchange=false
#if log is too big just wipe it, who cares
numlines="$(wc -l ~/cronlog.log)"
numlinez="$(echo $numlines | head -c 3)"
echo "cronlog is $numlinez/$MAXLOG"
if [ "$numlinez" -gt "$MAXLOG" ]
then
echo "fuck it, wipe the log"
rm ~/cronlog.log
#make new log
touch cronlog.log
echo "cronlog archived" | tee -a ~/cronlog.log
fi
#ok, now logging
echo "" >> ~/cronlog.log
date >> ~/cronlog.log
#if the index is of a certain size archive it
#check if index > x lines
numlines="$(wc -l webdir/index.html)"
numlinez="$(echo $numlines | head -c 3)"
echo "index lines: $numlinez/$MAXINDEX" | tee -a ~/cronlog.log
if [ "$numlinez" -gt "$MAXINDEX" ]
then
echo "ARCHIVING INDEX!!!" | tee -a ~/cronlog.log
#generate the current date for archive
todayis="$(date -u +%Y-%m-%d)"
#generate new page name with date
movedpage="~/webdir/$(date -u +%Y-%m-%s).html"
#change name of old index to new generated name
mv webdir/index.html "$movedpage"
#add link to new archived page into archive.html
file="webdir/archive.html"
insert="<!--posts-->\n<a href=$movedpage>$todayis<\/a><br><br>\n"
sed -i -- "s/<!--posts-->/$insert/" "$file"
#make new index.html
cp template.conf webdir/index.html
didsomethingchange=true
fi
#BLOG POST STUFF
#get all files in webadd directory
filez="$(ls -1 webadd)"
echo "here are the files we're gonna push: $filez" | tee -a ~/cronlog.log
#make array of files
arr=($filez)
#get first file in arry
afile=${arr[0]}
#POST ALL THE FILES!!
while [ "$filez" != "" ]
do
#get extension of top file
extn="${afile: -4}"
# test for image or txt
if [ "$extn" == '.png' ] || [ "$extn" = '.jpg' ] || [ "$extn" == '.gif' ]
then
echo "posting $afile" | tee -a ~/cronlog.log
#come up with unique string to rename the file (to avoid colisions)
newname="$(date +%s)$extn"
#move the image into the web directory and insert into index.html
mv webadd/$afile webdir/$newname
insert="<!--posts-->\n$(date)<br><p><img src=$newname><\/p><br><br><br>\n"
file="webdir/index.html"
sed -i -- "s/<!--posts-->/$insert/" "$file"
didsomethingchange=true
#is it text?
elif [ "$extn" == '.txt' ]
then
echo "found a text, $afile" | tee -a ~/cronlog.log
str="$(cat webadd/"$afile")"
rm webadd/$afile
file="webdir/index.html"
insert="<!--posts-->\n$(date)<br><p>$str<\/p><br><br><br>\n"
sed -i -- "s/<!--posts-->/$insert/" "$file"
didsomethingchange=true
fi
# i t e r a t e
#get all files in webadd
filez="$(ls -1 webadd)"
#make array of files
arr=($filez)
#get first file in array
afile=${arr[0]}
done
# if something changed, post to da web
if [ "$didsomethingchange" == true ]
then
echo "surging now" | tee -a ~/cronlog.log
/usr/local/bin/surge ~/webdir sexoskeleton.com | tee -a ~/cronlog.log
else
echo "no files" | tee -a ~/cronlog.log
fi
Loading…
Cancel
Save