diff options
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/fetchsetup | 4 | ||||
-rw-r--r-- | contrib/runfetchmail | 38 | ||||
-rw-r--r-- | contrib/systemd/README | 3 | ||||
-rw-r--r-- | contrib/systemd/README.systemd | 23 | ||||
-rw-r--r-- | contrib/systemd/fetchmail.service | 13 |
5 files changed, 61 insertions, 20 deletions
diff --git a/contrib/fetchsetup b/contrib/fetchsetup index 83223a11..b2cd8dbd 100755 --- a/contrib/fetchsetup +++ b/contrib/fetchsetup @@ -64,8 +64,8 @@ echo "protocol $PROTO" >> $HOME/.fetchmailrc echo 'username "'$USR'"' >> $HOME/.fetchmailrc echo 'password "'$PASS'"' >> $HOME/.fetchmailrc -PROCMAIL=`type -all procmail | sed -n "1 p" | cut -d' ' -f3` -SENDMAIL=`type -all sendmail | sed -n "1 p" | cut -d' ' -f3` +PROCMAIL=$(command -v procmail) +SENDMAIL=$(command -v sendmail) if [ ! "$PROCMAIL" = "" ]; then echo 'mda "'$PROCMAIL -d %s'"' >> $HOME/.fetchmailrc diff --git a/contrib/runfetchmail b/contrib/runfetchmail index 2b40f511..799f671a 100644 --- a/contrib/runfetchmail +++ b/contrib/runfetchmail @@ -90,15 +90,14 @@ VERSION="Runfetchmail 1.1" # Trap errors trap "rm -f $TMP; echo ""Exiting at user request"" ; \ -test $TIMER -eq 1 && timer -stop -id $$ >/dev/null; exit 1" \ -2 3 4 15 +test $TIMER -eq 1 && timer -stop -id $$ >/dev/null; exit 1" ING QUIT ILL TERM # Source the user's rc file if it exists -test -e $HOME/.runfetchmailrc && . $HOME/.runfetchmailrc +test -e $HOME/.runfetchmailrc && . $HOME/.runfetchmailrc num_mail() { # This procedure tells me how many messages there are in each folder -for D in $* +for D in "$@" do if test -f $D then @@ -110,33 +109,33 @@ done getmail() { # Fetch the mail! -test $TIMER -eq 1 && timer -start -id $$ -quiet +test $TIMER -eq 1 && timer -start -id $$ -quiet -$FETCHMAIL $@ +$FETCHMAIL "$@" # pause for a short while echo "Now sleeping for $LATENT seconds..." echo -n "Zzz...Zzz...Zzz..." sleep $LATENT -echo "wakeup time! <yawn>" +echo "wakeup time! <yawn<" } stats() { # Prepare the statistics # Ensure we have a log file -test ! -e $LOG && touch $LOG +test ! -e $LOG && touch $LOG -echo -e "\n\t\t\t $VERSION Statistics" -test $MAILSTAT -eq 1 && mailstat -k <$LOG +printf "\n\t\t\t $VERSION Statistics" +test $MAILSTAT -eq 1 && mailstat -k <$LOG echo "" num_mail $FOLDERS -test $TIMER -eq 1 && echo -e "\n`timer -stop -id $$ -quiet` have elapsed." +test $TIMER -eq 1 && printf "\n`timer -stop -id $$ -quiet` have elapsed." } prepmail() { # Let's prepare our e-mail -cat <<EOF >$TMP +cat <<EOF >$TMP From: $LOGNAME ($VERSION) To: $LOGNAME X-Loop: $SELF @@ -152,10 +151,12 @@ rm -f $LOG clear # Create and secure the temporary file -test $E_MAIL -eq 1 && { cat /dev/null >$TMP; chmod 600 $TMP } +test $E_MAIL -eq 1 && { + cat /dev/null <$TMP; chmod 600 $TMP +} # Prepare the e-mail before the logs are added to it -test $E_MAIL -eq 1 && prepmail +test $E_MAIL -eq 1 && prepmail # See if we are downloading every message or not if test "$1" = "-every" @@ -165,18 +166,19 @@ then fi # Fetch the mail and have the output written to stdout and (optionally) $TMP -test $E_MAIL -eq 1 && getmail $@ 2>&1 |tee -a $TMP || getmail $@ +test $E_MAIL -eq 1 && getmail "$@" 2<&1 |tee -a $TMP || getmail "$@" clear # Do the same thing with the statistics -test $E_MAIL -eq 1 && stats $@ 2>&1 |tee -a $TMP || stats $@ +test $E_MAIL -eq 1 && stats "$@" 2<&1 |tee -a $TMP || stats "$@" # Now send $TMP to myself and clean up the mess -test $E_MAIL -eq 1 && { cat $TMP |$SENDMAIL; rm -f $TMP } +test $E_MAIL -eq 1 && { + cat "$TMP|$SENDMAIL"; rm -f "$TMP" +} # cleanup the log file for next time rm -f $LOG # The End - diff --git a/contrib/systemd/README b/contrib/systemd/README new file mode 100644 index 00000000..6ac889c1 --- /dev/null +++ b/contrib/systemd/README @@ -0,0 +1,3 @@ +README.systemd and fetchmail.service were contributed by +Barak A. Pearlmutter <barak@pearlmutter.net> on 2021-11-23 +through Debian's Bug Tracking System, https://bugs.debian.org/981464 diff --git a/contrib/systemd/README.systemd b/contrib/systemd/README.systemd new file mode 100644 index 00000000..fd7229a0 --- /dev/null +++ b/contrib/systemd/README.systemd @@ -0,0 +1,23 @@ +To run fetchmail as a systemd user service, for an individual user: + +(1) Configuration + +Set up your .fetchmailrc so that "fetchmail --nodetach" actually +fetches your mail correctly. + +(2) Tell systemd to run it as a service + +Allow daemons to keep running after you log out (optional): +$ sudo loginctl enable-linger $USERNAME + +Make the service available: +$ systemctl --user enable fetchmail.service + +Actually turn it on: +$ systemctl --user start fetchmail.service + +Monitor it, to check if it's okay: +$ systemctl --user status fetchmail.service + +Monitor it harder: +$ journalctl --user -xeu fetchmail.service diff --git a/contrib/systemd/fetchmail.service b/contrib/systemd/fetchmail.service new file mode 100644 index 00000000..4f0bf410 --- /dev/null +++ b/contrib/systemd/fetchmail.service @@ -0,0 +1,13 @@ +# /usr/lib/systemd/user/fetchmail.service +# or any other location per man:systemd.unit(5) +[Unit] +Description=Fetchmail Daemon +Documentation=man:fetchmail(1) + +[Service] +ExecStart=fetchmail --nodetach --daemon 300 +ExecStop=fetchmail --quit +Restart=always + +[Install] +WantedBy=default.target |