GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
linux_lab
/
bootstrap
Browse code
Run puppet before and after domain join. Leave domain before joining.
master
1 parent
77d1dea
commit
3165cf1ace0f4493965997052e6c9be355a98bb1
Administrator
authored
on 12 Feb 2021
Patch
Showing
1 changed file
bootstrap.sh
Ignore Space
Show notes
View
bootstrap.sh
#!/usr/bin/env bash # Author: MG BASE_PATH=$(pwd) CURRENT_USER=$(whoami) if [[ ${CURRENT_USER} != root ]]; then echo "You need to run this script as root. Aborting." exit fi cd /tmp echo "## Cloning bootstrap repo ##" git clone https://isgb.otago.ac.nz/infosci/git/linux_lab/bootstrap.git cd bootstrap echo echo -n "Enter hostname: " read hostname echo ${hostname} echo echo "About to join domain as ${hostname}" echo "Press Enter to continue or Ctrl+c to abort" read echo echo "## Setting hostname to ${hostname} ... ##" hostnamectl set-hostname ${hostname} echo echo "## Running bootstrap via puppet... ##" PUPPET_ROOT=/tmp/bootstrap/environments/production MODULE_PATH=${PUPPET_ROOT}/modules SITE_PATH=${PUPPET_ROOT}/manifests/site.pp RUBYOPT='-W0' puppet apply --modulepath ${MODULE_PATH} ${SITE_PATH} user=$(sed -n 1p ${BASE_PATH}/domain_sekrit) domain=$(sed -n 2p ${BASE_PATH}/domain_sekrit) pass=$(sed -n 3p ${BASE_PATH}/domain_sekrit) echo echo "## Leaving domain... ##" echo ${pass} | realm leave --verbose --user=${user} ${domain} echo echo "## Joining domain... ##" echo ${pass} | realm join --verbose --user=${user} ${domain} echo echo "## Running bootstrap via puppet again (to correct changes made as a result of domain join) ... ##" RUBYOPT='-W0' puppet apply --modulepath ${MODULE_PATH} ${SITE_PATH} echo echo "## Cleaning up... ##" cd .. rm -rf /tmp/bootstrap echo echo "## Done. ##"
#!/usr/bin/env bash # Author: MG BASE_PATH=$(pwd) CURRENT_USER=$(whoami) if [[ ${CURRENT_USER} != root ]]; then echo "You need to run this script as root. Aborting." exit fi cd /tmp echo "## Cloning bootstrap repo ##" git clone https://isgb.otago.ac.nz/infosci/git/linux_lab/bootstrap.git cd bootstrap echo echo -n "Enter hostname: " read hostname echo ${hostname} echo echo "About to join domain as ${hostname}" echo "Press Enter to continue or Ctrl+c to abort" read echo echo "## Setting hostname to ${hostname} ... ##" hostnamectl set-hostname ${hostname} echo echo "## Running bootstrap via puppet... ##" PUPPET_ROOT=/tmp/bootstrap/environments/production MODULE_PATH=${PUPPET_ROOT}/modules SITE_PATH=${PUPPET_ROOT}/manifests/site.pp RUBYOPT='-W0' puppet apply --modulepath ${MODULE_PATH} ${SITE_PATH} echo echo "## Joining domain... ##" user=$(sed -n 1p ${BASE_PATH}/domain_sekrit) domain=$(sed -n 2p ${BASE_PATH}/domain_sekrit) pass=$(sed -n 3p ${BASE_PATH}/domain_sekrit) echo ${pass} | realm join --verbose --user=${user} ${domain} echo echo "## Cleaning up... ##" cd .. rm -rf /tmp/bootstrap echo echo "## Done. ##"
Show line notes below