diff options
author | osm0sis <osm0sis@outlook.com> | 2019-07-20 20:50:50 -0300 |
---|---|---|
committer | osm0sis <osm0sis@outlook.com> | 2019-07-20 20:50:50 -0300 |
commit | 84d9032606f2440041dc79bbf805f03fabe61ae0 (patch) | |
tree | 2732948269b5898cbad1cfac06b9f4cda5d3a43e | |
parent | 559a6082e8beb858ec252d8c69a6a97d4352d462 (diff) |
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
-rwxr-xr-x | tools/ak3-core.sh | 24 |
1 files changed, 24 insertions, 0 deletions
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 <owner> <group> <mode> <file> [<file2> ...] +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 <owner> <group> <dir_mode> <file_mode> <dir> [<dir2> ...] +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() { |