This commit is contained in:
quietsy
2023-09-15 08:26:11 +03:00
parent e18e6900db
commit 3344bc6e2d
+6 -8
View File
@@ -111,12 +111,16 @@ create_lsiown_alias() {
cat <<-'EOF' >/usr/bin/lsiown
#!/bin/bash
MAXDEPTH=("-maxdepth" "0")
OPTIONS=()
while getopts RcfvhHLP OPTION
do
if [[ "${OPTION}" != "?" ]]; then
if [[ "${OPTION}" != "?" && "${OPTION}" != "R" ]]; then
OPTIONS+=("-${OPTION}")
fi
if [[ "${OPTION}" = "R" ]]; then
MAXDEPTH=()
fi
done
shift $((OPTIND - 1))
@@ -129,13 +133,7 @@ create_lsiown_alias() {
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}")
if [[ "${OPTIONS[*]}" =~ "-R" ]]; then
OPTIONS=( "${OPTIONS[@]/-R/-P}" )
/usr/bin/find "${PATH[@]}" \( ! -group "${GROUP}" -o ! -user "${USER}" \) -exec chown "${OPTIONS[@]}" "${USER}":"${GROUP}" {} + || printf "${ERROR}"
else
/usr/bin/find "${PATH[@]}" -maxdepth 0 \( ! -group "${GROUP}" -o ! -user "${USER}" \) -exec chown "${OPTIONS[@]}" "${USER}":"${GROUP}" {} + || printf "${ERROR}"
fi
/usr/bin/find "${PATH[@]}" "${MAXDEPTH[@]}" \( ! -group "${GROUP}" -o ! -user "${USER}" \) -exec chown "${OPTIONS[@]}" "${USER}":"${GROUP}" {} + || printf "${ERROR}"
EOF
chmod +x /usr/bin/lsiown
}