#!/bin/sh
$1 is the NIS domain, $2 is the primary NIS server
ypcat -k -d $1 -h $2 netgroup > /dev/shm/nis-map.netgroup 2>&1
IFS=$'\n'
for line in $(cat /dev/shm/nis-map.netgroup); do
IFS=' '
netgroupname=$(echo $line | awk '{print $1}')
triples=$(echo $line | sed "s/^$netgroupname //")
echo "ipa netgroup-add $netgroupname --desc=NIS_NG_$netgroupname"
if [ $(echo $line | grep "(," | wc -l) -gt 0 ]; then
echo "ipa netgroup-mod $netgroupname --hostcat=all"
fi
if [ $(echo $line | grep ",," | wc -l) -gt 0 ]; then
echo "ipa netgroup-mod $netgroupname --usercat=all"
fi
for triple in $triples; do
triple=$(echo $triple | sed -e 's/-//g' -e 's/(//' -e 's/)//')
if [ $(echo $triple | grep ",.*," | wc -l) -gt 0 ]; then
hostname=$(echo $triple | cut -f1 -d,)
username=$(echo $triple | cut -f2 -d,)
domain=$(echo $triple | cut -f3 -d,)
hosts=""; users=""; doms="";
[ -n "$hostname" ] && hosts="--hosts=$hostname"
[ -n "$username" ] && users="--users=$username"
[ -n "$domain" ] && doms="--nisdomain=$domain"
echo "ipa netgroup-add-member $netgroup $hosts $users $doms"
else
netgroup=$triple
echo "ipa netgroup-add $netgroup --desc=<NIS_NG>_$netgroup"
fi
done
done
#!/bin/sh
ypcat -k -d $1 -h $2 netgroup > /dev/shm/nis-map.netgroup 2>&1
IFS=$'\n'
for line in $(cat /dev/shm/nis-map.netgroup); do
IFS=' '
netgroupname=$(echo $line | awk '{print $1}')
triples=$(echo $line | sed "s/^$netgroupname //")
echo "ipa netgroup-add $netgroupname --desc=NIS_NG_$netgroupname"
if [ $(echo $line | grep "(," | wc -l) -gt 0 ]; then
echo "ipa netgroup-mod $netgroupname --hostcat=all"
fi
if [ $(echo $line | grep ",," | wc -l) -gt 0 ]; then
echo "ipa netgroup-mod $netgroupname --usercat=all"
fi
for triple in $triples; do
triple=$(echo $triple | sed -e 's/-//g' -e 's/(//' -e 's/)//')
if [ $(echo $triple | grep ",.*," | wc -l) -gt 0 ]; then
hostname=$(echo $triple | cut -f1 -d,)
username=$(echo $triple | cut -f2 -d,)
domain=$(echo $triple | cut -f3 -d,)
hosts=""; users=""; doms="";
[ -n "$hostname" ] && hosts="--hosts=$hostname"
[ -n "$username" ] && users="--users=$username"
[ -n "$domain" ] && doms="--nisdomain=$domain"
echo "ipa netgroup-add-member $netgroup $hosts $users $doms"
else
netgroup=$triple
echo "ipa netgroup-add $netgroup --desc=<NIS_NG>_$netgroup"
fi
done
done
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow