1870 |
local filename="${file##*/}" |
local filename="${file##*/}" |
1871 |
local count |
local count |
1872 |
local output |
local output |
1873 |
|
local oldprotected |
1874 |
local i |
local i |
1875 |
|
local x |
1876 |
|
|
1877 |
declare -i count=0 |
# hack; do not honor a global set IFS like '§' |
1878 |
|
local IFS |
1879 |
|
|
1880 |
|
count=0 |
1881 |
|
|
1882 |
# check if there are already protected files |
# check if there are already protected files |
1883 |
for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" | |
for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" | |
1884 |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
1885 |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
sort -t'%' -k3 -k2 | cut -f1 -d'%') |
1886 |
do |
do |
1887 |
count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::") |
count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')" |
1888 |
|
done |
1889 |
|
|
1890 |
|
# dirty hack to convert 0001 -> 1; 0120 -> 120 etc |
1891 |
|
x="${#count}" |
1892 |
|
for (( i=0; i<x; i++ )) |
1893 |
|
do |
1894 |
|
if [[ ${count:${i}:1} != 0 ]] |
1895 |
|
then |
1896 |
|
count="${count:${i}}" |
1897 |
|
break |
1898 |
|
fi |
1899 |
done |
done |
1900 |
(( count ++ )) |
|
1901 |
|
count="$(( ${count}+1 ))" |
1902 |
|
|
1903 |
# fill output up with zeros |
# fill output up with zeros |
1904 |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done |
3261 |
need_busybox_support() |
need_busybox_support() |
3262 |
{ |
{ |
3263 |
local cmd |
local cmd |
3264 |
|
local busybox |
3265 |
cmd="$1" |
cmd="$1" |
3266 |
|
|
3267 |
if [[ -x /bin/busybox ]] |
for busybox in {,/usr}/bin/busybox |
3268 |
then |
do |
3269 |
if [[ $(readlink $(which ${cmd})) = /bin/busybox ]] |
if [[ -x ${busybox} ]] |
3270 |
then |
then |
3271 |
# needs busybox support |
if [[ $(readlink $(which ${cmd})) = ${busybox} ]] |
3272 |
return 0 |
then |
3273 |
|
# needs busybox support |
3274 |
|
return 0 |
3275 |
|
fi |
3276 |
fi |
fi |
3277 |
fi |
done |
3278 |
|
|
3279 |
# no busybox |
# no busybox |
3280 |
return 1 |
return 1 |
3445 |
|
|
3446 |
mprintfeatures() |
mprintfeatures() |
3447 |
{ |
{ |
3448 |
echo "Global features: ${MAGE_FEATURES_GLOBAL[*]}" |
echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}" |
3449 |
echo "Local features: ${MAGE_FEATURES[*]}" |
echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}" |
3450 |
echo "Current features: ${MAGE_FEATURES_CURRENT[*]}" |
echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}" |
3451 |
} |
} |