sync_ldap_users_groups.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # Licensed to Cloudera, Inc. under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. Cloudera, Inc. licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # NOTE: This script requires curl to be installed. Also, it does not have to run on the Hue server, it can run anywhere that curl is installed. As long as that host can reach the Hue server.
  18. # Please change USER to contain the user to login
  19. USER="cconner"
  20. # Please change PASSWORD to contain the password for the above user
  21. PASSWORD="password"
  22. #Please enter the Hue server name below
  23. HUE_SERVER="cdh46-1"
  24. #Please enter the Hue server port below
  25. HUE_PORT="8888"
  26. #Please enter the group name you want to sync
  27. GROUP_NAME="admins"
  28. #Please enter off or on based on if you want to import the members of the group
  29. IMPORT_MEMBERS="on"
  30. #Please enter off or on based on if you want to create home directories for new users
  31. CREATE_DIRS="on"
  32. HUE_PASS_URL="${HUE_SERVER}:${HUE_PORT}/accounts/login/"
  33. HUE_LDAP_USER_GROUP_SYNC_URL="${HUE_SERVER}:${HUE_PORT}/useradmin/users/sync_ldap_users_groups"
  34. echo "Running Command:"
  35. echo "curl -i -c /tmp/${USER}_cookie.txt -d \"username=${USER}&password=${PASSWORD}\" \"${HUE_PASS_URL}\""
  36. curl -i -c /tmp/${USER}_cookie.txt -d "username=${USER}&password=${PASSWORD}" "${HUE_PASS_URL}"
  37. echo "Running Command:"
  38. echo "curl -i -b /tmp/${USER}_cookie.txt \"${HUE_LDAP_USER_GROUP_SYNC_URL}\" > /dev/null"
  39. curl -i -b /tmp/${USER}_cookie.txt "${HUE_LDAP_USER_GROUP_SYNC_URL}" > /dev/null