Created
September 4, 2020 10:03
-
-
Save ChatchaiJ/66e65d839c4827fd1ed8a00acaa36f32 to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
CUAD="/root/bin/can-user-access-dir" # Can this 'user' access this 'directory' | |
[ -z "$1" ] && echo "Usage: $0" && exit | |
USER=$1 | |
### Prepare working space ### | |
T=`mktemp -d --tmpdir=/tmp .XXXXX` | |
trap "rm -rf $T" EXIT | |
## trap "rm -rvf $T" EXIT | |
## echo "Workdir: $T" | |
chmod 777 $T | |
cd $T || { echo "Can't change working directory"; exit; } | |
### Now start working ### | |
id $USER |\ | |
cut -f4 -d= |\ | |
sed -e 's/,/\n/g' |\ | |
grep -v ^513 |\ | |
sed -e 's/[()]/ /g' |\ | |
while read gid name; do | |
[ -z "$gid" -o -z "$name" ] && continue | |
mkdir -m 750 $name | |
chgrp $gid $name | |
$CUAD $USER $name | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment