--- trunk/mage/usr/lib/mage/mage4.functions.sh 2007/06/30 15:38:50 501 +++ trunk/mage/usr/lib/mage/mage4.functions.sh 2007/11/05 19:36:36 603 @@ -1,6 +1,6 @@ #!/bin/bash # Magellan Linux Installer Functions (mage.functions.sh) -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.33 2007-06-30 15:38:50 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.34 2007-11-05 19:34:36 niro Exp $ mage_setup() { @@ -1430,7 +1430,29 @@ ################################################### count_protected_files() { - ${MLIBDIR}/writeprotected "$1" + local file="$1" + local dirname="${file%/*}" + local filename="${file##*/}" + local count + local output + local i + + declare -i count=0 + + # check if there are already protected files + for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | + sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | + sort -t'%' -k3 -k2 | cut -f1 -d'%') + do + count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") + done + (( count ++ )) + + # fill output up with zeros + for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done + output="${output}${count}" + + echo "${output}" } # call with