#!/bin/sh set -e configfile=".gotmailauth" if [ -e /etc/adduser.conf ]; then . /etc/adduser.conf else echo "/etc/adduser.conf missing. Exiting..." exit 1 fi if [ $# -gt 0 ]; then USERS=$* else USERS=`getent passwd | awk -F: '{print $1}'` fi if [ "$VERBOSE" ]; then opts="--verbose" else opts="--silent" fi for user in $USERS; do uid=`getent passwd $user | awk -F: '{print $3}' | head -1` HOME=`getent passwd $user | awk -F: '{print $6}' | head -1` if [ -z "$HOME" ]; then echo "User $user doesn't exist. Ignoring..." continue fi # Ignore non-human accounts silently [ "$uid" -ge "$FIRST_UID" -a "$uid" -le "$LAST_UID" ] || continue [ -d $HOME ] || continue # [ -L $HOME ] && continue if [ -e $HOME/$configfile ]; then for line in `cat $HOME/$configfile | egrep -v '^[[:blank:]]*#'`; do login=`echo "$line" | awk -F: '{print $1}'` pw=`echo "$line" | awk -F: '{print $2}'` target=`echo "$line" | awk -F: '{print $3}'` if [ -z "$target" ]; then target=$user fi su mail -c "gotmail -u $login -p $pw --delete-messages --use-sa --delete-spam $opts --forwarding-email $target || echo \"Gotmail from $login@hotmail.com to $target failed with error \$?\"" done fi done