Apostila interativa de linux (incompleto)

Publicado por Edersom 09/11/2004

[ Hits: 11.593 ]

Download Apostila.tar.gz




Este Script, eh apenas uma estrutura que montei a fim de montar uma apostila on-line de linux, mas como meus conhecimentos saum um pouco fraquinhos (podem observar isso no código fonte do script) Resolvi pedir ajuda :D

Bom, Se surgir alguma Dúvida, naum deixe de me consultar
valews galera!!!!!!
fuiiiiiiii

  



Esconder código-fonte

#!/bin/sh
#
# SCRIPT:
# AUTOR: EDERSOM ANGELO DA SILVA (maxmaxine@gmail.com)
# DATA: 07/11/2004
# REV: 1.1.B
# PLATAFORMA: LINUX
#
# FINALIDADE:   # Criar uma ferramenta eficaz de auxilio ao estudo do linux,
#      # reunindo o máximo possivel de documentação sobre vários assuntos
#
#
# LISTA DE REVISAO:
#
#   DATA: data_da_modificação
#   POR: Autor_da_modificação
#   MODIFICAÇÃO: Modificação realizada.
#
# LICENÇA: GLP
#
#
# DECLARAÇÕES DO AUTOR:   # Eu sou ainda um filhote de pinguim
#         # Não possuo muitos conhecimentos no mundo Linux
#         # Por isso, não ligue se ver alguma bobeira escrita
#         # Pois afinal eu ainda estou aprendendo (como voce)
#         # E foi pensando nisto, que criei este Script, para
#         # Poder aprender mais Sobre linux, e oferecer para quem
#         # Quiser, uma ferramenta de estudo interessante didaticamente falando         
#
# set -n # Tire o comantário para verificar sua sintaxe, sem executar.
#    # Obs: Não se esqueça de recolocá-lo, caso contrário o script naum funcionará
# set -x # Retire o comantário para Depurar este shell-script (Apenas korn shell (ksh))
#
#
#############################################
###  ABAIXO ESTAO DEFINIDAS AS VARIÁVEIS  ###
#############################################
DIALOG=${DIALOG=dialog}
TITU='Estudo Interativo'
BACK='Tux o Pinguim Selvagem'
tempfile='/tmp/tmpfile'
PROXIMA=primeira
calc=${calc=/tmp/calc}

################################################
###  TENHO NEM IDEIA DE COMO CHAMAR O RESTO  ###
################################################


while : # Gera o loop Principal
do
case "$PROXIMA" in # Executa as sequencias definidas na variável atual 

#-------------------------------------------------------------------------------------------------------------------------------


#TELA INICIAL
        primeira)
PROXIMA=menu_1 #define que a proxima tela a ser exibida será o menu Principal


$DIALOG                                               \
--backtitle "$BACK"                                   \
--title "$TITU"                                       \
--msgbox                                              \
"Bem-vindo Programa de auxilio ao estudo do Linux\n
Este script almeja ser uma ferramenta completa para o
auxilio ao estudo Inicial/Avançado do linux"          \
0 0
                                                      ;;

#-------------------------------------------------------------------------------------------------------------------------------

#Menu principal

   menu_1)
   $DIALOG                                       \
   --backtitle "$BACK"                           \
   --title "$TITU"                               \
   --cancel-label "Sair"                         \
   --menu                                        \
   "Menu Principal\n
   Escolha uma das opçoes abaixo"                \
   10 40 3                                       \
   1 "Estudar"                                   \
   2 "Responder Questionário"                    \
   Ca "Calculadora Simples" 2>$tempfile
valret=$?
if [ "$valret" == 0 ]
then
PROXIMA=`cat $tempfile` # Define váriavel de acordo com a escolha
else
exit 0
fi
                                                      ;;

#-------------------------------------------------------------------------------------------------------------------------------

################################################################################################################################
################################################################################################################################

# Menu 1-2
# Aqui é feita a escolha da categoria da matéria a ser estudada

   1) 
        $DIALOG                                       \
        --backtitle "$BACK"                           \
        --title "$TITU"                               \
        --cancel-label 'VOLTAR'                       \
        --menu                                        \
        'Menu Estudar\nEscolha uma das opçoes abaixo' \
        0 0 0                                         \
   Ln "Linux Básico"                             \
   Rl "Redes linux"                              \
        Sl "Servidores Linux" 2>$tempfile

