Last active
January 19, 2022 04:05
-
-
Save BackFront/51d57d3e3b44cd671b9dd1226b274616 to your computer and use it in GitHub Desktop.
Esse script faz a tarefa de administrar um servidor de ftp conectado ao mysql. Na verdade ele administra as informações do banco de dados; então fica funcionando como um genérico, desde que seja alterado para caber no banco que deseja ser usado.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MYSQL=`which mysql` | |
PWD=`pwd` | |
INICIO="sh $PWD/adminftp.sh" | |
USERDB=XXXXXXXX | |
DB=XXXXXXXXXX | |
PWDDB="XXXXXX" | |
criar_usuario() { | |
clear | |
$MYSQL -u $USERDB -p$PWDDB -e "select * from ftpusers" $DB | |
echo " Criacao de Usuarios para FTP" | |
echo | |
echo -n " Informe o id(valor unico): " | |
read ID | |
echo -n " Informe o nome do usuario: " | |
read USERNAME | |
echo -n " Informe senha: " | |
read PASSWORD | |
sleep 2 | |
$MYSQL -u $USERDB -p$PWDDB -e "insert into ftpusers values($ID,'$USERNAME','$PASSWORD','80','80','/ftp/$USERNAME/',1,100,0,0,0,0,0)" $DB | |
sleep 2 | |
mkdir -p /ftp/$USERNAME | |
chown -R 80.80 /ftp | |
echo | |
echo " Usuario $USERNAME criado com sucesso" | |
echo " Senha $PASSWORD" | |
read f | |
} | |
desativa_usuario() { | |
clear | |
echo " Desativando Usuario" | |
echo | |
echo | |
$MYSQL -u $USERDB -p$PWDDB -e "select * from ftpusers" $DB | |
echo | |
echo -n " Informe o nome do usuario: " | |
read USERNAME | |
sleep 3 | |
$MYSQL -u $USERDB -p$PWDDB -e "update ftpusers set active=0 where username='$USERNAME'" $DB | |
echo | |
echo " Usuario $USERNAME desativado" | |
read f | |
} | |
ativa_usuario() { | |
clear | |
echo " Desativando Usuario" | |
echo | |
echo | |
$MYSQL -u $USERDB -p$PWDDB -e "select * from ftpusers" $DB | |
echo | |
echo -n " Informe o nome do usuario: " | |
read USERNAME | |
sleep 3 | |
$MYSQL -u $USERDB -p$PWDDB -e "update ftpusers set active=1 where username='$USERNAME'" $DB | |
echo | |
echo " Usuario $USERNAME ativado" | |
read f | |
} | |
altera_senha() { | |
clear | |
echo | |
echo " Alterando Senha" | |
echo | |
echo -n " Informe o nome do usuario: " | |
read USERNAME | |
echo -n " Informe nova senha: " | |
read PASSWD | |
$MYSQL -u $USERDB -p$PWDDB -e "update ftpusers set password='$PASSWD' where username='$USERNAME'" $DB | |
echo | |
echo " Senha Alterada para $PASSWD" | |
read f | |
} | |
altera_quota(){ | |
clear | |
echo | |
echo " Alterando Quota" | |
echo | |
$MYSQL -u $USERDB -p$PWDDB -e "select * from ftpusers" $DB | |
echo | |
echo -n " Informe o usuario que deseja alterar: " | |
read USERNAME | |
echo -n " Informe nova quota(MB): " | |
read QUOTA | |
sleep 3 | |
$MYSQL -u $USERDB -p$PWDDB -e "update ftpusers set Quota=$QUOTA where username='$USERNAME'" $DB | |
echo | |
echo " Quota Alterada" | |
read f | |
} | |
lista_usuario(){ | |
clear | |
echo | |
echo " Listando Usuarios" | |
echo | |
echo | |
$MYSQL -u $USERDB -p$PWDDB -e "select * from ftpusers" $DB | |
echo | |
echo " Aperte Enter para sair" | |
read f | |
} | |
opcao_invalida(){ | |
echo "#####################################################################" | |
echo | |
echo "#############Opcao Invalida - Favor digitar uma correta #############" | |
echo | |
echo "#####################################################################" | |
echo | |
echo "##################APERTE ENTER PARA CONTINUAR########################" | |
read f | |
$INICIO | |
} | |
clear | |
echo | |
echo " ADMINISTRACAO FTP COM MYSQL" | |
echo " NetBSD + PureFTPD + MySQL" | |
echo | |
echo | |
echo " 1 - Criar Usuario" | |
echo | |
echo " 2 - Desativar Usuario" | |
echo | |
echo " 3 - Ativar Usuario" | |
echo | |
echo " 4 - Alterar Senha" | |
echo | |
echo " 5 - Altera Quota" | |
echo | |
echo " 6 - Listar Usuarios" | |
echo | |
echo " 7 - SAIR" | |
echo | |
echo -n " Informe a opcao desejada: " | |
read OPT | |
if [ $OPT -eq 1 ] | |
then | |
criar_usuario | |
$INICIO | |
elif [ $OPT -eq 2 ] | |
then | |
desativa_usuario | |
$INICIO | |
elif [ $OPT -eq 3 ] | |
then | |
ativa_usuario | |
$INICIO | |
elif [ $OPT -eq 4 ] | |
then | |
altera_senha | |
$INICIO | |
elif [ $OPT -eq 5 ] | |
then | |
altera_quota | |
$INICIO | |
elif [ $OPT -eq 6 ] | |
then | |
lista_usuario | |
$INICIO | |
elif [ $OPT -eq 7 ] | |
then | |
exit | |
else | |
opcao_invalida | |
read | |
$INICIO | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment