| verzia 1.2, 2003/06/18 09:25:34 |
verzia 1.3, 2003/06/18 12:18:59 |
|
|
| # - virtualdomains and rcpthosts are handled |
# - virtualdomains and rcpthosts are handled |
| # 16/06/2003 - option --help implemented |
# 16/06/2003 - option --help implemented |
| # - extended command line parsing with --alias option |
# - extended command line parsing with --alias option |
| |
# - local aliases support implemented |
| # |
# |
| |
|
| # $Platon: scripts/shell/sysadmin/qmail-manage.sh,v 1.1 2003/05/28 14:42:12 nepto Exp $ |
# $Platon: scripts/shell/sysadmin/qmail-manage.sh,v 1.2 2003/06/18 09:25:34 nepto Exp $ |
| |
|
| # |
# |
| # SYSTEM COMMANDS CONFIGURATION |
# SYSTEM COMMANDS CONFIGURATION |
| Riadok 60 finish() # modify this function to fit y |
|
| Riadok 61 finish() # modify this function to fit y |
|
| |
|
| usage() |
usage() |
| { |
{ |
| $ECHO "$PRG [ --help ] [ --alias <alias> ] <e-mail-address> <password>"; |
$ECHO "$PRG [ --help ] [ --alias <aliased-mailbox> ] <e-mail-address> <password>"; |
| exit 1; |
exit 1; |
| } |
} |
| |
|
| Riadok 130 for option; do |
|
| Riadok 131 for option; do |
|
| esac |
esac |
| done |
done |
| |
|
| |
# alias flag |
| |
alias_f=''; |
| |
if [ "$alias" ]; then |
| |
alias_f='1'; |
| |
fi |
| |
|
| # check if e-mail address seems to be valid |
# check if e-mail address seems to be valid |
| if [ "` $ECHO \"$email\" | $GREP -E '^[^@ ]+@[^@ ]+\.[^@ ]+$' `" ]; then |
if [ "` $ECHO \"$email\" | $GREP -E '^[^@ ]+@[^@ ]+\.[^@ ]+$' `" ]; then |
| # do nothing |
# do nothing |
|
|
| error "bad e-mail address"; |
error "bad e-mail address"; |
| fi |
fi |
| |
|
| |
# check if alias e-mail address seems to be valid |
| |
if [ $alias_f ]; then |
| |
if [ "` $ECHO \"$alias\" | $GREP -E '^[^@ ]+@[^@ ]+\.[^@ ]+$' `" ]; then |
| |
# do nothing |
| |
else |
| |
error "bad alias e-mail address"; |
| |
fi |
| |
fi |
| |
|
| # call startup() function |
# call startup() function |
| startup; |
startup; |
| |
|
| Riadok 149 domain2="` $ECHO \"$domain\" | $SED 's |
|
| Riadok 165 domain2="` $ECHO \"$domain\" | $SED 's |
|
| password2="` $HTPASSWD -nb DUMMY \"$password\" | sed 's/DUMMY://g' `"; |
password2="` $HTPASSWD -nb DUMMY \"$password\" | sed 's/DUMMY://g' `"; |
| mailbox="$DIR_MAILBOX/$domain2/$email"; |
mailbox="$DIR_MAILBOX/$domain2/$email"; |
| qmail_key="=$domain2-$username"; |
qmail_key="=$domain2-$username"; |
| |
alias_username="` $ECHO \"$alias\" | $SED 's/@.*$//g' `"; |
| |
alias_domain="` $ECHO \"$alias\" | $SED 's/^.*@//g' `"; |
| |
alias_qmail_key="=$domain2-$alias_username"; |
| |
|
| |
# alias sanity check |
| |
if [ $alias_f ]; then |
| |
if [ "$alias_domain" != "$domain" ]; then |
| |
error 'alias domain is not equal to e-mail domain'; |
| |
fi |
| |
if [ "$alias_username" = "$username" ]; then |
| |
error 'alias username is equal to e-mail username'; |
| |
fi |
| |
|
| # sanity check |
# sanity check |
| if [ "$domain" = "$domain2" ]; then |
if [ "$domain" = "$domain2" ]; then |
| error 'something went wrong, $domain is equal to $domain2'; |
error 'something went wrong, $domain is equal to $domain2'; |
| |
fi |
| fi |
fi |
| |
|
| # virtualdomains and rcpthosts file lines |
# virtualdomains and rcpthosts file lines |
|
|
| >"$DIR_PASSWORDS/$domain"; |
>"$DIR_PASSWORDS/$domain"; |
| fi |
fi |
| |
|
| |
# if we are making an alias, get appropriate information |
| |
if [ $alias_f ]; then |
| |
notice "extracting real mailbox path for alias"; |
| |
mailbox="` $GREP "^$alias_qmail_key:" "$DIR_DOMAINS/$domain" \ |
| |
| sed 's/^[^:]*:[^:]*:[^:]*:[^:]*:\(.[^:]*\):.*$/\1/g' `"; |
| |
fi |
| |
|
| # domain and password file lines |
# domain and password file lines |
| #=pokus-sk-ondrej.jombik:mailbox:888:888:/usr/mailbox/pokus-sk/ondrej.jombik@pokus.sk::: |
#=pokus-sk-ondrej.jombik:mailbox:888:888:/usr/mailbox/pokus-sk/ondrej.jombik@pokus.sk::: |
| domain_file_line="$qmail_key:mailbox:888:888:$mailbox:::"; |
domain_file_line="$qmail_key:mailbox:888:888:$mailbox:::"; |
| Riadok 204 domain_file_line="$qmail_key:mailbox:888 |
|
| Riadok 240 domain_file_line="$qmail_key:mailbox:888 |
|
| password_file_line="$email:$password2:mailbox:$mailbox"; |
password_file_line="$email:$password2:mailbox:$mailbox"; |
| |
|
| echo "$domain_file_line" >> "$DIR_DOMAINS/$domain"; |
echo "$domain_file_line" >> "$DIR_DOMAINS/$domain"; |
| echo "$password_file_line" >> "$DIR_PASSWORDS/$domain"; |
if [ ! $alias_f ]; then |
| |
echo "$password_file_line" >> "$DIR_PASSWORDS/$domain"; |
| |
fi |
| |
|
| # nastavit domenovy subor a passwordovy subor vytvorit adresar |
# nastavit domenovy subor a passwordovy subor vytvorit adresar |
| # /usr/mailbox/domena/usermailbox v nom vytvorit Maildir |
# /usr/mailbox/domena/usermailbox v nom vytvorit Maildir |
| # (/var/qmail/bin/maildirmake) a do toho isteho adresara nakopirovat |
# (/var/qmail/bin/maildirmake) a do toho isteho adresara nakopirovat |
| # defaultny .qmail subor ktory bude mat niekde zadefinovanu cestu.. |
# defaultny .qmail subor ktory bude mat niekde zadefinovanu cestu.. |
| |
|
| if [ ! -d "$mailbox" ]; then |
if [ ! $alias_f ]; then if [ ! -d "$mailbox" ]; then |
| # if this fails we have a really big problem... |
# if this fails we have a really big problem... |
| mkdir -p "$mailbox" || error "mailbox '$mailbox' creation failure"; |
mkdir -p "$mailbox" || error "mailbox '$mailbox' creation failure"; |
| cd "$mailbox" \ |
cd "$mailbox" \ |
| Riadok 219 if [ ! -d "$mailbox" ]; then |
|
| Riadok 257 if [ ! -d "$mailbox" ]; then |
|
| && cd - \ |
&& cd - \ |
| && notice "mailbox '$mailbox' was created" \ |
&& notice "mailbox '$mailbox' was created" \ |
| && cp -f "$file_default_dotqmail" "$mailbox/.qmail" 2>/dev/null |
&& cp -f "$file_default_dotqmail" "$mailbox/.qmail" 2>/dev/null |
| fi |
fi; fi |
| |
|
| # call finish() function |
# call finish() function |
| finish; |
finish; |
| |
|
| if :; then |
if :; then |
| #else # just comment this line to enable debug information |
else # just comment this line to enable debug information |
| # debug print |
# debug print |
| echo "email: $email"; |
echo "email: $email"; |
| echo "alias: $alias"; |
echo "alias: $alias"; |