valret=$?
if [ "$valret" == 0 ]
then
PROXIMA=`cat $tempfile`
else
PROXIMA='menu_1'
fi
                                                     ;;
#-------------------------------------------------------------------------------------------------------------------------------
       Ln)
        PROXIMA=1
        $DIALOG                                       \
        --backtitle "$BACK"                           \
        --title "$TITU"                               \
        --yesno                                       \
        "Voce escolheu Linux Básico\ncontinuar?"      \
        0 0
# valret=$?
if [ "$?" == 0 ]
then

pwd >$tempfile


$DIALOG                                               \
        --backtitle "$BACK"                           \
        --title "$TITU"                               \
        --cancel-label 'VOLTAR'                       \
        --menu                                        \
        'Escolha uma das opçoes abaixo'               \
        0 0 0                                         \
   Hl "História do Linux"                        \
   Db "O que é e como escolher uma distro"       \
        In "Instalação do Linux"                      \
        Au "Administração de usuários"                \
        Sx "Servidor X"                               \
   Os "O que é shell?"                           \
        Ic "Introdução aos Comandos"                  \
        Ta "Trabalhando com arquivos"                 \
        Cg "Configurações gerais"                     \
        Cs "Comandos úteis" 2>/tmp/resp1


   if [ "$?" == 0 ]
   then
      tmp=`cat $tempfile`
      opcao=`cat /tmp/resp1`
      local=$tmp/Ln
      PROXIMA=RsP
   else
      PROXIMA=1
   fi
else
PROXIMA=1
fi
                                                      ;;
#-------------------------------------------------------------------------------------------------------------------------------
   Rl)
   
           PROXIMA=1
        $DIALOG                                       \
        --backtitle "$BACK"                           \
        --title "$TITU"                               \
        --yesno                                       \
        "Voce escolheu Redes Linux\ncontinuar?"      \
        0 0
# valret=$?
if [ "$?" == 0 ]
then

pwd >$tempfile


$DIALOG                                               \
        --backtitle "$BACK"                           \
        --title "$TITU"                               \
        --cancel-label 'VOLTAR'                       \
        --menu                                        \
        'Escolha uma das opçoes abaixo'               \
        0 0 0                                         \
   Rc "Arquivos de configuração da rede"         \
   Rf "Front-Ends para configuração de rede"     \
        Rd "Dispositivos de Rede"                     \
        Rp "Protocolos"                               \
        Rt "TCP/IP"                                   \
   Ro "Topologia"                                \
        Rc "Cabeamento"                               \
        Rh "Hub"                                      \
        Rs "Switch" 2>/tmp/resp1


   if [ "$?" != 1 ]
   then
      local=`cat $tempfile`
      opcao=`cat /tmp/resp1`
      local=$tmp/Rl
      PROXIMA=RsP
   else
      PROXIMA=1
   fi
else
PROXIMA=1
fi
                                                      ;;

#-------------------------------------------------------------------------------------------------------------------

   Sl)
        PROXIMA=1
        $DIALOG                                       \
        --backtitle "$BACK"                           \
        --title "$TITU"                               \
        --yesno                                       \
        "Voce escolheu Servidores Linux\ncontinuar?"  \
        0 0
# valret=$?
if [ "$?" == 0 ]
then

pwd >$tempfile


$DIALOG                                               \
        --backtitle "$BACK"                           \
        --title "$TITU"                               \
        --cancel-label 'VOLTAR'                       \
        --menu                                        \
        'Escolha uma das opçoes abaixo'               \
        0 0 0                                         \
   Sr "Roteadores"                               \
   Sa "Apache"                                   \
        Sq "Squid"                                    \
        Sm "Samba"                                    \
        Sf "Proftp"                                   \
   Se "Email (SMTP/POP)"                         \
        Sh "DHCP"                                     \
        Sn "DNS"                                      \
        Sd "NIS"                                      \
        St "LTSP"                                     \
   Sa "NFS" 2>/tmp/resp1


   if [ "$?" != 1 ]
   then
      local=`cat $tempfile`
      opcao=`cat /tmp/resp1`
      local=$tmp/Sl
      PROXIMA=RsP
   else
      PROXIMA=1
   fi
