SaMMyMaster
Elite Lord
- Registriert
- 15. Oktober 2009
- Beiträge
- 3.007
- Lösungen
- 11
- Reaktionspunkte
- 2.667
- Punkte
- 403
Wen man gerne mal genau schauen will, was sich in der neuen inhaus geändert hat. Hier mal ein Script was euch ein diff macht mit den unterschieden
[\spoiler]
Code:
#!/bin/bash
#set -e # Exit immediately if a command exits with a non-zero status.
DIFF_PATH=$(cd "$(dirname "$0")" && pwd)
NAS_PATH="/home/xxxx/yyyy/FritzBox/FritzBox_Firmenware/download.avm.de/inhaus/Smart24P1FCS/5690Pro/" # da liegen alle FW für die 5690Pro
FWDU="/home/xxxx/yyyy/tools/freetz-ng/fw_config_check/tools/fwdu" #Da ist mein freetz-ng zum entpacken der FOS
TYPE="5690_Pro"
OS="07.90"
SPARTE="Inhaus"
# Supported OS versions
SUPPORTED_VERSIONS=("20.04" "21.10" "22.04" "23.04" "23.10" "24.04" "10" "11" "12" "2023.4" "2024.1" "21.3" "17" "7.1")
# Current OS version
OS_VERSION=$(lsb_release -rs)
# Check OS compatibility
if [[ ! " ${SUPPORTED_VERSIONS[@]} " =~ " ${OS_VERSION} " ]]; then
echo "Incompatible version: $OS_VERSION"
exit 1
fi
# Check for required packages
if ! dpkg -l | grep -q "moreutils"; then
echo "Error: moreutils package is not installed. Please install it before running the script."
exit 1
fi
# Check if NAS_PATH exists
if [ ! -d "$NAS_PATH" ]; then
echo "Error: NAS_PATH does not exist."
exit 1
fi
# Automatically find the latest and previous firmware images
ALT=$(ls -1 "$NAS_PATH" | grep "FRITZ.Box_${TYPE}-${OS}-" | grep "${SPARTE}" | sort | tail -n 2 | head -n 1 | sed 's/.*-\(.*\)-.*/\1/')
NEU=$(ls -1 "$NAS_PATH" | grep "FRITZ.Box_${TYPE}-${OS}-" | grep "${SPARTE}" | sort | tail -n 1 | sed 's/.*-\(.*\)-.*/\1/')
# Check if firmware images are found
if [[ -z "$ALT" || -z "$NEU" ]]; then
echo "Error: Could not find required firmware images."
exit 1
fi
# Copy firmware images
echo "Copying firmware images..."
cp -ar "$NAS_PATH/FRITZ.Box_${TYPE}-${OS}-${ALT}-${SPARTE}.image" "${DIFF_PATH}" || { echo "Failed to copy ${ALT}"; exit 1; }
cp -ar "$NAS_PATH/FRITZ.Box_${TYPE}-${OS}-${NEU}-${SPARTE}.image" "${DIFF_PATH}" || { echo "Failed to copy ${NEU}"; exit 1; }
# Unpack firmware
echo "Unpacking firmware images..."
$FWDU unpack "FRITZ.Box_${TYPE}-${OS}-${ALT}-${SPARTE}.image"
$FWDU unpack "FRITZ.Box_${TYPE}-${OS}-${NEU}-${SPARTE}.image"
# Create patch directory
mkdir -p "${DIFF_PATH}/patche"
# Generate diff
echo "Generating patch..."
diff -durN --no-dereference "${DIFF_PATH}/FRITZ.Box_${TYPE}-${OS}-${ALT}-${SPARTE}/" "${DIFF_PATH}/FRITZ.Box_${TYPE}-${OS}-${NEU}-${SPARTE}/" > "${DIFF_PATH}/patche/${TYPE}_${OS}_${ALT}_${NEU}_${SPARTE}.patch"
# Clean up patch file
sed -i "s+${DIFF_PATH}/++g" "${DIFF_PATH}/patche/${TYPE}_${OS}_${ALT}_${NEU}_${SPARTE}.patch"
grep -v "diff -durN" "${DIFF_PATH}/patche/${TYPE}_${OS}_${ALT}_${NEU}_${SPARTE}.patch" | sponge "${DIFF_PATH}/patche/${TYPE}_${OS}_${ALT}_${NEU}_${SPARTE}.patch"
# Create zip of the patch
mkdir -p "${DIFF_PATH}/patche/gepackt/${TYPE}"
zip -j "${DIFF_PATH}/patche/gepackt/${TYPE}/${TYPE}_${OS}_${ALT}_${NEU}_${SPARTE}.zip" "${DIFF_PATH}/patche/${TYPE}_${OS}_${ALT}_${NEU}_${SPARTE}.patch"
# Cleanup
echo "Cleaning up..."
rm -rf "${DIFF_PATH}/FRITZ.Box_${TYPE}-${OS}-${ALT}-${SPARTE}" "${DIFF_PATH}/FRITZ.Box_${TYPE}-${OS}-${NEU}-${SPARTE}" \
"${DIFF_PATH}/FRITZ.Box_${TYPE}-${OS}-${ALT}-${SPARTE}.image" "${DIFF_PATH}/FRITZ.Box_${TYPE}-${OS}-${NEU}-${SPARTE}.image"
echo "Process completed successfully."