[FUGSPBR] script criar contas

Mauricio Goto freebsd-brasil em sys.adm.br
Qui Mar 6 18:14:14 BRT 2003


alias se alguem quiser usar um script tosco, para adicionar usuarios (ftp) e virtualhost =) 

----------------

#!/bin/tcsh
# Script criado por Mauricio Goto
# Para modificacao entre em contato (goto em sys.adm.br)
#
# ./add-sites www.dominio.com.br user senha

set conf = /usr/local/apache/conf/dominios.conf
set data = `date "+%Y%m%d%H%M"`
set www = $argv[1]
set dir = `echo "$www" | awk -F. '{print $2}'`
set first = `echo "$dir" | cut -c 1`

if ($#argv != 3) then
        printf "Caro $LOGNAME esta faltando os dados (DOMINIO, USER e SENHA)\n"
        exit 1
endif

if -d /usr/htdocs/$first/$dir then
        echo "Diretorio htdocs ja existe (/usr/htdocs/$first/$dir)"
else
        mkdir /usr/htdocs/$first/$dir
endif

if -d /apache/logs/$argv[1] then
        echo "Diretorio de logs ja existe (/apache/logs/$argv[1])"
else
        mkdir /apache/logs/$argv[1]
        touch /apache/logs/$argv[1]/error_log
        touch /apache/logs/$argv[1]/access_log
endif


cp $conf $conf.bkp/dominios.conf.$data
echo "" >> $conf
echo "<VirtualHost *>" >> $conf
echo " ServerName $www" >> $conf
echo "  DocumentRoot /usr/htdocs/$first/$dir" >> $conf
echo "  SetEnvIf Remote_Addr "\"127\.0\.0\.1\"" babacas" >> $conf
echo "  SetEnvIf Request_URI "\"\^robots\.txt\$\"" babacas" >> $conf
echo "  SetEnvIf Request_URI "\"^cmd\.exe\$\"" babacas" >> $conf
echo "  SetEnvIf Request_URI "\"^root\.exe\$\"" babacas" >> $conf
echo "  ErrorLog  /apache/logs/$www/error_log" >> $conf
echo "  CustomLog  /apache/logs/$www/access_log combined env=\!babacas" >> $conf
echo "  CustomLog  /apache/logs/access_log_todos vh env=\!babacas" >> $conf
echo "  DirectoryIndex index.htm index.html index.php" >> $conf
echo "</VirtualHost>" >> $conf


foreach i (`pw usershow -a | awk -F: '{print $1}'`)
        if ($i == $argv[2]) then
                echo "User $argv[2] ja existe"
        else
                set pass = `openssl passwd $argv[3]`
                set next = `pw usernext | awk -F: '{print $1}'`
                set group = `pw groupnext | awk -F: '{print $1}'`
                cp /etc/master.passwd /etc/master.passwd.bkp/master.passwd.$data
                printf "$argv[2]\:$pass\:$next\:$group\:\:0\:0:ftp $argv[1]\:/usr/htdocs/$fi
rst/$dir\:/sbin/nologin\n" >> /etc/master.passwd
                pwd_mkdb -p /etc/master.passwd
                exit 0
        endif
end
history -c

------------------------

[]x

> On Thu, 06 Mar 2003 17:04:56 -0300
> Rogério Godoy <godoy em pucrs.campus2.br> wrote:
> 
> > Ola, alguem tem algum script para criar contas no bsd??? Se tiver, pode
> > me enviar, ou dizer onde consigo.
> > 
> > 
> 
> altere esse script para pegar o usuarios de um file =) 
> 
> 
> foreach i (`pw usershow -a | awk -F: '{print $1}'`)
>         if ($i == $argv[2]) then
>                 echo "User $argv[2] ja existe"
>         else
>                 set pass = `openssl passwd $argv[3]`
>                 set next = `pw usernext | awk -F: '{print $1}'`
>                 set group = `pw groupnext| awk -F: '{print $1}'`
>                 cp /etc/master.passwd /etc/master.passwd.bkp/master.passwd.$data
>                 printf "$argv[2]\:$pass\:$next\:$group\:\:0\:0:ftp $argv[1]\:/usr/htdocs/$first/$dir\:/sbin/nologin\n" >> /etc/master.passwd
>                 pwd_mkdb -p /etc/master.passwd
>                 exit 0
>         endif
> end
> 
> []x
_______________________________________________________________
Sair da Lista: http://www2.fugspbr.org/mailman/listinfo/fugspbr
Historico: http://www4.fugspbr.org/lista/html/FUG-BR/



Mais detalhes sobre a lista de discussão freebsd