else
PROXIMA=1
fi
                                                      ;;

   RsP)

    $DIALOG                                       \
        --title "$TITU"                               \
        --textbox $local/$opcao                       \
        0 0
rm -r /tmp/resp1
PROXIMA=1


                                                      ;;
################################################################################################################################
################################################################################################################################

# Menu 2-2
# Aqui é feita a escolha da categoria da matéria a se responder o questionário

   2)
   $DIALOG                                       \
        --backtitle "$BACK"                           \
        --title "$TITU"                               \
        --cancel-label 'VOLTAR'                       \
        --menu                                        \
        'Menu Questionario\n                          
   Escolha uma das opçoes abaixo'                \
        0 0 0                                         \
   Lb "Linux Básico"                             \
   Re "Redes linux"                              \
        Ss "Servidores Linux" 2>$tempfile

valret=$?
if [ "$valret" == 0 ]
then
PROXIMA=`cat $tempfile`
else
PROXIMA='menu_1'
fi
                                                     ;;


#-------------------------------------------------------------------------------------------------------------------------------
################################################################################################################################

   Lb)
   PROXIMA=2
   $DIALOG                                       \
   --backtitle "$BACK"                           \
   --title "$TITU"                               \
   --yesno                                       \
   "Voce escolheu Linux Básico\nContinuar?"      \
   0 0                                           \

if [ "$?" == 0 ]
then

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
   #PERGUNTA 1
         $DIALOG                                       \
         --title "$TITU"                               \
         --nocancel                                    \
         --backtitle "$BACK"                           \
         --radiolist                                   \
         "Pergunta 1"                                  \
         0 0 0                                         \
         R1 'Resposta 1'     off                       \
         R2 'Resposta 2'     off                       \
         R3 'Resposta 3'     off                       \
         R4 'Resposta 4'     off                       \
         R5 'Resposta 5'     off 2>/tmp/P1
         
   resp1=`cat /tmp/P1`
      
   
   if [ "$resp1" != R1 ] # VERIFICA SE A QUESTÃO ESTA CORRETA OU NÃO
   then
      #GRAVA AS VARIÁVEIS CASO RESPOSTA DIFERENDE DE R1
      
      INC1='A RESPOSTA DA P1 EH...'
      COR1='VC ERROU!'
      
      else
      #GRAVA AS VARIÁVEIS CASO RESPOSTA IGUAL A R1
      
      INC1='VC ACERTOU!'
      COR1='PERGUNTA 1'
      
   fi
      
   $DIALOG --title "$TITU" --backtitle "$BACK" --msgbox "$INC1\n$COR1" 8 60
   
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   
   #PERGUNTA 2
      
      $DIALOG                                       \
      --title "$TITU"                               \
      --backtitle "$BACK"                           \
      --nocancel                                    \
      --radiolist                                   \
      "Pergunta 2"                                  \
      0 0 0                                         \
      R1 'Resposta 1'     off                       \
      R2 'Resposta 2'     off                       \
      R3 'Resposta 3'     off                       \
      R4 'Resposta 4'     off                       \
      R5 'Resposta 5'     off 2>/tmp/P2
      
   resp2=`cat /tmp/P2`
      
   if [ "$resp2" != R1 ] # VERIFICA SE A QUESTÃO ESTA CORRETA OU NÃO
   then
      #GRAVA AS VARIÁVEIS CASO RESPOSTA DIFERENDE DE R1
      
      INC2='A RESPOSTA DA P2 EH...'
      COR2='VC ERROU!'
      
   else
      #GRAVA AS VARIÁVEIS CASO RESPOSTA IGUAL A R1
      
      INC2='VC ACERTOU!'
      COR2='PERGUNTA 2'
      
   fi
      
   $DIALOG --title "$TITU" --backtitle "$BACK" --msgbox "$INC2\n$COR2" 8 60
   
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PROXIMA=resultado
else
PROXIMA=2
fi
                                                     ;;

#-------------------------------------------------------------------------------------------------------------------------------
# Questionario de Redes 
   Re)
   
   PROXIMA=2
   $DIALOG                                       \
   --backtitle "$BACK"                           \
   --title "$TITU"                               \
   --yesno                                       \
   "Voce escolheu Redes Linux\nContinuar?"       \
   0 0                                           \

