Skip to content

Instantly share code, notes, and snippets.

@dzogrim
Created September 18, 2024 08:53
Show Gist options
  • Save dzogrim/417cc64e66e2c08befb3e1010cbcc2be to your computer and use it in GitHub Desktop.
Save dzogrim/417cc64e66e2c08befb3e1010cbcc2be to your computer and use it in GitHub Desktop.
Performs a series of checks and logs system information related to security and system configuration. It retrieves the system’s serial number and logs various outputs, including systemd PCR logs, BIOS information, and EFI boot settings to a specific mount point.
#!/bin/sh
for cmd in dmidecode systemd-pcrlock efibootmgr; do
if ! which "$cmd" > /dev/null 2>&1; then
echo "Erreur : La commande $cmd n'est pas installée ou n'est pas disponible dans PATH."
exit 1
fi
done
SERIAL=$( sudo dmidecode -s system-serial-number )
if [ -z "$SERIAL" ]; then
echo "Erreur : Impossible de récupérer le numéro de série."
exit 1
fi
TIMESTAMP=$( date +"%Y-%m-%d_%H-%M" )
MOUNTPOINT="/run/media/my_device/Installers"
if [ ! -d "$MOUNTPOINT" ]; then
echo "Erreur : Le point de montage $MOUNTPOINT n'existe pas."
exit 2
fi
sudo systemd-pcrlock cel > "$MOUNTPOINT/${SERIAL}_$TIMESTAMP.json"
if [ $? -ne 0 ]; then
echo "Erreur : Échec de l'exécution de systemd-pcrlock cel."
fi
sudo systemd-pcrlock log --no-pager > "$MOUNTPOINT/${SERIAL}_$TIMESTAMP.raw.log" 2> "$MOUNTPOINT/${SERIAL}_$TIMESTAMP.stderr.log"
if [ $? -ne 0 ]; then
echo "Erreur : Échec de l'exécution de systemd-pcrlock log."
fi
sudo dmidecode -t bios > "$MOUNTPOINT/${SERIAL}_$TIMESTAMP.bios.txt"
if [ $? -ne 0 ]; then
echo "Erreur : Échec de l'exécution de dmidecode."
fi
sudo efibootmgr > "$MOUNTPOINT/${SERIAL}_$TIMESTAMP.efiboot.txt"
if [ $? -ne 0 ]; then
echo "Erreur : Échec de l'exécution de efibootmgr."
fi
echo "Les fichiers ont été créés avec succès dans $MOUNTPOINT."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment