Last active
August 29, 2015 14:03
-
-
Save HenriqueLR/835385610067e97c8f28 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#! /bin/bash | |
#NOME : HENRIQUE LUZ RODRIGUES | |
# Abro uma caixa com a menssagem seguinte.! | |
zenity --warning --text="PARA FUNCIONAR CORRETAMENTE EXECUTE COMO ROOT" | |
#Crio o Menu com as opções usando um case.! | |
Menu () { | |
main=$(zenity --width=710 --height=510 --list --column "Gerência de usuários." \ | |
--title="Gerenciador de Usuários" \ | |
" 1 – Adicionar um usuário ao sistema") | |
case ${main} in | |
" 1 – Adicionar um usuário ao sistema")user ;; | |
esac | |
} | |
#Função que o menu chamada para executar a ação de adicionar o usuário. | |
user () { | |
find /home | zenity --progress --width 350 --pulsate --text "Aguarde..." \ | |
usuario=`zenity --width=250 --height=200 --entry \ | |
--title="Adicionar usuário" \ | |
--text="Digite o nome do usuário:"` | |
if [ $? -eq 1 ] ; then | |
Menu | |
elif [ -z $usuario ] ; then | |
zenity --error --text="Informe um nome para o usuário" | |
user | |
elif ! [ -z `grep -w $usuario /etc/passwd` ] ; then | |
zenity --error --text="Usuário já existe" | |
user | |
else | |
adduser $usuario | |
zenity --info --text="Usuário '$usuario' adicionado com sucesso" | |
fi | |
Menu | |
} | |
#chamada para o menu.! | |
Menu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Estudar uma solução para a barra de progresso, pois estou dando um find no /home, e não é nenhum pouco viável ...