if [ "$?" == 0 ]
then

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
   #PERGUNTA 1
         $DIALOG                                       \
         --title "$TITU"                               \
         --backtitle "$BACK"                           \
         --nocancel                                    \
         --radiolist                                   \
         "Pergunta 1"                                  \
         0 0 0                                         \
         R1 'Resposta 1'     off                       \
         R2 'Resposta 2'     off                       \
         R3 'Resposta 3'     off                       \
         R4 'Resposta 4'     off                       \
         R5 'Resposta 5'     off 2>/tmp/P1
         
   resp1=`cat /tmp/P1`
      
   
   if [ "$resp1" != R1 ] # VERIFICA SE A QUESTÃO ESTA CORRETA OU NÃO
   then
      #GRAVA AS VARIÁVEIS CASO RESPOSTA DIFERENDE DE R1
      
      INC1='A RESPOSTA DA P1 EH...'
      COR1='VC ERROU!'
      
      else
      #GRAVA AS VARIÁVEIS CASO RESPOSTA IGUAL A R1
      
      INC1='VC ACERTOU!'
      COR1='PERGUNTA 1'
      
   fi
      
   $DIALOG --title "$TITU" --backtitle "$BACK" --msgbox "$INC1\n$COR1" 8 60
   
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   
   #PERGUNTA 2
      
      $DIALOG                                       \
      --title "$TITU"                               \
      --backtitle "$BACK"                           \
      --nocancel                                    \
      --radiolist                                   \
      "Pergunta 2"                                  \
      0 0 0                                         \
      R1 'Resposta 1'     off                       \
      R2 'Resposta 2'     off                       \
      R3 'Resposta 3'     off                       \
      R4 'Resposta 4'     off                       \
      R5 'Resposta 5'     off 2>/tmp/P2
      
   resp2=`cat /tmp/P2`
      
   if [ "$resp2" != R1 ] # VERIFICA SE A QUESTÃO ESTA CORRETA OU NÃO
   then
      #GRAVA AS VARIÁVEIS CASO RESPOSTA DIFERENDE DE R1
      
      INC2='A RESPOSTA DA P2 EH...'
      COR2='VC ERROU!'
      
   else
      #GRAVA AS VARIÁVEIS CASO RESPOSTA IGUAL A R1
      
      INC2='VC ACERTOU!'
      COR2='PERGUNTA 2'
      
   fi
      
   $DIALOG --title "$TITU" --backtitle "$BACK" --msgbox "$INC2\n$COR2" 8 60
   
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PROXIMA=resultado
else
PROXIMA=2
fi
                                                     ;;

#-------------------------------------------------------------------------------------------------------------------------------
# Questionário de Servidores Linux
   Ss)
   PROXIMA=2
   $DIALOG                                       \
   --backtitle "$BACK"                           \
   --title "$TITU"                               \
   --yesno                                       \
   "Voce escolheu Servidores Linux\nContinuar?"  \
   0 0                                           \

