Skip to content

Instantly share code, notes, and snippets.

@t0d0r
Created August 21, 2012 12:47
Show Gist options
  • Save t0d0r/3415094 to your computer and use it in GitHub Desktop.
Save t0d0r/3415094 to your computer and use it in GitHub Desktop.
bash script from mail.interbild.net
#!/bin/sh
# script name: mkmailuser
# part of freebsd helpers
# author todor dragnev aka t0d0r
## get command line
user1=$1
password=$2
ip=$3
email=$4
date=`date +"%D %T"`
user=`echo ${user1} | tr "[:upper:]" "[:lower:]"`
if [ "$ip" = "" ]; then
echo "Usage: $0 <username> <password> <ip> [option@email]"
exit
fi
if [ -f /home/mail/$user ]; then
echo "already have account with this login name."
exit
fi
echo ${password} | pw useradd ${user} -h 0 -d /home/mail/${user} -m -g 200 -c "mailonly[${ip}]" -s /sbin/nologin || exit
echo "
## username : $user
## ip : $ip
## date : $date
## email : $email
" | tee > /home/mail/$user/create-mail.nfo
finger $user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment