diff --git a/lsiown.v1 b/lsiown.v1 new file mode 100755 index 0000000..3814739 --- /dev/null +++ b/lsiown.v1 @@ -0,0 +1,30 @@ +#!/bin/bash + +# Version 1 +# 2024-06-08 - Initial Version + +LSIOWN_SCRIPT_VER="1.20240608" + +MAXDEPTH=("-maxdepth" "0") +OPTIONS=() +while getopts RcfvhHLP OPTION +do + if [[ "${OPTION}" != "?" && "${OPTION}" != "R" ]]; then + OPTIONS+=("-${OPTION}") + fi + if [[ "${OPTION}" = "R" ]]; then + MAXDEPTH=() + fi +done + +shift $((OPTIND - 1)) +OWNER=$1 +IFS=: read -r USER GROUP <<< "${OWNER}" +if [[ -z "${GROUP}" ]]; then + printf '**** Permissions could not be set. Group is missing or incorrect, expecting user:group. ****\n' + exit 0 +fi + +ERROR='**** Permissions could not be set. This is probably because your volume mounts are remote or read-only. ****\n**** The app may not work properly and we will not provide support for it. ****\n' +PATH=("${@:2}") +/usr/bin/find "${PATH[@]}" "${MAXDEPTH[@]}" ! -xtype l \( ! -group "${GROUP}" -o ! -user "${USER}" \) -exec chown "${OPTIONS[@]}" "${USER}":"${GROUP}" {} + || printf "${ERROR}"