#!/bin/bash DEST="$1" SORCE="$2" log="$3" exec 2>"./0diff.log" function set_local () { #use local settings if run on its own #................................................................................................ log="./Log" export HOMEDIR="`pwd`" export TOOLSDIR="$HOMEDIR/tools" export TAR="$TOOLSDIR/tar" export OEMLIST="avme avm aol 1und1 freenet tcom all constar" export avm_Lang="en" export avm_Lang="de" export VERBOSE="-v" OEM="avme" OEM="all" OEM="avm" SORCE="./FBDIR" DEST="./FBDIR2" #DEST="./speed-to-fritz/FBDIR" echo echo echo "ATTENTION: This skript is invoked without parameters!" echo echo sleep 1 #................................................................................................ } # without parameter set parameters localy [ $# -lt 1 ] && set_local rm -fr ${log} mkdir ${log} echo "Compare of Firmwares, difference is logged to: ${log}" echo echo echo "Source one: ${DEST}" echo "Source two: ${SORCE}" sleep 1 CONFIG_PRODUKT=`ls -d "${DEST}"/squashfs-root/etc/default.F*` CONFIG_PRODUKT=${CONFIG_PRODUKT##*.} SORCE_PRODUKT=`ls -d "${SORCE}"/squashfs-root/etc/default.F*` SORCE_PRODUKT=${SORCE_PRODUKT##*.} echo "SOURCE PRODUKT: ${SORCE_PRODUKT}" echo "DEST PRODUKT: ${CONFIG_PRODUKT}" echo "Will take a minute to copy and to make the compare ..." # $1 = Directoryname # $2 = Filename function rmvTabFromFile () { if [ -f "${1}/${2}" ]; then echo "File: ${1}/${2}" sed -i -e 's|^[\x09]*||g' ${1}/${2} sed -i -e 's|^[\x20]*||g' ${1}/${2} fi } # $1 = Directoryname function rmvTabFromFiles () { if [ -d "${1}" ]; then for FILE in `ls ${1}`; do rmvTabFromFile ${1} "${FILE##*/}" done fi } # $1 = Directoryname of Directorys function rmvTabDir () { for dir in `ls -d "${1}"/* `; do DIR="$(basename "$dir" | sed -r 's/(.*)\.[^\.]*/\1/')" rmv_tab ${DIR} done } function remtab () { for dir in `ls -d "${XXDIR}"/* `; do DIR="$(basename "$dir" | sed -r 's/(.*)\.[^\.]*/\1/')" if [ -d "${XXDIR}/${DIR}" ]; then for FILE in `ls ${XXDIR}/${DIR}`; do HFILE="${FILE##*/}" HFILE="${FILE}" if [ -f "${XXDIR}/${DIR}/${HFILE}" ]; then echo "File: ${XXDIR}/${DIR}/${HFILE}" sed -i -e 's|^[\x09]*||g' ${XXDIR}/${DIR}/${HFILE} sed -i -e 's|^[\x20]*||g' ${XXDIR}/${DIR}/${HFILE} sed -i -e 's|[\x0D]||g' ${XXDIR}/${DIR}/${HFILE} fi done fi #/[\x09\x20]{2}/ done } function comparedir () { #for DIR in modules init.d html fon fon2 fon_dect fon_dect2 fon_dev fon_tamlist.2 dect first fon_config home help internet menus system tools wlan; do if [ -d "${SORCE}${XDIR}" ] && [ -d "${DEST}${XDIR2}" ]; then for dir in `ls -d -R "${SORCE}/${XDIR}"/* `; do DIR="$(basename "$dir" | sed -r 's/(.*)\.[^\.]*/\1/')" if [ -d "${SORCE}${XDIR}/${DIR}" ] && [ -d "${DEST}${XDIR2}/${DIR}" ]; then echo "Directory: ${XDIR}/${DIR}" if ! [ -d "${log}/${DIR}" ]; then #sleep 0 mkdir -p ${log}/${DIR} fi for FILE in `ls ${SORCE}${XDIR}/${DIR}`; do HFILE="${FILE##*/}" # sed -i -e 's|^[\x0D]*||g' ${SORCE}${XDIR}/${DIR}/${HFILE} diff -Naur -E -b -w ${SORCE}${XDIR}/${DIR}/${HFILE} ${DEST}${XDIR2}/${DIR}/${HFILE} > ${log}/${DIR}/${HFILE} if ! [ -s "${log}/${DIR}/${HFILE}" ]; then rm ${log}/${DIR}/${HFILE} fi done fi done else echo "Source two was not specified!" fi } function comparedir2 () { #for DIR in modules init.d html fon fon2 fon_dect fon_dect2 fon_dev fon_tamlist.2 dect first fon_config home help internet menus system tools wlan; do if [ -d "${SORCE}${XDIR}" ] && [ -d "${DEST}${XDIR2}" ]; then for dir in `ls -d "${SORCE}/${XDIR}"/* `; do DIR="$(basename "$dir" | sed -r 's/(.*)\.[^\.]*/\1/')" if [ -d "${SORCE}${XDIR}/${DIR}" ] && [ -d "${DEST}${XDIR2}/${DIR}" ]; then echo "Directory: ${XDIR}/${DIR}" if ! [ -d "${log}/${DIR}" ]; then mkdir -p ${log}/${DIR} fi HFILE="${DIR}" diff -Naur ${SORCE}${XDIR}/${DIR} ${DEST}${XDIR2}/${DIR} > ${log}/${DIR}/${HFILE} sed -i -e "s|1969-12-31|2008-01-01|g" ${log}/${DIR}/${HFILE} sed -i -e "s|${SORCE}${XDIR}/||g" ${log}/${DIR}/${HFILE} sed -i -e "s|${DEST}${XDIR}/||g" ${log}/${DIR}/${HFILE} sed -i -e "/diff/d" ${log}/${DIR}/${HFILE} if ! [ -s "${log}/${DIR}/${HFILE}" ]; then rm ${log}/${DIR}/${HFILE} fi fi done else echo "Source two was not specified!" fi } if [ "$OEM" = "avme" ] ; then HTML="$OEM/$avm_Lang/html" else HTML="$OEM/html" fi #XDIR="/squashfs-root/usr/www/avm/html" #XDIR2="$XDIR" #comparedir2 #sleep 5 #exit 0 XDIR="/squashfs-root" XDIR2="$XDIR" comparedir2 #sleep 5 exit 0 XDIR="/squashfs-root/usr/www/${HTML}" XDIR2="$XDIR" comparedir2 sleep 5 exit 0 SORCE="./tmp" rm -fr "${SORCE}" mkdir -p "${SORCE}" DEST="./FBDIR" cp -fdpr "./FBDIR/squashfs-root" --target-directory="${SORCE}" exec 2>"./0errlog" export AVM_V_MINOR="50" #./add_dect_labor "${SORCE}" "" "${OEMLIST}" ./patch_fc "${SORCE}/squashfs-root"