Create initial commands for automations
This commit is contained in:
commit
a1bfd25b29
56
mailpipe
Executable file
56
mailpipe
Executable file
@ -0,0 +1,56 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
logfile=$(mktemp)
|
||||
exec &>> $logfile
|
||||
exec 100> $HOME/homepage.lock
|
||||
|
||||
#pwd
|
||||
#whoami
|
||||
|
||||
file=$(mktemp)
|
||||
cat > $file
|
||||
|
||||
finish() {
|
||||
code=$?
|
||||
|
||||
cat $logfile >> /tmp/mailpipe.log
|
||||
|
||||
if [ $code -gt 0 ]
|
||||
then
|
||||
sendmail vizesportwart@tsc-vfl.de << EOF
|
||||
From: TSC Homepage Bot <tsc-homepage@server-hh>
|
||||
To: Vizesportwart <vizesportwart@tsc-vfl.de>
|
||||
Date: $(date)
|
||||
Subject: Failed to parse ESV mail
|
||||
|
||||
The parsing of the competition notification failed. Please see also the logs!
|
||||
|
||||
The output of the script:
|
||||
|
||||
$(cat $logfile)
|
||||
|
||||
The offending mail was this one:
|
||||
|
||||
$(cat $file)
|
||||
EOF
|
||||
fi
|
||||
exit $?
|
||||
}
|
||||
trap finish EXIT
|
||||
|
||||
flock 100
|
||||
|
||||
cd $HOME/hugo-page
|
||||
git fetch
|
||||
git reset --hard origin/develop
|
||||
|
||||
. ~/venv-homepage/bin/activate
|
||||
pip install -r scripts/read-competition-notification/requirements.txt
|
||||
|
||||
./scripts/read-competition-notification/run.sh -o content/turniermeldung --read-mbox $file -vv
|
||||
|
||||
git add content/turniermeldung
|
||||
git commit -m "Automatic commit to create new competition notification"
|
||||
git push origin develop
|
||||
|
||||
rm $file
|
79
update-cron.sh
Executable file
79
update-cron.sh
Executable file
@ -0,0 +1,79 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
exec 100> $HOME/homepage.lock
|
||||
|
||||
flock 100
|
||||
|
||||
src=/srv/data/tsc-cloud/homepage/hugo-page
|
||||
dst=/srv/http/tsc/hugo
|
||||
|
||||
cmd="$SSH_ORIGINAL_COMMAND"
|
||||
# echo "$cmd"
|
||||
|
||||
publishToStage=
|
||||
publishToProduction=y
|
||||
|
||||
parseCMD() {
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
part="$1"
|
||||
shift
|
||||
|
||||
case "$part" in
|
||||
stage)
|
||||
publishToStage=y
|
||||
publishToProduction=
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command $part"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
parseCMD $cmd
|
||||
|
||||
doPublishToStage() {
|
||||
rsync -ah --delete --delete-delay public/ "$dst/"
|
||||
}
|
||||
|
||||
doPublishToProduction() {
|
||||
rclone sync --stats 3s -c public/ ionos:/
|
||||
rclone rmdirs ionos:/
|
||||
}
|
||||
|
||||
# exit 1
|
||||
|
||||
cd "$src"
|
||||
|
||||
echo "Fetching the latest git commits"
|
||||
git fetch
|
||||
|
||||
echo "Switching tothe latest branch commit"
|
||||
git reset --hard origin/develop
|
||||
|
||||
echo "Updating NPM packages"
|
||||
npm ci
|
||||
|
||||
echo "Dropping old public folder"
|
||||
rm -rf public
|
||||
|
||||
echo "Building the page"
|
||||
npm run build
|
||||
|
||||
echo "Synchronizing files to web server"
|
||||
|
||||
if [ -n "$publishToStage" ]
|
||||
then
|
||||
echo "Pushing to stage"
|
||||
time doPublishToStage
|
||||
fi
|
||||
|
||||
if [ -n "$publishToProduction" ]
|
||||
then
|
||||
echo "Publishing to production server"
|
||||
time doPublishToProduction
|
||||
fi
|
||||
|
||||
echo "Deployment done"
|
||||
|
Loading…
Reference in New Issue
Block a user