==== Download HP Bios ===== {{ :home-harmening:scripts:shell:sync_hpbios.png?400|}} Ich habe mal ein lokales Repository für BIOS Updates für HP Computer benötigt. Hier das Skript welches die BIOS Versionen und die nötige XML Datei herunterlädt um das \\ Repo aufzubauen. Die Dateien müssen nach nur noch über einen Webserver zur Verfügung gestellt werden. \\ \\ \\ Das Skript lädt nur Dateien herunter die noch nicht vorhanden sind. Zuvor werden alle Dateien entfernt deren md5 Prüfsumme nicht in der bereitgestelltn xml Datei von HP vorhanden sind. #!/bin/bash # Skript syncronisiert den HP Bios Ordner für eine Bestimmte ID str_hpserver="ftp.hp.com/pub/pcbios" RED="\e[31m" GREEN="\e[32m" YELLOW="\e[33m" NC="\e[0m" str_id=$1 if [ -z $str_id ]; then echo "Ich brauche eine ID wie z.B. 81C7"; exit 1; fi str_path=$2 if [ -z $str_path ]; then echo "Ich brauche eine Pfad wo die Dateien gespeichert werden wie z.B. /var/www/html/bios"; exit 1; fi # Installiere xmlstarlet if ! dpkg --list | grep xmlstarlet &> /dev/null; then apt-get install -y xmlstarlet; fi # Download XML Datei if [ -f ${str_path}/${str_id} ]; then rm ${str_path}/${str_id}; fi printf "$YELLOW Download XML File ${str_hpserver}/${str_id}/${str_id}.xml\n $NC" wget -q --show-progress ${str_hpserver}/${str_id}/${str_id}.xml -O ${str_path}/${str_id}.xml echo # Erstelle eine Liste der MD5 Summen aus der XML Datei list_hpbios_md5=$(xmlstarlet pyx ${str_path}/${str_id}.xml | grep AMd5 | awk '{print $2}') # Erstelle eine Liste der BIOS Dateien aus der XML Datei list_hpbios_files=$(xmlstarlet pyx ${str_path}/${str_id}.xml | grep ABin | awk '{print $2}') int_hpbios_files=$(echo ${list_hpbios_files} | wc -w) # Erstelle eine Liste der lokalen BIOS Dateien list_lobios_files=$(ls ${str_path}/*.bin) # Entferne alle lokale BIOS Dateien derer MD5 Summe nicht in der XML Datei steht printf "$YELLOW Prüfe md5 Summen der vorhandenen BIOS Dateien\n $NC" for str_lobios_file in ${list_lobios_files}; do if ! echo ${list_hpbios_md5} | grep -i $(md5sum ${str_lobios_file} | awk '{print $1}') &> /dev/null ; then printf "$RED Lösche Datei ${str_lobios_file}\n $NC" ; rm ${str_lobios_file}; fi done echo # Lade jede BIOS Datei aus der Liste herunter printf "$YELLOW Download BIOS\n $NC" i=0 for str_bios_file in ${list_hpbios_files}; do i=$((i+1)) if [ -f ${str_path}/${str_bios_file} ]; then continue else printf "$YELLOW Download file ${i} ... ${int_hpbios_files}$NC" printf "$GREEN" wget -q --show-progress ${str_hpserver}/${str_id}/${str_bios_file} -O ${str_path}/${str_bios_file} printf "$NC" fi done