Email UserAdmin
Publicado por Perfil removido 28/10/2003
[ Hits: 6.550 ]
Criei uma ferramenta, esta em sua primeira versa~o, ainda tem um monte de coisa pra fazer nele.... ele tem suporte a varios dominios..... para criar usuarios de email no sendmail...... estou refazendo ele .. pra ficar mais facil de usar....... caso vc for usar para criar usuarios em apenas um dominio tem que mudar uns lance no fonte dele.... de alguem tiver dicas, sugesto~es me envia.....
#!/usr/bin/perl
# write by Lucas de Camargo Zechim
# lucas@cneccapivari.br
# www.cneccapivari.br
# version 1b - Ago 21 12:57:47 2003
#
#
# * This program is free software; you can redistribute it and/or
# * modify it under the terms of the GNU General Public License as
# * published by the Free Software Foundation; either version 2 of
# * the License, or (at your option) any later version.
#
# 1. CONFIGURATION
#
$CONFIGURATOR_VERSION = "1.0b";
$CONFIGURATOR_DATE = "Tue Ago 19 16:01:48 BRT 2003";
#
# 2. MAKE VARS OF DIALOG
#
$DIALOG = "`type -p dialog`";
$DIALOG_BACKTITLE = "--backtitle \"AdminUsers version $CONFIGURATOR_VERSION ($CONFIGURATOR_DATE)\"";
$DIALOG_CANCEL_LABEL_QUIT = "--cancel-label 'Sair'";
$DIALOG_OK_LABEL = "--ok-label 'OK'";
$DIALOG_TRIM = "--trim";
#
# 2.1 VARS OF SYSTEM
#
$clear = "`type -p clear`";
$userdd = "`/usr/sbin/useradd`";
$passwd = "`type -p passwd`";
$chmod = "`type -p chmod`";
$chown = "`type -p chown`";
$mkdir ="`type -p mkdir`";
#
# 3. START SCRIPT
#
#
# 3.1 WELCOME MESSAGE
`$DIALOG $DIALOG_BACKTITLE --title "Seja bem-vindo " --msgbox "\nEssa ferramenta foi criada para ajudar a gerenciar usuários de e-mail's. Para entrar tecle <ENTER>, para sair tecle <ESC>\n\nDesenvolvido por Lucas de Camargo Zechim\nlucas\@cneccapivari.br" 12 60`;
$exit=$?;
# IF -1 or 255 -> exit
if ("$exit" != "0") {
exit 0;
$clear;
}
#
# 3.2 MAKE THE FIRST MENU -> WELCOME TO THE JUNGLE
#
while (1) {
if(@machine_array == '') {
$menu = `$DIALOG $DIALOG_BACKTITLE $DIALOG_OK_LABEL --clear --title "AdminUsers" $DIALOG_CANCEL_LABEL_QUIT --menu "" 0 70 5 "1" "Adicionar usuário" "2" "Remover Usuário" "3" "Listar usuários" 2>&1 1>/dev/null`;
}
# IF CANCEL
if ($? != 0) {
`$DIALOG $DIALOG_BACKTITLE --title "Quit" --clear --yesno "\nDeseja realmente sair?" 8 40 2>&1 >/dev/null`;
if ($? == 0) {
exit;
$clear;
}
}
if ($menu == '1') {
# Prompt for name of new user
$new_user = `$DIALOG $DIALOG_BACKTITLE $DIALOG_TRIM $DIALOG_OK_LABEL --title "Criar usuário" --inputbox "Nome do usuario?" 9 60 2>&1 1>/dev/null`;
# Prompt for domain of new user
$new_user_choice_domain = `$DIALOG $DIALOG_BACKTITLE $DIALOG_OK_LABEL --title "Criar Usuário" --radiolist "Dominio do usuário" 10 40 3 "1" "\@domain1" "off" "2" "\@domain2" "off" "3" "\@domain3" "off" 2>&1 1>/dev/null`;
# Make value for domain choice
if ($new_user_choice_domain == 1) {
$new_user_domain = "domain1";
}
if ($new_user_choice_domain == 2) {
$new_user_domain = "domain2";
}
if ($new_user_choice_domain == 3) {
$new_user_domain = "domain3";
}
# Make the var user....
$user="$new_user\@$new_user_domain";
# CONFIRM IF THE USER EXISTS
$grep = `grep -o $user /etc/mail/virtusertable`;
if ($grep) {
`$DIALOG $DIALOG_BACKTITLE $DIALOG_OK_LABEL --title "ERRO" --msgbox "\n\"$user\" já existe." 10 30`;
} else {
# Confirm info of the possible new user.
$new_user_confirm = `$DIALOG $DIALOG_BACKTITLE $DIALOG_OK_LABEL --title "Confirme as informações" --clear --yesno "\nConfirma as informações abaixo:\n\nNome do usuário: $new_user\nDominio do usuário: \@$new_user_domain" 15 60 2>&1 1>/dev/null`;
# If confirm the info of users - !CREATE THE USER!
# Create a user with the follow rule:
# if the domain is @domain1 -> the user is: $new_user_domain
# if is other domain -> the user is: '$new_user_domain'_alies
if ($new_user_confirm == 0) {
if ($new_user_choice_domain == 1) {
# Note: If your system create a home directory, add a comment in the 2 lines bellow
`$mkdir /home/$new_user`; # Create home directory
`$chown $new_user:mail /home/$new_user`; # Chown in home directory
`/usr/sbin/useradd -g mail -d /home/$new_user -s /bin/bash $new_user`; # Create the user
`$passwd $new_user`; # Set the password to user
# Note: If you don't use a "virutal domains in sendmail" comment the 3 lines bellow
`echo "$user $new_user" >> /etc/mail/virtusertable`; # Add user in virtusertable
`makemap hash /etc/mail/vitusertable.db < /etc/mail/virtusertable`; # Create a virtusertable.db
`/etc/rc.d/rc.sendmail restart`; # restart sendmail
} else {
# Make only the first part of domain
my @user_domain = split(/\./,"$new_user_domain");
$#user_domain = 0;
foreach my $domain (@user_domain) {
# Note: If your system create a home directory, add a comment in the 2 lines bellow
`$mkdir /home/$new_user\_$domain`; # Create home directory
`$chown $new_user\_$domain:mail /home/$new_user\_$domain`; # Chown in home directory
`/usr/sbin/useradd -g mail -d /home/$new_user\_$domain -s /bin/bash $new_user\_$domain`; # Create the uesr
`$passwd $new_user\_$domain`; # Set the password to user
# Note: If you don't use a "virutal domains in sendmail" comment the 3 lines bellow
`echo $user $new_user\_$domain >> /etc/mail/virtusertable`; # Add user in virtusertable
`makemap hash /etc/mail/vitusertable.db < /etc/mail/virtusertable`; # Create a virtusertable.db
`/etc/rc.d/rc.sendmail restart`; # restart sendmail
}
}
}
}
}
if ($menu == '2') {
# Prompt for name of delete user
$new_user = `$DIALOG $DIALOG_BACKTITLE $DIALOG_TRIM $DIALOG_OK_LABEL --title "Criar usuário" --inputbox "Nome do usuario?" 9 60 2>&1 1>/dev/null`;
# Prompt for domain of delete user
$new_user_choice_domain = `$DIALOG $DIALOG_BACKTITLE $DIALOG_OK_LABEL --title "Criar Usuário" --radiolist "Dominio do usuário" 10 40 3 "1" "\@cneccapivari.br" "off" "2" "\@jornalocidadao.com.br" "off" "3" "\@carrara.com.br" "off" 2>&1 1>/dev/null`;
# Make value for domain choice
if ($new_user_choice_domain == 1) {
$new_user_domain = "cneccapivari.br";
}
if ($new_user_choice_domain == 2) {
$new_user_domain = "jornalocidadao.com.br";
}
if ($new_user_choice_domain == 3) {
$new_user_domain = "carrara.com.br";
}
# Make the var user....
$user="$new_user\@$new_user_domain";
# CONFIRM IF THE USER EXISTS
$grep = `grep -o $user /etc/mail/virtusertable`;
if ($grep) {
`$DIALOG $DIALOG_BACKTITLE $DIALOG_OK_LABEL --title "ERRO" --msgbox "\n\"$user\" não existe." 10 30`;
} else {
# Confirm info of the possible new user.
$new_user_confirm = `$DIALOG $DIALOG_BACKTITLE $DIALOG_OK_LABEL --title "Confirme as informações" --clear --yesno "\nConfirma a exclusão do usuário:\n$user" 15 60 2>&1 1>/dev/null`;
# If confirm the info of users - !DELETE THE USER!
# Delete a user with the follow rule:
# if the domain is @domain1 -> the user is: $new_user_domain
# if is other domain -> the user is: '$new_user_domain'_alies
if ($new_user_confirm == 0) {
if ($new_user_choice_domain == 1) {
# Note: If your system create a home directory, add a comment in the 2 lines bellow
# `$mkdir /home/$new_user`; # Create home directory
# `$chown $new_user:mail /home/$new_user`; # Chown in home directory
`/usr/sbin/useradd -g mail -d /home/$new_user -s /bin/bash $new_user`; # Create the user
`$passwd $new_user`; # Set the password to user
# Note: If you don't use a "virutal domains in sendmail" comment the 3 lines bellow
`echo "$user $new_user" >> /etc/mail/virtusertable`; # Add user in virtusertable
`makemap hash /etc/mail/vitusertable.db < /etc/mail/virtusertable`; # Create a virtusertable.db
`/etc/rc.d/rc.sendmail restart`; # restart sendmail
} else {
# Make only the first part of domain
my @user_domain = split(/\./,"$new_user_domain");
$#user_domain = 0;
foreach my $domain (@user_domain) {
# Note: If your system create a home directory, add a comment in the 2 lines bellow
# `$mkdir /home/$new_user\_$domain`; # Create home directory
# `$chown $new_user\_$domain:mail /home/$new_user\_$domain`; # Chown in home directory
`/usr/sbin/useradd -g mail -d /home/$new_user\_$domain -s /bin/bash $new_user\_$domain`; # Create the uesr
`$passwd $new_user\_$domain`; # Set the password to user
# Note: If you don't use a "virutal domains in sendmail" comment the 3 lines bellow
`echo $user $new_user\_$domain >> /etc/mail/virtusertable`; # Add user in virtusertable
`makemap hash /etc/mail/vitusertable.db < /etc/mail/virtusertable`; # Create a virtusertable.db
`/etc/rc.d/rc.sendmail restart`; # restart sendmail
}
}
}
}
}
if ($menu == 3) {
# Make the menu of "Listar usuários"
$menu3 = `$DIALOG $DIALOG_BACKTITLE $DIALOG_OK_LABEL --clear --title "AdminUsers" $DIALOG_CANCEL_LABEL_QUIT --menu "" 0 70 5 "1" "Buscar Usuário" "2" "Lista completa" 2>&1 1>/dev/null`;
if ($menu3 == 1) {
$search_user = `$DIALOG $DIALOG_BACKTITLE $DIALOG_TRIM $DIALOG_OK_LABEL --title "" --inputbox "Nome do usuario?" 8 40 2>&1 1>/dev/null`;
if ($search_user == 0) {
`grep "$search_user" /etc/mail/virtusertable > /tmp/tmp_list_users`;
$search_list = `$DIALOG $DIALOG_BACKTITLE $DIALOG_OK_LABEL --title "Lista dos \usuários" --textbox /tmp/tmp_list_users 18 60 2>&1 &1>/dev/null`;
}
}
if ($menu3 == 2) {
## build list of users
$cat_list = `cat /etc/mail/virtusertable > /tmp/tmp_list_users`;
$entire_list = `$DIALOG $DIALOG_BACKTITLE $DIALOG_OK_LABEL --title "Lista dos usuários" --textbox /tmp/tmp_list_users 18 60 2>&1 &1>/dev/null`;
}
}
}
Adicionar conta de e-mail - Postfix com domínios virtuais no MySQL
Apagar spam na fila do postfix por palavra
Remover caixas postais do Cyrus IMAP
Retorna apenas emails válidos com MX válidos
Nenhum comentário foi encontrado.
Cirurgia para acelerar o openSUSE em HD externo via USB
Void Server como Domain Control
Modo Simples de Baixar e Usar o bash-completion
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
[Resolvido] VirtualBox can't enable the AMD-V extension
Como verificar a saúde dos discos no Linux
Como instalar , particionar, formatar e montar um HD adicional no Linux?
Como automatizar sua instalação do Ubuntu para desenvolvimento de software.
Quais os códigos mais dificeis que vcs sabem fazer? (5)
Não consigo instalar distro antiga no virtualbox nem direto no hd (8)
Fiz uma pergunta no fórum mas não consigo localizar (14)
Upscaling com imagem cortada no monitor secundário ao usar iGPU Multi ... (1)
Servidor Ubuntu 24.04 HD 500 não tenho espaço na \home\adminis... [RES... (8)









