Created
February 24, 2023 19:45
-
-
Save carlosmgv02/5f6228e7ec4402479bdca5601263e7a0 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 | |
# Author: Carlos Martínez García-Villarrubia (carlos.martinezg@estudiants.urv.cat) | |
date=$(date +"%Y-%m-%d %H:%M:%S") | |
if [ $# -gt 0 ]; then | |
for paquet in "$@" | |
do | |
# Comprovo si el paquet ja està instal·lat | |
if apt list --installed | grep -w "$paquet" >/dev/null 2>&1; then | |
update_info=$(apt list --upgradable | grep -w $paquet | awk -F/ '{print $1}') | |
# Si està instal·lat, comprovo si té una nova versió disponible | |
if [ -n "$update_info" ]; then | |
# Si té una nova versió disponible, la mostro pel logger | |
logger "$date $paquet té una nova versió disponible: $update_info" | |
fi | |
else | |
# Si no està instal·lat, mostro per pantalla que no està instal·lat | |
echo "$date $paquet no està instal·lat." | |
fi | |
done | |
else | |
echo "No s'ha passat cap argument com a paràmetre." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment