From 84d9032606f2440041dc79bbf805f03fabe61ae0 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Sat, 20 Jul 2019 20:50:50 -0300 Subject: AK3: add file/directory attributes functions - from my "Complete Shell Script Flashable Zip Replacement" reference thread: https://forum.xda-developers.com/android/software-hacking/dev-complete-shell-script-flashable-zip-t2934449 --- tools/ak3-core.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/ak3-core.sh b/tools/ak3-core.sh index ac04275..4268992 100755 --- a/tools/ak3-core.sh +++ b/tools/ak3-core.sh @@ -37,6 +37,30 @@ file_getprop() { } ### +### file/directory attributes functions: +# set_perm [ ...] +set_perm() { + local uid gid mod; + uid=$1; gid=$2; mod=$3; + shift 3; + chown $uid:$gid "$@" || chown $uid.$gid "$@"; + chmod $mod "$@"; +} + +# set_perm_recursive [ ...] +set_perm_recursive() { + local uid gid dmod fmod; + uid=$1; gid=$2; dmod=$3; fmod=$4; + shift 4; + while [ "$1" ]; do + chown -R $uid:$gid "$1" || chown -R $uid.$gid "$1"; + find "$1" -type d -exec chmod $dmod {} +; + find "$1" -type f -exec chmod $fmod {} +; + shift; + done; +} +### + ### dump_boot functions: # split_boot (dump and split image only) split_boot() { -- cgit v1.2.3