Robert Kudyba wrote: > Using the sample script > <https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Identity_Management_Guide/migrating-from-nis.html#nis-import-hosts> > Im > trying to use hosts that are in various states meaning they could be > powered off or disconnected, in our 2 campuses. We maintain a master > /etc/hosts file just to document how are static IPs are assigned. When > I try to use the script I get asked for the zone name for each host. We > use the DNS of the university rather than running one on the FreeIPA > Fedora 25 server. This is a new install so I can redo this as needed. > Heres what I get: > > ./nis-hosts.sh nisname subdomain.ourdomain.edu > <http://subdomain.ourdomain.edu> > Zone name: > ipa: ERROR: 'name' is required > awk: cmd. line:1: {print $3 "." subdomain.ourdomain.edu > <http://subdomain.ourdomain.edu> "." nisname ".in-addr.arpa."} > awk: cmd. line:1: ^ syntax error > > Zone name: subdomain > ipa: ERROR: DNS is not configured
Looks to me like the DNS component was not configured in IPA so all the dns-* commands will fail. > Note Im using our real domain and subdomain from above. The script is > below. Can I hard code our domain and/or sub-domain some where in the > script to get around the Zone name being prompted for each host? > > #!/bin/sh > # 1 is the nis domain, 2 is the nis master server > ypcat -d $1-h $2hosts | egrep -v "localhost|127.0.0.1"> > /dev/shm/nis-map.hosts 2>&1 > > > > IFS=$'\n' > forline in$(cat /dev/shm/nis-map.hosts); do > IFS=' ' > ipaddress=$(echo $line|awk '{print $1}') > hostname=$(echo $line|awk '{print $2}') > master=$(ipa env xmlrpc_uri |tr -d '[:space:]'|cut -f3 -d:|cut > -f3 -d/) > domain=$(ipa env domain|tr -d '[:space:]'|cut -f2 -d:) I'd move these two ipa env commands out of the loop. These values won't change and will just work to slow down the import. rob > if[ $(echo $hostname|grep "\."|wc -l) -eq 0 ]; then > hostname=$(echo $hostname.$domain) > fi > zone=$(echo $hostname|cut -f2- -d.) > if[ $(ipa dnszone-show $zone2>/dev/null | wc -l) -eq 0 ]; then > ipa dnszone-add > --name-server=$master--admin-email=root.$master > fi > ptrzone=$(echo $ipaddress|awk -F. '{print $3 "." $2 "." $1 > ".in-addr.arpa."}') > if[ $(ipa dnszone-show $ptrzone2>/dev/null|wc -l) -eq 0 ]; then > ipa dnszone-add > $ptrzone--name-server=$master--admin-email=root.$master > fi > # Now create this entry > ipa host-add $hostname--ip-address=$ipaddress > ipa host-show $hostname > done > > > -- Manage your subscription for the Freeipa-users mailing list: https://www.redhat.com/mailman/listinfo/freeipa-users Go to http://freeipa.org for more info on the project