#!/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