From f751b0d6d0969d6ff18a7696e14b32c51c0d1ef1 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Mon, 28 Feb 2022 10:06:07 -0500 Subject: [PATCH] Add Whiptail choice regarding --- template_setup.sh | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/template_setup.sh b/template_setup.sh index 25adb52..03e4386 100644 --- a/template_setup.sh +++ b/template_setup.sh @@ -1,28 +1,36 @@ +#!/bin/bash echo "Setting up template environment" -source ~/.bashrc +source $HOME/.bashrc +## Update echo "Running topgrade" /opt/topgrade/topgrade -echo "Checking if Directory $nssdb_dir contains Membership to FreeIPA Realm" -realm_join=0 -if [[ ! -f /var/lib/ipa-client/sysrestore/sysrestore.state ]] +## FreeIPA Realm Join +if (whiptail --title "FreeIPA Relam Join" --yes-button "yes" --no-button "no" --yesno "Do You want to join a FreeIPA Realm?" 10 80) then - echo "$HOSTNAME appears to not be joined to FreeIPA Server Realm" - realm_join=1 -else - echo "$HOSTNAME appears to already be joined to FreeIPA Server Realm" -fi - -if [[ $HOSTNAME == *template* ]]; then - echo "Hostname $HOSTNAME contains the word 'template', skipping realm joining" + echo "Checking if system already contains Membership to FreeIPA Realm" realm_join=0 -fi + if [[ ! -f /var/lib/ipa-client/sysrestore/sysrestore.state ]] + then + echo "$HOSTNAME appears to not be joined to FreeIPA Server Realm" + realm_join=1 + else + echo "$HOSTNAME appears to already be joined to FreeIPA Server Realm" + fi -if [ "$realm_join" == 1 ]; then - echo "Setting up ipa-client to join FreeIPA Server Realm" - freeipa_admin=$(whiptail --passwordbox "Please enter the user authorized to join FreeIPA realm: $freeipa_admin" 8 78 --title "FreeIPA Admin User Prompt" 3>&1 1>&2 2>&3) - freeipa_password=$(whiptail --passwordbox "Please enter the password for the FreeIPA admin user: $freeipa_admin" 8 78 --title "FreeIPA Password Prompt" 3>&1 1>&2 2>&3) - ipa-client-install --mkhomedir --no-ntp --principal="$freeipa_admin" --password="$freeipa_password" --enable-dns-updates --unattended + if [[ $HOSTNAME == *template* ]]; then + echo "Hostname $HOSTNAME contains the word 'template', skipping realm joining" + realm_join=0 + fi + + if [ "$realm_join" == 1 ]; then + echo "Setting up ipa-client to join FreeIPA Server Realm" + freeipa_admin=$(whiptail --passwordbox "Please enter the user authorized to join FreeIPA realm: $freeipa_admin" 8 78 --title "FreeIPA Admin User Prompt" 3>&1 1>&2 2>&3) + freeipa_password=$(whiptail --passwordbox "Please enter the password for the FreeIPA admin user: $freeipa_admin" 8 78 --title "FreeIPA Password Prompt" 3>&1 1>&2 2>&3) + ipa-client-install --mkhomedir --no-ntp --principal="$freeipa_admin" --password="$freeipa_password" --enable-dns-updates --unattended + fi +else + echo "Skipping realm joining" fi