Last active
June 17, 2020 15:03
-
-
Save lupa18/de7fd5f97903b4100485a8b56055d6a4 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Script de actualización | |
########################################### | |
# Variables | |
########################################### | |
carpetausu="$HOME" | |
registroviejo="$carpetausu"/actualizacion.log | |
registro="$carpetausu"/.actualizacion.log | |
if [ -f /usr/lib/update-notifier/apt-check ]; then | |
infoextra=$(/usr/lib/update-notifier/apt-check --human-readable) | |
else | |
infoextra="" | |
fi | |
########################################### | |
# Muevo el registro si existe | |
########################################### | |
if [ -f "$registroviejo" ]; then | |
mv "$registroviejo" "$registro" | |
fi | |
########################################### | |
# Muestro la última actualización | |
########################################### | |
# Verifico si existe el registro | |
if [ ! -f "$registro" ]; then | |
lastact="No disponible" | |
touch "$registro" | |
echo "Inicio el registro" >> "$registro" | |
else | |
lastact=$(tail -n 1 "$registro") | |
fi | |
########################################### | |
# Informo de la última actualización | |
echo "----------------------------------------" | |
echo -e "\nÚltima actualización: $lastact \n" | |
echo "$infoextra" | |
echo "----------------------------------------" | |
# esperamos a ver si seguimos o no, por defecto sí | |
read -p "Desea continuar (S/n): " -i s -e seguimos | |
if [ "$seguimos" = "s" ]; then | |
echo ------------------------------- | |
echo Actualizo la lista de paquetes | |
echo ------------------------------- | |
sudo apt-get update | |
echo ------------------------------- | |
echo Aplico la actualicación | |
echo ------------------------------- | |
sudo apt-get -y dist-upgrade | |
# Controlo si hubo error y termino en ese caso | |
if [[ $? -gt 0 ]]; then | |
echo "" | |
echo ------------------------------- | |
echo Error al actualizar, se sale | |
echo ------------------------------- | |
exit | |
fi | |
# Registro la actualizacion | |
echo "$(date +%d)-$(date +%m)-$(date +%Y)" >> "$registro" | |
# Limpio los paquetes que no se usan más | |
sudo apt-get autoremove | |
# Doy información del estado del sistema | |
echo -------------------------------- | |
echo Reviso la partición boot: | |
df -h | grep boot | |
echo -------------------------------- | |
echo Estos son los núcelos instalados: | |
dpkg -l linux-image* | grep ii | |
echo -------------------------------- | |
echo presione una tecla para continuar | |
read pause | |
echo -------------------------------- | |
echo Archivo de registro guardado en: "$registro" | |
# preguntar por rebooteo | |
if [ -f /var/run/reboot-required ] | |
then | |
echo -------------------------------------------- | |
echo !! El sistema indica que es necesario reiniciar | |
echo -------------------------------------------- | |
while true; do | |
read -p "Está de acuerdo con agendar reiniciado para la 5:20 am? (s/n) " sino | |
case $sino in | |
[Ss]* ) sudo shutdown -r 5:20 ; break;; | |
[Nn]* ) echo "No se reiniciará" ; break;; | |
* ) echo "Responda (S)i o (N)o.";; | |
esac | |
done | |
else | |
echo No es necesario reiniciar el sistema | |
fi | |
else # no se quiso hace la actualizacion | |
echo No se actualiza | |
exit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment