Domanda Aggiornamento automatico con uno script in Bash

Stato
Discussione chiusa ad ulteriori risposte.

f3b995

Utente Silver
27 Febbraio 2015
86
13
5
50
Ultima modifica:
Finito il mio primo script! Mi son divertito nel farlo, per chi è esperto sarà una cagata, ma senza aver professori c'ho sbattuto la testa!
Google non è sempre nostro amico!
V3.1-2
CIAO! ;)
Bash:
#!/bin/bash

# Questo script aggiorna il sistema in automatico, chiedendo se si preferisce spegnere o riavviare il sistema al termine del processo
# code by Feb v 3.1-2

if [ $(id -u) -ne 0 ]; then
       echo -e '\E[1;31m'"This script needs root permissions!"; tput sgr0
       exit 1
fi

sleep 1
echo ""
echo -e '\E[1;36m'"                              Coded by Feb"; tput sgr0
sleep 1
echo -e '\E[1;35m'"                                 V 3.1-2"; tput sgr0
sleep 1
echo ""

 echo "Do you want to shut down or reboot the system when the process is finished?"
 echo "1. To Shut down"
 echo "2. To reboot"
 echo "3. To cancel"
 echo -n "Please choose [1,2 or 3]? "

read risposta

if [ $risposta -eq 1 ] ; then
                                                      # SHUTDOWN

# Introduzione
echo ""
echo -e '\E[1;32m'"                                    SHUTDOWN"; tput sgr0
echo ""
sleep 1

# Inizio l'update
echo -e '\E[1;32m'"Updating.."; tput sgr0
   echo ""
      sleep 1
          sudo apt-get update
                echo ""
echo -e '\E[1;32m'"Update completed!"; tput sgr0

sleep 1

echo ""

sleep 2

# Inizio ad aggiornare il sistema
echo -e '\E[1;32m'"Upgrading.."; tput sgr0
    echo ""
       sleep 1
           sudo apt-get upgrade -y
                 echo ""
echo -e '\E[1;32m'"Upgrade completed!"; tput sgr0

sleep 1

echo ""

sleep 2

# Inizio ad aggiornare la distribuzione
echo -e '\E[1;32m'"Upgrading dist..."; tput sgr0
   echo ""
      sleep 1
          sudo apt-get dist-upgrade -y
                             echo ""
echo -e '\E[1;32m'"Upgrade dist completed!"; tput sgr0

echo ""
sleep 2

# Rimuovo i pacchetti vecchi che non servono più
echo -e '\E[1;32m'"Removing the old packages"; tput sgr0
   echo ""
      sleep 1
          sudo apt-get autoremove -y
             echo ""
                sleep 1
echo -e '\E[1;36m'"FINISH! :)"; tput sgr0
sleep 2

echo -e '\E[1;31m'"***********************!!!ALLERT!!!***********************"; tput sgr0

sleep 1

# Avverto che il pc verrà spento
echo -e '\E[1;32m'"The system will be shutdown in a few seconds!"; tput sgr0
echo ""

sleep 1
echo "10"
sleep 1
echo "9"
sleep 1
echo "8"
sleep 1
echo "7"
sleep 1
echo "6"
sleep 1
echo "5"
sleep 1
echo "4"
sleep 1
echo "3"
sleep 1
echo "2"
sleep 1
echo "1"
sleep 1
echo ""

# Saluto (gesto di cortesia)
echo -e '\E[1;33m'"BYE BYE :D"; tput sgr0

shutdown -h now

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

else                  
        if [ $risposta -eq 2 ] ; then
                                                      # REBOOT

# Introduzione
echo ""
echo -e '\E[1;32m'"                                      REBOOT"; tput sgr0
echo ""
sleep 1

# Inizio l'update
echo -e '\E[1;32m'"Updating.."; tput sgr0
   echo ""
      sleep 1
          sudo apt-get update
                echo ""
echo -e '\E[1;32m'"Update completed!"; tput sgr0

sleep 1

echo ""

sleep 2

# Inizio ad aggiornare il sistema
echo -e '\E[1;32m'"Upgrading.."; tput sgr0
    echo ""
       sleep 1
           sudo apt-get upgrade -y
                 echo ""
echo -e '\E[1;32m'"Upgrade completed!"; tput sgr0

sleep 1

echo ""

sleep 2

# Inizio ad aggiornare la distribuzione
echo -e '\E[1;32m'"Upgrading dist..."; tput sgr0
   echo ""
      sleep 1
          sudo apt-get dist-upgrade -y
                             echo ""
echo -e '\E[1;32m'"Upgrade dist completed!"; tput sgr0

echo ""
sleep 2

# Rimuovo i pacchetti vecchi che non servono più
echo -e '\E[1;32m'"Removing the old packages"; tput sgr0
   echo ""
      sleep 1
          sudo apt-get autoremove -y
             echo ""
                sleep 1
echo -e '\E[1;36m'"FINISH! :)"; tput sgr0
sleep 2

echo -e '\E[1;31m'"***********************!!!ALLERT!!!***********************"; tput sgr0

sleep 1

# Avverto che il pc verrà riavviato
echo -e '\E[1;31m'"The system will be reboot in a few seconds!"; tput sgr0
echo ""

sleep 1
echo "10"
sleep 1
echo "9"
sleep 1
echo "8"
sleep 1
echo "7"
sleep 1
echo "6"
sleep 1
echo "5"
sleep 1
echo "4"
sleep 1
echo "3"
sleep 1
echo "2"
sleep 1
echo "1"
sleep 1
echo ""

# Saluto (gesto di cortesia)
echo -e '\E[1;33m'"SEE YOU AFTER! :D"; tput sgr0

shutdown -r now

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

                                                        #ANNULLA

else
                if [ $risposta -eq 3 ]; then
                  clear
                       echo -e '\E[1;31m'"Now tell me why you launched this script and after you deleted it?!?! o.O" ; tput sgr0
                           exit
                fi
        fi
fi
 
madonna che rompi palle... visto che lo sto studiando mi sono messo a fare qualcosa di semplice.. dato che mi è riuscito "bene" volevo condividerlo..
ma visto che giudicate ogni cosa lascio pure perdere..
 
madonna che rompi palle... visto che lo sto studiando mi sono messo a fare qualcosa di semplice.. dato che mi è riuscito "bene" volevo condividerlo..
ma visto che giudicate ogni cosa lascio pure perdere..
Tranquillo non sono tutti così. Certa gente ha studiato mto e ha molta esperienza e per questo si crede superiore e se una cosa non è fatta perfettamente hanno da ridire.
 
E infatti non fanno tutti così :\
Comunque, carino lo script! Cosa differisce tra la versione ultimata e questa?
:)
Non cambia molto, ho sistemato i colori e cambiato alcune robine, prima mi dava un errore di sintassi, ora capito il motivo è l'ho riaggiornato, è comodissimo!

Inviata da FEVER tramite app ufficiale di Inforge.net
 
Tranquillo non sono tutti così. Certa gente ha studiato mto e ha molta esperienza e per questo si crede superiore e se una cosa non è fatta perfettamente hanno da ridire.
Immagino.. dai dai che ho fatto altri lavorino per conto mio e stanno riuscendo bene! Alla fine sono Delle utility che evitano di perder tempo, insomma lanci lo script e fa tutto lui, crack wifi, update, settare il governo della CPU, eliminare file spazzatura, ripulire la cache e di conseguenza la RAM, ecc ecc :)

Inviata da FEVER tramite app ufficiale di Inforge.net
 
Stato
Discussione chiusa ad ulteriori risposte.