Created
April 5, 2024 21:46
-
-
Save gmolveau/e2f07ef9a652ea2c5699826f6cb1b536 to your computer and use it in GitHub Desktop.
linuxserver.io lsiown script (extracted with `docker run --rm -it ghcr.io/linuxserver/baseimage-ubuntu:jammy cat /usr/bin/lsiown`)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
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[@]}" \( ! -group "${GROUP}" -o ! -user "${USER}" \) -exec chown "${OPTIONS[@]}" "${USER}":"${GROUP}" {} + || printf "${ERROR}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment