Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve email script #156

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions scripts/email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@

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

trap 'kill %1' EXIT

[email protected]
TOADDRS=$FROMADDR

tmpdir=$(mktemp -d)
reportfile=$tmpdir/movies.report
./scripts/gen_report.sh -s "$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"
Expand Down
31 changes: 31 additions & 0 deletions scripts/gen_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

set -e

start_server=0
while getopts 's' OPTION; do
case "$OPTION" in
s)
start_server=1
;;
*)
echo "Usage: $0 [-s] <outfile>"
exit 1
;;
esac
done
shift $(( OPTIND - 1 ))

outfile=$1

# Make sure the latest code is installed in python env.
flox activate -- make install

# Accept a parameter --start-server to start the server before sending the email.
if [ $start_server -eq 1 ]; then
flox activate -- make webapp &
trap 'kill %1' EXIT
sleep 10 # Wait for the server to start.
fi

flox activate -- lcli report render --name default > "$outfile"
Loading