Created
September 4, 2020 10:03
-
-
Save ChatchaiJ/0087e0bfc28fe2e05f2c56c2473c1b21 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 | |
[ "`id -u`" != 0 ] && echo "Must be root to run this script" && exit -1 | |
[ -z "$2" -o "$3" ] && echo "Usage: $0 user directory" && exit -1 | |
USER="$1" | |
DIR="$2" | |
id "$USER" >& /dev/null || { | |
echo "User '$USER' not exist"; | |
exit -1; | |
} | |
[ ! -d "$DIR" ] && echo "Directory '$DIR' not exist" && exit -1 | |
sudo -u "$USER" test -d "${DIR}/." | |
if [ "$?" != 0 ]; then | |
echo "FAILED: $USER -> $DIR" | |
exit 1 | |
else | |
echo "OK: $USER -> $DIR" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment