Community Articles
Find and share helpful community-sourced technical articles
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.
Labels (2)
New Contributor

When using post-user-creation-hook.sh script to create home directories for users we can edit the script to set a quota too.

For information on enabling HDFS home dir creation see:

https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.0.3/bk_ambari-administration/content/create_use...

If you want to set a quota on this dir you can edit:

/var/lib/ambari-server/resources/scripts/post-user-creation-hook.sh

# the default implementation creates user home folders; the first argument must be the username
ambari_sudo "yarn jar /var/lib/ambari-server/resources/stacks/HDP/2.0.6/hooks/before-START/files/fast-hdfs-resource.jar $JSON_INPUT"

#ADD THESE LINES

while read -r LINE
do
  USR_NAME=$(echo "$LINE" | awk -F, '{print $1}')

hdfs dfsadmin -setSpaceQuota 10 /user/$USR_NAME > /tmp/posthook.tmp

done <"$CSV_FILE"

#END ADD QUOTA

if [ "$DEBUG" -gt "0" ]; then echo "Switch debug OFF";set -x;unset DEBUG; else echo "debug: OFF"; fi
unset DEBUG
}


main "$@"

Add the lines between the comments and save. Now when a user is added both a home dir is created with a 10G quota set.

678 Views
0 Kudos
Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
1 of 1
Last update:
‎07-13-2017 01:48 PM
Updated by:
 
Contributors
Top Kudoed Authors