Skip to content

Instantly share code, notes, and snippets.

@ljm42
Last active March 21, 2021 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljm42/d612bcfbc071d854baba53c482fd64e4 to your computer and use it in GitHub Desktop.
Save ljm42/d612bcfbc071d854baba53c482fd64e4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# version 1.5
# latest version of this script: https://gist.github.com/ljm42/d612bcfbc071d854baba53c482fd64e4
# see also https://forums.unraid.net/topic/103886-permissions-on-files-installed-by-plugins/
#
# run this script to check for file ownership and permission problems on Unraid plugin txz files
#
# to use:
# * cd /tmp
# * wget https://gist.github.com/ljm42/d612bcfbc071d854baba53c482fd64e4/raw -O plgcheck
# * bash plgcheck
i=1
for f in $(find /boot/config/plugins -name '*.txz' -o -name '*.tar.gz' -o -name '*.tgz' | sort -f); do
# skip precompiled packages
# only precompiled packages should be in these directories, not the plugin's main txz file
[[ $f =~ /NerdPack\/packages/ ]] && continue
[[ $f =~ /DevPack\/packages/ ]] && continue
[[ $f =~ /nvidia-driver\/packages/ ]] && continue
[[ $f =~ /dvb-driver\/packages/ ]] && continue
[[ $f =~ /mft-tools\/packages/ ]] && continue
[[ $f =~ /iscsi\/packages/ ]] && continue
[[ $f =~ /Unraid-Kernel-Helper\/packages/ ]] && continue
[[ $f =~ /nct6687-driver\/packages/ ]] && continue
[[ $f =~ /coral-driver\/packages/ ]] && continue
[[ $f =~ /hpsahba\/packages/ ]] && continue
echo "$((i++)) $f"
# show ownership issues
OWN="$(less "$f" | grep -v "root/root")"
[[ -n $OWN ]] && echo && echo "Ownership issues (should be root/root)" && echo "${OWN%x}"
# show permissions issues
PERM="$(less "$f" | grep -v "rwxr-xr-x" | grep -v "rw-r--r--")"
[[ -n $PERM ]] && echo && echo "Permission issues (should be rwxr-xr-x or rw-r--r--)" && echo "${PERM%x}"
echo
done
@eschultz
Copy link

Looks good. I was able to skip 100+ txz's by adding an exception for DevPack packages as well:

[[ $f =~ /DevPack\/packages/ ]] && continue

@ljm42
Copy link
Author

ljm42 commented Mar 10, 2021

good idea, thanks!

@dlandon
Copy link

dlandon commented Mar 21, 2021

Please add .tgz files also. I use a zipped bundle and not a package.

@ljm42
Copy link
Author

ljm42 commented Mar 21, 2021

Thanks @dlandon, we're now checking for *.tgz too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment