]> git.draconx.ca Git - scripts.git/blob - fetchmail-sync.zsh
Add script to convert "JWK"-format RSA keys to normal.
[scripts.git] / fetchmail-sync.zsh
1 #!/usr/bin/env zsh
2 #
3 # Copyright (C) 2010 Nick Bowler
4 #
5 # Simple script which ensures that a running fetchmail daemon is
6 # sleeping, by forcing a fetch run and waiting until it finishes.
7 # This is useful for log rotation: the fetchmail daemon will not
8 # write to the log file while it is sleeping.  It is also useful
9 # for manually invoking fetch runs.
10 #
11 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
12 # This is free software: you are free to do what the fuck you want to.
13 # There is NO WARRANTY, to the extent permitted by law.
14
15 setopt nonotify
16
17 pid=`head -n 1 ~/.fetchmail.pid 2>/dev/null`
18
19 if ! [[ $pid > 0 && $(ps --no-heading $pid) =~ fetchmail ]]; then
20         echo "$0: fetchmail is not running."
21         exit 1
22 fi
23
24 coproc sed --unbuffered '/^fetchmail: sleeping/q'
25 tail -s 0.1 -n 0 -f ~/.fetchmaillog --pid $! >&p &
26 kill -USR1 $pid
27 <&p
28 wait