From f91c943bad25b7fbafa8e16ac6cc21cffaebf54b Mon Sep 17 00:00:00 2001 From: jgaunt Date: Tue, 21 Jul 2020 20:16:50 -0400 Subject: [PATCH] add os name and version --- domainjoin.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/domainjoin.sh b/domainjoin.sh index 389d364..b90c0c6 100644 --- a/domainjoin.sh +++ b/domainjoin.sh @@ -4,13 +4,26 @@ if [ "$EUID" -ne 0 ]; then echo "Please run as root" exit fi - # ask for the domain, username, and password read -e -p "Enter Domain name: " -i "home.johnhgaunt.com" domain read -e -p "Enter netBIOS name: " -i "GAUNT" netbiosname read -e -p "Enter Domain Admin username: " -i "jgaunt" username read -e -s -p "Enter Password: " password +# get OS ditro and version +OS=$(hostnamectl | awk '/Operating System/ {print $3}') +if [ "${OS}" == "Ubuntu" ]; then + OS_VER=$(hostnamectl | awk '/Operating System/ {print $4}') +else + OS_VER=$(hostnamectl | awk '/Operating System/ {print $5}') +fi + +# set os name and version for when the computer joins AD +echo "[active-directory]" > /etc/realmd.conf +echo "os-name = ${OS}" >> /etc/realmd.conf +echo "os-version = ${OS_VER}" >> /etc/realmd.conf + + # join the computer to the domain echo ${password} | realm join -U ${username} ${domain}