Die Runde Stunde
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

68 lines
2.1 KiB

#!/bin/bash
# Upload jpeg images from the give directory to the uberspace host.
# All images will be resized first, copied and then hugo generation will be started.
# Login will be done with ssh, so key must be installed for the
# executing system: See https://dashboard.uberspace.de/dashboard/authentication
# case in-sensitive matching
shopt -s nocaseglob
if [ -z "$1" ]
then
echo "Uploder for drs - Die Runde Stunde - to Uberspace"
echo "Usage:"
echo " upload <SORUCE_DIR>"
echo "SOURCE_DIR is a locale directory with jpg image file(s) (must end with case insensitive jpg or jpeg). All images will be resized and then copied to uberspace. Then the Hugo generation will be triggered."
exit 1
fi
if [[ ! -d "$1" ]]
then
echo "'$1' seems not to be an existing directory on your filesystem."
exit 1
fi
# We take all image files from the particular directory (no sub dir)...
count="$(find $1 -maxdepth 1 -iregex '.*\.jpe?g' | wc -l)"
if [[ $count == 0 ]]
then
echo "No jpg file found!"
exit 1
fi
echo "Found $count image(s) on $1"
# Create a temporary directory and store its name in a variable ...
TMPDIR=$(mktemp -d)
# Bail out if the temp directory wasn't created successfully.
if [ ! -e $TMPDIR ]; then
>&2 echo "Failed to create temp directory"
exit 1
fi
echo "Using temp dir: $TMPDIR"
# Make sure it gets removed even if the script exits abnormally.
trap "exit 1" HUP INT PIPE QUIT TERM
trap 'rm -rf "$TMPDIR"' EXIT
echo "Rezising image(s)"
# Copy and resize original images, we want to upload smaller files to uberspace
FILES=$(find "$1" -iregex '.*\.jpe?g')
for FILE in $FILES; do
convert "$FILE" -resize 1900x "$TMPDIR"/$(basename "$FILE")
done
HOST=kollegen@despina.uberspace.de
DESTDIR=/home/kollegen/dierundestundegen/dropin
echo "Uploading to $HOST/$DESTIDR"
rsync -v $TMPDIR/* $HOST:$DESTDIR
echo Generate content on uberspace
ssh kollegen@despina.uberspace.de 'cd dierundestundegen/dierundestunde/redaktion && venv/bin/python ~/dierundestundegen/dierundestunde/redaktion/generate_content.py && ~/dierundestundegen/dierundestunde/redaktion/generate.sh'
echo Done.