Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

13.5.3.5. Automount マップのインポート

自動マウントマップは実際には、場所 (親エントリー) と関連のキーおよびマップを定義する入れ子および相互関連のエントリーになります。
NIS および IdM エントリーのデータは同じですが、データの定義方法は異なります。NIS 情報は、エクスポートして、自動マウントの場所と関連マップの LDAP エントリー構築に使用します。次に、マップ用に設定されたすべてのキーのエントリーを作成します。
このスクリプトは、他の NIS 移行スクリプトの例とは異なり、移行する NIS ドメインおよびサーバー以外に自動マウントの場所、マップ名もオプションとして指定できます。
#!/bin/sh
# 1 is for the automount entry in ipa

ipa automountlocation-add $1 
 
# 2 is the nis domain, 3 is the nis master server, 4 is the map name 
ypcat -k -d $2 -h $3 $4 > /dev/shm/nis-map.$4 2>&1 
 
ipa automountmap-add $1 $4 
 
basedn=$(ipa env basedn|tr -d '[:space:]'|cut -f2 -d:) 
cat > /tmp/amap.ldif <<EOF 
dn: nis-domain=nisdomain.example.com+nis-map=$4,cn=NIS Server,cn=plugins,cn=config 
objectClass: extensibleObject 
nis-domain: $3 
nis-map: $4 
nis-base: automountmapname=$4,cn=nis,cn=automount,$basedn 
nis-filter: (objectclass=*) 
nis-key-format: %{automountKey} 
nis-value-format: %{automountInformation}        
EOF 
ldapadd -x -h $3 -D "cn=directory manager" -w secret -f /tmp/amap.ldif 
 
IFS=$'\n' 
for line in $(cat /dev/shm/nis-map.$4); do  
        IFS=" " 
        key=$(echo "$line" | awk '{print $1}') 
        info=$(echo "$line" | sed -e "s#^$key[ \t]*##") 
        ipa automountkey-add nis $4 --key="$key" --info="$info" 
done
これは、特定の NIS ドメインに対して実行できます。
[root@nis-server ~]# kinit admin
[root@nis-server ~]# ./nis-hosts.sh location nisdomain nis-master.example.com map