Differences
This shows you the differences between two versions of the page.
linux_wiki:freeipa_report_uids_gids [2017/09/02 17:40] billdozor created |
linux_wiki:freeipa_report_uids_gids [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== FreeIPA: Report UIDs GIDs ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | Output all UIDs and GIDs (names to number mappings) to two separate files. | ||
- | |||
- | **Checklist** | ||
- | * Distro(s): | ||
- | * Other: [[http:// | ||
- | |||
- | ---- | ||
- | |||
- | ====== The Script ====== | ||
- | |||
- | <code bash report-uids-gids.sh> | ||
- | #!/bin/bash | ||
- | # Name: report-uids-gids.sh | ||
- | # Description: | ||
- | # Last Updated: 2016-10-07 | ||
- | # Recent Changes: | ||
- | ############################################################################################### | ||
- | |||
- | ##### Customize These Variables ##### | ||
- | # admin credentials | ||
- | admin_user=" | ||
- | |||
- | # Dump files for uids/gids | ||
- | dump_uids="/ | ||
- | dump_gids="/ | ||
- | ##### End of Customize Variables ##### | ||
- | |||
- | # | ||
- | # Functions; Main starts after | ||
- | # | ||
- | function show_usage | ||
- | { | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e "-> FreeIPA admin access." | ||
- | echo -e | ||
- | } | ||
- | |||
- | # | ||
- | # Get Script Arguments | ||
- | # | ||
- | # Reset POSIX variable in case it has been used previously in this shell | ||
- | OPTIND=1 | ||
- | |||
- | while getopts " | ||
- | case " | ||
- | h) # -h (help) argument | ||
- | show_usage | ||
- | exit 0 | ||
- | ;; | ||
- | *) # invalid argument | ||
- | show_usage | ||
- | exit 0 | ||
- | ;; | ||
- | esac | ||
- | done | ||
- | |||
- | # | ||
- | # Main Starts Here | ||
- | # | ||
- | |||
- | # Pre-check - see if we have a kerberos ticket, if not, prompt login | ||
- | / | ||
- | if [[ $? -ne 0 ]]; then | ||
- | echo ">> | ||
- | / | ||
- | echo | ||
- | fi | ||
- | |||
- | echo -e " | ||
- | echo -e "#### | ||
- | echo -e " | ||
- | echo | ||
- | echo -e "This script will get all usernames/ | ||
- | echo -e "User IDs: ${dump_uids}" | ||
- | echo -e "Group IDs: ${dump_gids}" | ||
- | |||
- | echo -e " | ||
- | read run_script | ||
- | |||
- | if [[ ${run_script} != " | ||
- | echo -e " | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | echo -e ">> | ||
- | cat /dev/null > ${dump_uids} | ||
- | cat /dev/null > ${dump_gids} | ||
- | |||
- | echo -e ">> | ||
- | user_list=" | ||
- | |||
- | echo -e ">> | ||
- | for user_field in $(echo ${user_list}); | ||
- | if [[ " | ||
- | echo -en ": ${user_field}" | ||
- | else | ||
- | echo -e " | ||
- | fi | ||
- | done | ||
- | |||
- | echo -e ">> | ||
- | group_list=" | ||
- | |||
- | echo -e ">> | ||
- | for group_field in $(echo ${group_list}); | ||
- | if [[ " | ||
- | echo -en ": ${group_field}" | ||
- | else | ||
- | echo -e " | ||
- | fi | ||
- | done | ||
- | |||
- | echo -e " | ||
- | |||
- | echo -e " | ||
- | echo -e "#### | ||
- | echo -e " | ||
- | </ | ||
- | |||
- | ---- | ||