Skip to content

Commit

Permalink
make: email target to start server lazily
Browse files Browse the repository at this point in the history
  • Loading branch information
booxter committed Nov 20, 2024
1 parent b31017a commit e8bf6f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ run-db-upgrade:
webapp:
pdm run webapp

email:
./scripts/email.sh --start-server

swagger:
#curl http://localhost:8000/api/doc/swagger.json -o swagger.json
pdm run swagger > swagger.json.tmp
Expand Down
13 changes: 12 additions & 1 deletion scripts/email.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
#!/bin/sh

set -e

# Accept a parameter --start-server to start the server before sending the email.
if [ "$1" = "--start-server" ]; then
flox activate -- make webapp &
sleep 10 # Wait for the server to start.
fi

[email protected]
TOADDRS=$FROMADDR

tmpdir=$(mktemp -d)
reportfile=$tmpdir/movies.report

lcli report render --name default > "$reportfile"
flox activate -- lcli report render --name default > "$reportfile"
mailsend-go -from $FROMADDR -t $TOADDRS -sub "Movies for $(date '+%Y-%m-%d')" \
-use gmail auth -user $FROMADDR -pass "$(pass priv/google.com-mutt)" \
body -file "$reportfile"

rm -r "$tmpdir"

kill %1
exit

0 comments on commit e8bf6f8

Please sign in to comment.