From 7a2394b403f451a402f82c5c0c60f4d9172e0485 Mon Sep 17 00:00:00 2001 From: thespad Date: Sat, 8 Jun 2024 21:01:10 +0100 Subject: [PATCH] Move lsiown into its own package --- lsiown.v1 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 lsiown.v1 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}"