Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
linux_wiki:spacewalk_register [2015/12/21 23:03] billdozor created |
linux_wiki:spacewalk_register [2019/07/11 22:29] (current) billdozor [The Script] |
||
---|---|---|---|
Line 3: | Line 3: | ||
**General Information** | **General Information** | ||
- | Registering | + | Register or unregister |
**Checklist** | **Checklist** | ||
- | * Enterprise Linux 6/7 | + | * Distro(s): |
- | * Spacewalk | + | * Other: [[https:// |
---- | ---- | ||
- | ====== | + | ====== |
- | <code bash spacewalk_register.sh> | + | This Spacewalk |
- | ############################################################################################ | + | |
- | # | + | |
- | # Title: spacewalk_register.sh | + | |
- | # Description: | + | |
- | ############################################################################################ | + | |
- | + | ||
- | # | + | |
- | # CUSTOMIZE HERE | + | |
- | # | + | |
- | #spacewalk server fqdn hostname | + | |
- | sw_server=" | + | |
- | + | ||
- | #spacewalk server' | + | |
- | #(this is the package available at: https:// | + | |
- | sw_server_ca=" | + | |
- | + | ||
- | #spacewalk server channel activation keys | + | |
- | sw_activation_key_centos6=" | + | |
- | sw_activation_key_centos7=" | + | |
- | sw_activation_key_oracle6=" | + | |
- | sw_activation_key_oracle7=" | + | |
- | + | ||
- | #spacewalk client repos | + | |
- | sw_client_repo_el6=" | + | |
- | sw_client_repo_el7=" | + | |
- | + | ||
- | # | + | |
- | # END OF CUSTOMIZATION | + | |
- | # | + | |
- | + | ||
- | # | + | |
- | # Functions; Main starts after | + | |
- | # | + | |
- | function check_os_type | + | |
- | { | + | |
- | if [[ $(uname -i) != " | + | |
- | echo -e " | + | |
- | exit 1 | + | |
- | else | + | |
- | ## Gather Distro and Major Version | + | |
- | if [ -f / | + | |
- | distro=$(awk -F: ' | + | |
- | major_version=$(awk -F: ' | + | |
- | elif [ -f / | + | |
- | distro=$(awk ' | + | |
- | major_version=$(awk -F. ' | + | |
- | fi | + | |
- | + | ||
- | if [[ ${distro,,} == " | + | |
- | case ${major_version} in | + | |
- | 7) | + | |
- | # CentOS 7 register | + | |
- | sw_client_repo=${sw_client_repo_el7} | + | |
- | sw_activation_key=${sw_activation_key_centos7} | + | |
- | ;; | + | |
- | 6) | + | |
- | # CentOS 6 register | + | |
- | sw_client_repo=${sw_client_repo_el6} | + | |
- | sw_activation_key=${sw_activation_key_centos6} | + | |
- | ;; | + | |
- | *) | + | |
- | echo -e " | + | |
- | exit 1 | + | |
- | ;; | + | |
- | esac | + | |
- | elif [[ ${distro,,} == " | + | |
- | case ${major_version} in | + | |
- | 7) | + | |
- | # Oracle 7 register | + | |
- | sw_client_repo=${sw_client_repo_el7} | + | |
- | sw_activation_key=${sw_activation_key_oracle7} | + | |
- | ;; | + | |
- | 6) | + | |
- | # Oracle 6 register | + | |
- | sw_client_repo=${sw_client_repo_el6} | + | |
- | sw_activation_key=${sw_activation_key_oracle6} | + | |
- | ;; | + | |
- | *) | + | |
- | echo -e " | + | |
- | exit 1 | + | |
- | ;; | + | |
- | esac | + | |
- | else | + | |
- | echo -e " | + | |
- | exit 1 | + | |
- | fi | + | |
- | + | ||
- | fi | + | |
- | } | + | |
- | + | ||
- | #### | + | |
- | #### Main Starts Here | + | |
- | #### | + | |
- | + | ||
- | echo -e " | + | |
- | echo -e "#### | + | |
- | echo -e " | + | |
- | + | ||
- | ## Check OS type. set client repo, and spacewalk activation key variable | + | |
- | echo -e " | + | |
- | check_os_type | + | |
- | + | ||
- | # | + | |
- | # Confirm running the script | + | |
- | # | + | |
- | echo | + | |
- | echo -e " | + | |
- | echo -e " | + | |
- | echo -e "Will Register | + | |
- | echo -e " | + | |
- | echo -e " | + | |
- | read run_script | + | |
- | + | ||
- | if [[ ${run_script} != " | + | |
- | echo -e " | + | |
- | exit 1 | + | |
- | fi | + | |
- | + | ||
- | ## Add Repos ## | + | |
- | echo -e " | + | |
- | yum -y install ${sw_client_repo} | + | |
- | + | ||
- | echo -e " | + | |
- | dig mirrors.fedoraproject.org &> | + | |
- | + | ||
- | echo -e " | + | |
- | yum -y install epel-release | + | |
- | + | ||
- | echo -e " | + | |
- | sed -i ' | + | |
- | + | ||
- | ## Install Spacewalk' | + | |
- | echo -e " | + | |
- | rpm -ivh https:// | + | |
- | + | ||
- | ## Install Client Packages ## | + | |
- | echo -e " | + | |
- | yum -y install rhn-client-tools rhn-check rhn-setup rhnsd m2crypto yum-rhn-plugin | + | |
- | + | ||
- | echo -e " | + | |
- | yum -y install rhncfg rhncfg-actions rhncfg-client rhncfg-management | + | |
- | + | ||
- | ## Register ## | + | |
- | echo -e " | + | |
- | rhnreg_ks --serverUrl=https:// | + | |
- | registration_return_code=$? | + | |
- | + | ||
- | if [[ ${registration_return_code} -eq 0 ]]; then | + | |
- | echo -e "-> Registration successful." | + | |
- | sleep 1 | + | |
- | else | + | |
- | echo -e "-> Registration encountered an error! (Return Code: ${registration_return_code})" | + | |
- | echo -e "-> Will NOT install osad and disable default repos...exiting." | + | |
- | exit 1 | + | |
- | fi | + | |
- | + | ||
- | # Install osad (jabberd client for immediate response to remote commands) | + | |
- | echo -e " | + | |
- | yum -y install osad | + | |
- | + | ||
- | if [[ ${major_version} == " | + | |
- | systemctl enable osad | + | |
- | systemctl start osad | + | |
- | else | + | |
- | chkconfig osad on | + | |
- | service osad start | + | |
- | fi | + | |
- | + | ||
- | # Allow Spacewalk server to deploy config files | + | |
- | echo -e " | + | |
- | rhn-actions-control --enable-all | + | |
- | + | ||
- | ## Disable Old Repos ## | + | |
- | + | ||
- | if [[ ${distro,,} == " | + | |
- | # Disable CentOS default system repos | + | |
- | echo -e " | + | |
- | for FILE in / | + | |
- | sed -i ' | + | |
- | sed -i '/ | + | |
- | done | + | |
- | elif [[ ${distro,,} == " | + | |
- | # Disable Oracle default system repos | + | |
- | echo -e " | + | |
- | for FILE in / | + | |
- | sed -i ' | + | |
- | sed -i '/ | + | |
- | done | + | |
- | fi | + | |
- | + | ||
- | # Disable temporary epel repo | + | |
- | echo -e " | + | |
- | sed -i ' | + | |
- | sed -i ' | + | |
- | + | ||
- | # Show repos | + | |
- | echo -e " | + | |
- | yum repolist | + | |
- | + | ||
- | # Show website | + | |
- | echo -e " | + | |
- | + | ||
- | echo -e " | + | |
- | echo "# Spacewalk Registration Completed." | + | |
- | echo "# | + | |
- | exit 0 | + | |
- | </ | + | |
---- | ---- | ||