mirror of
https://github.com/linuxserver/docker-mods.git
synced 2026-01-20 12:21:59 +08:00
31 lines
945 B
Bash
Executable File
31 lines
945 B
Bash
Executable File
#!/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}"
|