Differences
This shows you the differences between two versions of the page.
linux_wiki:freeipa_client_enroll [2018/06/02 23:19] billdozor [FreeIPA Client Enroll] |
linux_wiki:freeipa_client_enroll [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== FreeIPA Client Enroll ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | Enrolling a new client with FreeIPA servers. | ||
- | |||
- | **Checklist** | ||
- | * Distro(s): Enterprise Linux 6/7 | ||
- | * Other: [[http:// | ||
- | |||
- | ---- | ||
- | |||
- | ====== The Script ====== | ||
- | |||
- | <code bash ipa-enroll-client.sh> | ||
- | #!/bin/bash | ||
- | # Name: ipa-enroll-client.sh | ||
- | # Description: | ||
- | # Last Updated: 12/28/2016 | ||
- | # Recent Changes: | ||
- | ################################################################################### | ||
- | |||
- | ##### Customize These Variables ##### | ||
- | |||
- | # Domain Name | ||
- | domain_name=" | ||
- | |||
- | # IPA Servers | ||
- | ipa_server1=" | ||
- | ipa_server2=" | ||
- | |||
- | # User with permissions to enroll/ | ||
- | # For security purposes, this account should not be able to login to any systems | ||
- | enroll_user=" | ||
- | |||
- | # Password of Enroll User | ||
- | enroll_pw=" | ||
- | |||
- | ##### End of Customize Variables ##### | ||
- | |||
- | #### Functions Here: Main Starts After #### | ||
- | function check_os_type | ||
- | { | ||
- | if [ -f / | ||
- | distro=$(awk -F: ' | ||
- | major_version=$(awk -F: ' | ||
- | elif [ -f / | ||
- | distro=$(awk ' | ||
- | major_version=$(awk -F. ' | ||
- | fi | ||
- | } | ||
- | |||
- | function show_usage | ||
- | { | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e "-> FreeIPA admin access for interactive mode." | ||
- | echo -e | ||
- | } | ||
- | |||
- | #### End of Functions #### | ||
- | |||
- | # | ||
- | # Get Script Arguments | ||
- | # | ||
- | # Reset POSIX variable in case it has been used previously in this shell | ||
- | OPTIND=1 | ||
- | |||
- | #Default Settings | ||
- | interactive=" | ||
- | |||
- | while getopts " | ||
- | case " | ||
- | h) # -h (help) argument | ||
- | show_usage | ||
- | exit 0 | ||
- | ;; | ||
- | i) # -i (interactive) argument | ||
- | interactive=" | ||
- | ;; | ||
- | *) # invalid argument | ||
- | show_usage | ||
- | exit 0 | ||
- | ;; | ||
- | esac | ||
- | done | ||
- | |||
- | # | ||
- | # Main Starts Here | ||
- | # | ||
- | |||
- | # Pre-checks | ||
- | check_os_type | ||
- | |||
- | # | ||
- | # Confirm running the script | ||
- | # | ||
- | echo -e " | ||
- | echo -e "#### | ||
- | echo -e " | ||
- | echo | ||
- | echo -e " | ||
- | echo -e " | ||
- | if [[ ${interactive} == " | ||
- | echo -e "Mode: Unattended" | ||
- | else | ||
- | echo -e "Mode: Interactive" | ||
- | fi | ||
- | echo -e " | ||
- | read run_script | ||
- | |||
- | if [[ ${run_script} != " | ||
- | echo -e " | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | echo -e " | ||
- | yum -y install ipa-client | ||
- | |||
- | echo -e " | ||
- | case ${major_version} in | ||
- | " | ||
- | if [[ ${interactive} == " | ||
- | ## Unattended ## | ||
- | ipa-client-install --domain=${domain_name} --server=${ipa_server1} --server=${ipa_server2} --mkhomedir --no-dns-sshfp --fixed-primary --hostname=$(hostname | sed " | ||
- | else | ||
- | ## Interactive ## | ||
- | ipa-client-install --domain=${domain_name} --server=${ipa_server1} --server=${ipa_server2} --mkhomedir --no-dns-sshfp --fixed-primary --hostname=$(hostname | sed " | ||
- | fi | ||
- | ;; | ||
- | " | ||
- | if [[ ${interactive} == " | ||
- | ## Unattended ## | ||
- | ipa-client-install --domain=${domain_name} --server=${ipa_server2} --server=${ipa_server1} --mkhomedir --no-dns-sshfp --fixed-primary --hostname=$(hostname | sed " | ||
- | else | ||
- | ## Interactive ## | ||
- | ipa-client-install --domain=${domain_name} --server=${ipa_server2} --server=${ipa_server1} --mkhomedir --no-dns-sshfp --fixed-primary --hostname=$(hostname | sed " | ||
- | fi | ||
- | ;; | ||
- | " | ||
- | if [[ ${interactive} == " | ||
- | ## Unattended ## | ||
- | ipa-client-install --domain=${domain_name} --server=${ipa_server1} --server=${ipa_server2} --mkhomedir --hostname=$(hostname | sed " | ||
- | else | ||
- | ## Interactive ## | ||
- | ipa-client-install --domain=${domain_name} --server=${ipa_server1} --server=${ipa_server2} --mkhomedir --hostname=$(hostname | sed " | ||
- | fi | ||
- | ;; | ||
- | esac | ||
- | |||
- | echo -e " | ||
- | rhncfg-client get / | ||
- | |||
- | echo -e " | ||
- | case ${major_version} in | ||
- | " | ||
- | systemctl restart sshd | ||
- | ;; | ||
- | " | ||
- | service sshd restart | ||
- | ;; | ||
- | esac | ||
- | |||
- | echo -e " | ||
- | case ${major_version} in | ||
- | " | ||
- | systemctl stop nslcd | ||
- | systemctl stop nscd | ||
- | systemctl disable nslcd | ||
- | systemctl disable nscd | ||
- | ;; | ||
- | " | ||
- | service nslcd stop | ||
- | service nscd stop | ||
- | chkconfig nslcd off | ||
- | chkconfig nscd off | ||
- | ;; | ||
- | " | ||
- | service nscd stop | ||
- | chkconfig nscd off | ||
- | ;; | ||
- | esac | ||
- | |||
- | echo -e " | ||
- | case ${major_version} in | ||
- | " | ||
- | authconfig --disableldap --disableldapauth --disableforcelegacy --update | ||
- | ;; | ||
- | " | ||
- | authconfig --disableldap --disableldapauth --update | ||
- | ;; | ||
- | esac | ||
- | |||
- | echo -e " | ||
- | case ${major_version} in | ||
- | " | ||
- | systemctl restart sssd | ||
- | ;; | ||
- | " | ||
- | service sssd restart | ||
- | ;; | ||
- | esac | ||
- | |||
- | echo -e " | ||
- | case ${major_version} in | ||
- | " | ||
- | systemctl start oddjobd | ||
- | systemctl enable oddjobd | ||
- | ;; | ||
- | " | ||
- | service messagebus start | ||
- | service oddjobd start | ||
- | chkconfig messagebus on | ||
- | chkconfig oddjobd on | ||
- | ;; | ||
- | " | ||
- | service messagebus start | ||
- | service oddjobd start | ||
- | chkconfig messagebus on | ||
- | chkconfig oddjobd on | ||
- | ;; | ||
- | esac | ||
- | |||
- | if [[ ${major_version} == " | ||
- | |||
- | echo -e " | ||
- | |||
- | if [[ $(grep client_idle_timeout / | ||
- | echo -e " | ||
- | else | ||
- | echo -e " | ||
- | sed -i '/ | ||
- | service sssd restart | ||
- | service crond restart | ||
- | fi | ||
- | |||
- | fi | ||
- | |||
- | echo -e " | ||
- | echo -e "#### | ||
- | echo -e " | ||
- | </ | ||
- | |||
- | ---- | ||