if [ "$?" == 0 ]
then

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
   #PERGUNTA 1
         $DIALOG                                       \
         --title "$TITU"                               \
         --backtitle "$BACK"                           \
         --nocancel                                    \
         --radiolist                                   \
         "Pergunta 1"                                  \
         0 0 0                                         \
         R1 'Resposta 1'     off                       \
         R2 'Resposta 2'     off                       \
         R3 'Resposta 3'     off                       \
         R4 'Resposta 4'     off                       \
         R5 'Resposta 5'     off 2>/tmp/P1
         
   resp1=`cat /tmp/P1`
      
   
   if [ "$resp1" != R1 ] # VERIFICA SE A QUESTÃO ESTA CORRETA OU NÃO
   then
      #GRAVA AS VARIÁVEIS CASO RESPOSTA DIFERENDE DE R1
      
      INC1='A RESPOSTA DA P1 EH...'
      COR1='VC ERROU!'
      
      else
      #GRAVA AS VARIÁVEIS CASO RESPOSTA IGUAL A R1
      
      INC1='VC ACERTOU!'
      COR1='PERGUNTA 1'
      
   fi
      
   $DIALOG --title "$TITU" --backtitle "$BACK" --msgbox "$INC1\n$COR1" 8 60
   
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   
   #PERGUNTA 2
      
      $DIALOG                                       \
      --title "$TITU"                               \
      --backtitle "$BACK"                           \
      --nocancel                                    \
      --radiolist                                   \
      "Pergunta 2"                                  \
      0 0 0                                         \
      R1 'Resposta 1'     off                       \
      R2 'Resposta 2'     off                       \
      R3 'Resposta 3'     off                       \
      R4 'Resposta 4'     off                       \
      R5 'Resposta 5'     off 2>/tmp/P2
      
   resp2=`cat /tmp/P2`
      
   if [ "$resp2" != R1 ] # VERIFICA SE A QUESTÃO ESTA CORRETA OU NÃO
   then
      #GRAVA AS VARIÁVEIS CASO RESPOSTA DIFERENDE DE R1
      
      INC2='A RESPOSTA DA P2 EH...'
      COR2='VC ERROU!'
      
   else
      #GRAVA AS VARIÁVEIS CASO RESPOSTA IGUAL A R1
      
      INC2='VC ACERTOU!'
      COR2='PERGUNTA 2'
      
   fi
      
   $DIALOG --title "$TITU" --backtitle "$BACK" --msgbox "$INC2\n$COR2" 8 60
   
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PROXIMA=resultado
else
PROXIMA=2
fi
                                                     ;;

#-------------------------------------------------------------------------------------------------------------------------------

   
   resultado)
   PROXIMA=2
   $DIALOG                                       \
   --backtitle "$BACK"                           \
   --title "$TITU"                               \
   --yesno                                       \
"PRONTO PARA VER O RESULTADO DA CAGADA?"              \
0 0 
 
valret=$?
if [ "$valret" == 0 ]
then
   $DIALOG                                       \
   --backtitle "$BACK"                           \
   --title "$TITU"                               \
   --msgbox                                      \
   "Corretas                                Incorretas \n
   $COR1                                    $INC1 \n
   $COR2                                    $INC2 \n
   $COR3                                    $INC3 \n
   $COR4                                    $INC4 \n
   $COR5                                    $INC5 \n"             \
   0 0
else
PROXIMA=2
fi
                                                 ;;

#-------------------------------------------------------------------------------------------------------------------------------

################################################################################################################################
################################################################################################################################

#Calculadora Simples


   Ca)

   $DIALOG                                       \
   --title "Calculator"                          \
        --ok-label "RESULTADO"                        \
        --cancel-label "VOLTAR"                       \
   --backtitle "$BACK"                           \
   --inputbox                                    \
   "Calcula no formato 1+1" 8 25 2>$calc
if [ "$?" != 1 ]
then
resu=`cat $calc`

        $DIALOG                                       \
        --title "Resultado"                           \
        --backtitle "$BACK"                           \
        --msgbox $((resu)) 0 0

else
PROXIMA=menu_1
fi

                                                     ;;


esac

#-------------------------------------------------------------------------------------------------------------------------------

#rm -f /tmp/resp1
rm -f /tmp/resp2
rm -f /tmp/resp3
rm -f /tmp/resp4
rm -f /tmp/resp5
rm -f /tmp/resp6
rm -f /tmp/resp7
rm -f /tmp/resp8

#-------------------------------------------------------------------------------------------------------------------------------


done

#FIM

Scripts recomendados

Configurando CISCO por Shell Script

Compilação PHP 5.x.x

Salvaguardando configurações

Raiz Quadrada (Square Root) para Bash

Instalação da Multilib no Slackware


  

Comentários
[1] Comentário enviado por knowlink em 11/11/2004 - 14:15h

Cara, só uma idéia, porque tu não coloca as perguntas/respostas em um arquivo separado e carrega ele filtrando as perguntas e tal?
Ficaria mais fácil pra você manter/adicionar/remover as perguntas assim...

[2] Comentário enviado por slack_boy em 19/11/2004 - 11:15h

Gostei da ideia, vamos lah comunidade, vamos ajudar!!!!!!!!!

[3] Comentário enviado por sequelinha em 26/08/2006 - 10:57h

Eh ficou maneira esse script...

[4] Comentário enviado por Armlook em 12/08/2014 - 18:58h

Grande trabalho.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts