#!/bin/bash
# sms-conf - skrypt konfiguruje w ~/ plik .promailrc
# Author: Wrebiak Dariusz : beat@irc.pl
#
if [ "$EUID" != 0 ] ; then
    echo "[1mTylko root moze uzywac tego skryptu[0m"
  exit 0
fi

echo -n "[1mPodaj login konta ktore mam configurowac:[0m "
read user

DIR=`finger $user | grep Directory | awk '{print $2}'`
cd $DIR
touch .procmailrc

echo -n "[1mPodaj numer telefonu uzytkownika:[0m "
read telefon

echo 'NEW_SUBJECT=`formail -xSubject`' >> .procmailrc
echo 'SMS_MAILADDR=`formail -xReturn-Path`' >> .procmailrc
echo 'NEW_BODY=`formail -c | /usr/local/bin/mimecut`' >> .procmailrc
echo 'SIZE=`wc -c`' >> .procmailrc
echo ':0 c' >> .procmailrc
echo '* !^FROM_DAEMON' >> .procmailrc
echo "| /usr/local/bin/sms $telefon" '"$SMS_MAILADDR" "$SIZE" "$NEW_SUBJECT" "$NEW_BODY"' >> .procmailrc

grupa=`id -ng $user`
chown $user.$grupa .procmailrc

# http://orion.galaxy.okay.pl/~beat
